# Define here the models for your scraped items
#
# See documentation in:
# http://doc.scrapy.org/en/latest/topics/items.html

# A reminder: The 2 fields, 'file_urls' and 'files' are special fields
# required by scrapy pipeline for storing files to local disk.
# See https://groups.google.com/forum/print/msg/scrapy-users/kzGHFjXywuY/O6PIhoT3thsJ
# for more details and usage.

from scrapy.item import Item, Field
    
class TypedItem(Item):
    """ Quick extension so you can define type_name on an Item and
        it will get spit out in the JSON format. Replace this if
        you find a better way of achieving this.
    """
    type = Field()

    def __init__(self, *args, **kwargs):
        super(TypedItem, self).__init__(*args, **kwargs)
        self['type'] = self.type_name 

#########################################################
#   ___                  _   _                 
#  / _ \ _   _  ___  ___| |_(_) ___  _ __  ___ 
# | | | | | | |/ _ \/ __| __| |/ _ \| '_ \/ __|
# | |_| | |_| |  __/\__ \ |_| | (_) | | | \__ \
#  \__\_\\__,_|\___||___/\__|_|\___/|_| |_|___/
    type_name = "QuestionRecordQuestion"

    question_no = Field()
    # The member who raised the question
    raised_by = Field()
    # Was the question originally asked in English or translated?
    was_translated = Field()
    # Was a written reply expected?
    written_reply = Field()
    # The opening text of the question, before the specific articles
    question_text = Field()
    # The question articles. This is a list of items in the form
    # [ (article_id, text), (article_id, text), ... ]
    articles = Field()
    # The officers who are to reply to this question
    # Currently just a blob of text
    officer_to_reply = Field()


class QuestionRecordSubsidiaryPapers(TypedItem):
    type_name = "QuestionRecordSubsidiaryPapers"

    item_no = Field()
    title = Field()
    ln_no = Field()

class QuestionRecordOtherPapers(TypedItem):
    type_name = "QuestionRecordOtherPapers"
    item_no = Field()
    title = Field()
    presented_by = Field()


#########################################################
#  _   _                               _ 
# | | | | __ _ _ __  ___  __ _ _ __ __| |
# | |_| |/ _` | '_ \/ __|/ _` | '__/ _` |
# |  _  | (_| | | | \__ \ (_| | | | (_| |
# |_| |_|\__,_|_| |_|___/\__,_|_|  \__,_|
#                                        

class HansardAgenda(TypedItem):
    ####Depreciated####
    """ This will need developing, as it is structured in HTML """
    type_name = "HansardAgenda"
    date = Field()
    source_url = Field()
    file_urls = Field()
    files = Field()

class HansardMinutes(TypedItem):
    """ This contains a file of the mintues """
    type_name = "HansardMinutes"
    date = Field()
    source_url = Field()
    file_urls = Field()
    files = Field()

class HansardRecord(TypedItem):
    """ This will contain a DOC file for the record for the date """
    type_name = "HansardRecord"
    date = Field()
    source_url = Field()
    file_urls = Field()
    files = Field()
    
#####
# Library related items, including agenda and hansard at the moment
#####

#Common item for Library database
class LibraryResultPage(TypedItem):
    """
    Stores individual results pages, for debugging
    """
    type_name = "LibraryResultPage"
    # Title of the link
    title = Field()
    link = Field()
    # Page the link was found on
    browse_url = Field()
    # The type of document this page should be fore
    document_type = Field()


class LibraryAgenda(TypedItem):
    """
    Library record for Council Meeting agendas
    """
    type_name = "LibraryAgenda"
    title_en = Field()
    title_cn = Field()
    # List of (title, link) pairs
    links = Field()
    file_urls = Field()
    files = Field()
    # The URL to the source page
    source_url = Field()
    
    
class LibraryHansard(TypedItem):
    """
    Library record for Council Meeting Hansard
    """
    type_name = "LibraryHansard"
    title_en = Field()
    title_cn = Field()
    # List of (title, link) pairs
    links = Field()
    file_urls = Field()
    files = Field()
    # The URL to the source page
    source_url = Field()
#                                             

# Note that these questions-related items are not used yet
class QuestionRecordQuestion(TypedItem):