示例#1
0
    def __census_changed(self, combo):
        """
        Called when the user selects a new census from the combo box.
        """
        model = combo.get_model()
        index = combo.get_active()
        census_id = model[index][2]

        # Set date
        census_date = get_census_date(census_id)

        date_text = self.widgets['date_text']
        date_text.set_text(displayer.display(census_date))
        self.event.set_date_object(census_date)
        self.citation.set_date_object(census_date)

        # Set source
        self.citation.set_reference_handle(model[index][0])

        # Set new columns
        columns = get_census_columns(census_id)
        report_columns = get_report_columns(census_id)
        self.details.create_table(columns, report_columns)
        heading_list = get_census_headings(census_id)
        self.headings.create_table(heading_list)
示例#2
0
    def write_census(self, event, citation):
        """
        Called for each census.
        """
        if self.pgbrk and not self.first_page:
            self.doc.page_break()
            self.first_page = False
        
        # Date, Source, Place
        p_handle = event.get_place_handle()
        place = self.database.get_place_from_handle(p_handle)
        src_handle = citation.get_reference_handle()
        source = self.database.get_source_from_handle(src_handle)
        census_id = get_census_id(source)
        headings = [x[0] for x in get_report_columns(census_id)]

        # Census title
        self.doc.start_paragraph("CEN-Heading")
        self.doc.write_text(source.get_title())
        self.doc.end_paragraph()

        self.doc.start_table("centab", "CEN-HeadingTable")

        # Date
        self.write_heading(_("Date:"), get_date(event))
        
        # Source Reference
        self.write_heading(_("Citation:"), citation.get_page())

        # Address
        if place:
            self.write_heading(_("Address:"), place.get_display_info()[0])
        else:
            self.write_heading(_("Address:"), "")

        # Blank line
        self.write_heading("", "")

        self.doc.end_table()
        self.doc.start_table("centab", "CEN-" + census_id)
       
        # People
        person_list = []
        e_handle = event.get_handle()
        for link in self.database.find_backlink_handles(
                                e_handle, include_classes=['Person']):
            person = self.database.get_person_from_handle(link[1])
            person_list.append(get_attributes(person, e_handle))

        # Heading row
        self.doc.start_row()

        for column in headings:
            self.doc.start_cell("CEN-ColumnCell")
            self.doc.start_paragraph("CEN-Column")
            self.doc.write_text(column)
            self.doc.end_paragraph()
            self.doc.end_cell()
            
        self.doc.end_row()
        
        for row in sorted(person_list):
            self.doc.start_row()

            for offset, column in enumerate(get_census_columns(census_id)):
                self.doc.start_cell("CEN-BodyCell")
                if column == _('Name'):
                    self.doc.start_paragraph("CEN-Name")
                    self.doc.write_text(row[2].get(column, row[1]))
                else:
                    self.doc.start_paragraph("CEN-Normal")
                    if column in row[2]:
                        self.doc.write_text(row[2].get(column))

                self.doc.end_paragraph()
                self.doc.end_cell()
                
            self.doc.end_row()
            
        self.doc.end_table()
示例#3
0
    def write_census(self, event, citation):
        """
        Called for each census.
        """
        if self.pgbrk and not self.first_page:
            self.doc.page_break()
            self.first_page = False

        # Date, Source, Place
        p_handle = event.get_place_handle()
        place = self.database.get_place_from_handle(p_handle)
        src_handle = citation.get_reference_handle()
        source = self.database.get_source_from_handle(src_handle)
        census_id = get_census_id(source)
        headings = [x[0] for x in get_report_columns(census_id)]

        # Census title
        self.doc.start_paragraph("CEN-Heading")
        self.doc.write_text(source.get_title())
        self.doc.end_paragraph()

        self.doc.start_table("centab", "CEN-HeadingTable")

        # Date
        self.write_heading(_("Date:"), get_date(event))

        # Source Reference
        self.write_heading(_("Citation:"), citation.get_page())

        # Address
        if place:
            self.write_heading(_("Address:"), place.get_title())
        else:
            self.write_heading(_("Address:"), "")

        # Blank line
        self.write_heading("", "")

        self.doc.end_table()
        self.doc.start_table("centab", "CEN-" + census_id)

        # People
        person_list = []
        e_handle = event.get_handle()
        for link in self.database.find_backlink_handles(
                e_handle, include_classes=['Person']):
            person = self.database.get_person_from_handle(link[1])
            person_list.append(get_attributes(person, e_handle))

        # Heading row
        self.doc.start_row()

        for column in headings:
            self.doc.start_cell("CEN-ColumnCell")
            self.doc.start_paragraph("CEN-Column")
            self.doc.write_text(column)
            self.doc.end_paragraph()
            self.doc.end_cell()

        self.doc.end_row()

        for row in sorted(person_list):
            self.doc.start_row()

            for offset, column in enumerate(get_census_columns(census_id)):
                self.doc.start_cell("CEN-BodyCell")
                if column == _('Name'):
                    self.doc.start_paragraph("CEN-Name")
                    self.doc.write_text(row[2].get(column, row[1]))
                else:
                    self.doc.start_paragraph("CEN-Normal")
                    if column in row[2]:
                        self.doc.write_text(row[2].get(column))

                self.doc.end_paragraph()
                self.doc.end_cell()

            self.doc.end_row()

        self.doc.end_table()