Cleanup work on attributes and a comment on sort_event_types() in NarrativeWeb. Clean up work on calendar_build() in WebCal.

svn: r13796
This commit is contained in:
Rob G. Healey 2009-12-14 08:47:01 +00:00
parent 3350a54f0d
commit c94c9c588e
2 changed files with 133 additions and 145 deletions

View File

@ -5238,13 +5238,7 @@ class NavWebReport(Report):
# get family attributes
attribute_list.extend(family.get_attribute_list() )
for evt_ref in family.get_event_ref_list():
event = db.get_event_from_handle(evt_ref.ref)
# get events attributes
attribute_list.extend(event.get_attribute_list() )
# attributes to its caller
# return attributes to its caller
return attribute_list
def person_pages(self, ind_list, place_list, source_list):
@ -5263,8 +5257,7 @@ class NavWebReport(Report):
# get attributes for each person
attribute_list = self.build_attributes(person)
IndividualPage(self, self.title, person, ind_list, place_list, source_list,
attribute_list)
IndividualPage(self, self.title, person, ind_list, place_list, source_list, attribute_list)
if self.inc_gendex:
self.progress.set_pass(_('Creating GENDEX file'), len(ind_list))
@ -6082,7 +6075,7 @@ def sort_people(db, handle_list):
def sort_event_types(db, event_types, event_handle_list):
"""
sort a list of event types and group them by their type
sort a list of event types and their associated event handles
@param: event_types -- a dict of event types
@param: event_handle_list -- all event handles in this database
@ -6095,7 +6088,7 @@ def sort_event_types(db, event_types, event_handle_list):
event = db.get_event_from_handle(handle)
etype = str(event.type)
# add the stuff from this event
# add (gramps_id, date, handle) from this event
if etype in event_dict:
event_dict[etype].append(
(event.gramps_id, event.get_date_object(), handle)

View File

@ -586,9 +586,10 @@ class WebCalReport(Report):
def calendar_build(self, cal, year, month):
"""
This does the work of building the calendar
'cal' - one of "yg" year_glance(), or "wc" webcalendar()
'year' -- year being created
'month' - month number 1, 2, .., 12
@param: cal - either "yg" year_glance(), or "wc" webcalendar()
@param: year -- year being created
@param: month - month number 1, 2, .., 12
"""
# define names for long and short month names
@ -653,12 +654,13 @@ class WebCalReport(Report):
th_txt = '%s %d' % (month_name, year)
# begin calendar table and table head
cal_table = Html("table", class_ = "calendar", id = month_name)
with Html("table", class_ = "calendar", id = month_name) as table:
thead = Html("thead")
cal_table += thead
table += thead
trow = Html("tr") + (
Html('th', th_txt, class_ ='monthName', colspan=7, inline = True)
Html("th", th_txt, class_ ='monthName', colspan=7, inline = True)
)
thead += trow
@ -669,13 +671,13 @@ class WebCalReport(Report):
for day_col in range(7):
dayclass = get_class_for_daycol(day_col)
dayname = get_name_for_daycol(day_col)
trow += Html('th', class_ =dayclass, inline = True) + (
trow += Html("th", class_ =dayclass, inline = True) + (
Html('abbr', dayname[0], title=dayname)
)
# begin table body
tbody = Html("tbody")
cal_table += tbody
table += tbody
# get first of the month and month information
current_date, current_ord, monthinfo = get_first_day_of_month(year, month)
@ -706,22 +708,19 @@ class WebCalReport(Report):
if day == 0:
# day in previous month
if week_row == 0:
specday = __get_previous_month_day(year, month, day_col)
specclass = "previous " + dayclass
specday = __get_previous_month_day(year, month, day_col) if week_row == 0 \
else __get_next_month_day(year, month, day_col)
# a day in the next month
elif week_row == (nweeks-1):
specday = __get_next_month_day(year, month, day_col)
specclass = "next " + dayclass
specclass = "previous " if week_row == 0 else "Next "
specclass += dayclass
# continue table cell, <td>, without id tag
tcell = Html('td', class_ = specclass, inline = True) + (
tcell = Html("td", class_ = specclass, inline = True) + (
# adds date for previous and next month days
Html("div", specday, class_ = "date", inline = True)
)
trow += tcell
# normal day number in current month
else:
@ -733,8 +732,7 @@ class WebCalReport(Report):
bday_anniv_list = self.calendar.get(month, {}).get(thisday.day, [])
# date is an instance because of subtracting abilities in date.py
event_date = Date()
event_date.set_yr_mon_day(thisday.year, thisday.month, thisday.day)
event_date = Date(thisday.year, thisday.month, thisday.day)
# get events for this day
day_list = get_day_list(event_date, holiday_list, bday_anniv_list)
@ -743,7 +741,7 @@ class WebCalReport(Report):
if day_list:
hilightday = 'highlight ' + dayclass
tcell = Html('td', id = tcell_id, class_ = hilightday)
tcell = Html("td", id = tcell_id, class_ = hilightday)
# Year at a Glance
if cal == "yg":
@ -767,7 +765,7 @@ class WebCalReport(Report):
else:
# continue table cell, <td>, without id tag
tcell = Html('td', class_ = hilightday, inline = True) + (
tcell = Html("td", class_ = hilightday, inline = True) + (
# adds date division
Html("div", day, class_ = "date", inline = True)
@ -791,7 +789,7 @@ class WebCalReport(Report):
else:
# create empty day with date
tcell = Html('td', class_ = dayclass, inline = True) + (
tcell = Html("td", class_ = dayclass, inline = True) + (
# adds date division
Html("div", day, class_ = "date", inline = True)
@ -799,7 +797,7 @@ class WebCalReport(Report):
# nothing for this month
else:
tcell = Html('td', class_ = dayclass) + (
tcell = Html("td", class_ = dayclass) + (
# adds date division
Html("div", day, class_ = "date", inline = True)
@ -813,20 +811,17 @@ class WebCalReport(Report):
current_ord += 1
if cal == "yg":
# Fill up till we have 6 rows, so that the months align properly
for weeks in xrange(nweeks, 6):
six_weeks = Html("tr", class_ = "week%02d" % (weeks + 1))
# each calendar must have six weeks for proper styling and alignment
with Html("tr", class_ = "week%02d" % (weeks + 1)) as six_weeks:
tbody += six_weeks
for emptydays in xrange(6):
for emptydays in range(7):
six_weeks += Html("td", class_ = "emptyDays", inline = True)
# create table cell
for col in xrange(6):
six_weeks += Html("td", class_ = "EmptyDays", inline = True)
# return calendar table to its caller
return cal_table
# return calendar table to its callers
return table
# ---------------------------------------------------------------------------------------
# Creates the Web Calendars; the primary part of this plugin
@ -882,7 +877,7 @@ class WebCalReport(Report):
monthly_calendar += cal_foot
trow = Html("tr") + (
Html('td', note, colspan=7, inline = True)
Html("td", note, colspan=7, inline = True)
)
cal_foot += trow
@ -1190,10 +1185,10 @@ class WebCalReport(Report):
if event_obj.is_valid():
if self.link_to_narweb:
spouse_name = Html('a', spouse_name,
spouse_name = Html("a", spouse_name,
href=self.build_url_fname_html(spouse_handle, 'ppl',
prefix=self.narweb_prefix))
short_name = Html('a', short_name,
short_name = Html("a", short_name,
href=self.build_url_fname_html(person.handle, 'ppl',
prefix=self.narweb_prefix))
text = _('%(spouse)s and %(person)s') % {