diff --git a/src/data/Web_Mainz.css b/src/data/Web_Mainz.css index 355dfe2fc..e38cb9fdb 100644 --- a/src/data/Web_Mainz.css +++ b/src/data/Web_Mainz.css @@ -305,13 +305,30 @@ table tr th { padding:.1em 10px; border-bottom:double 4px #7D5925; } -table.infolist tr th a { - text-decoration:none; -} table tr td { vertical-align:middle; padding:.1em 10px; } +table tr td.TableHeaderCell { + color: #7D5925; + background-color: #f8eec9; + font-weight: bold; + text-align: left; + margin:0; + border-bottom:double 4px #7D5925; + border-left:solid 2px #7D5925; + border-right:solid 2px #7D5925; + border-top:solid 2px #7D5925; +} + +table tr td.TableDataCell { + color: #f8eec9; + border:solid 2px #7D5925; +} + +table.infolist tr th a { + text-decoration:none; +} table.infolist tr td a { display:block; text-decoration:none; diff --git a/src/data/javascript/css/swanky-purse/jquery-ui-1.7.2.custom.css b/src/data/javascript/css/swanky-purse/jquery-ui-1.7.2.custom.css index c0411a94a..e1ffb4b2b 100644 --- a/src/data/javascript/css/swanky-purse/jquery-ui-1.7.2.custom.css +++ b/src/data/javascript/css/swanky-purse/jquery-ui-1.7.2.custom.css @@ -48,7 +48,7 @@ /* Component containers ----------------------------------*/ -.ui-widget { } +.ui-widget { font-family:Georgia, serif; color:#7D5925; font-size: 0.7em; } .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { } .ui-widget-content { border: 1px solid #efec9f; background: #443113 url(images/ui-bg_diamond_8_443113_10x8.png) 50% 50% repeat; color: #efec9f; } .ui-widget-content a { color: #efec9f; background: none;} diff --git a/src/data/templates/view_person_detail.html b/src/data/templates/view_person_detail.html index 734e46866..449d9950a 100644 --- a/src/data/templates/view_person_detail.html +++ b/src/data/templates/view_person_detail.html @@ -10,33 +10,52 @@ }); - +
+

{{person.name_set|make_name:user}}

+
+
+ - + + + + - + + + + - + + + + - + + - + + - + + +
Family: {{person.name_set|preferred:"surname"}}Prefix:{{person.name_set|preferred:"prefix"}}Family{{person.name_set|preferred:"surname"}}Prefix{{person.name_set|preferred:"prefix"}}
Given: {{person.name_set|preferred:"first_name"}}Callname:{{person.name_set|preferred:"call"}}Given{{person.name_set|preferred:"first_name"}}Callname{{person.name_set|preferred:"call"}}
Type: {{person.name_set|preferred:"name_type"}}Patronymic:{{person.name_set|preferred:"patronymic"}}Type{{person.name_set|preferred:"name_type"}}Patronymic{{person.name_set|preferred:"patronymic"}}
Description:Description
ID:{{person.gramps_id|escape}}ID{{person.gramps_id|escape}}
Place:Place
+ +

Tabs

-
table 1
-
table 2
+
+ + {{ person|events_table|safe }} +
+
+ + + {% for name in person.name_set.all %} + + + + + {% endfor %} +
{{forloop.counter}}{{name|make_name:user}}
+
table 3
table 4
table 5
diff --git a/src/web/djangodb.py b/src/web/djangodb.py index a4f0edfd3..906e6270f 100644 --- a/src/web/djangodb.py +++ b/src/web/djangodb.py @@ -2,17 +2,12 @@ import web import gen from gen.db import GrampsDbBase from web.libdjango import DjangoInterface -import Utils # from ReportBase._CommandLineReport import run_report # import djangodb # db = djangodb.DjangoDb() # run_report(db, "ancestor_report", off="txt", of="ar.txt", pid="I37") -def probably_alive(handle): - db = DjangoDb() - return Utils.probably_alive(db.get_person_from_handle(handle), db) - class Cursor(object): def __init__(self, model, func): self.model = model @@ -114,6 +109,15 @@ class DjangoDb(GrampsDbBase): def get_person_cursor(self): return Cursor(self.dji.Person, self.dji.get_person) + def get_family_cursor(self): + return Cursor(self.dji.Family, self.dji.get_family) + + def get_events_cursor(self): + return Cursor(self.dji.Event, self.dji.get_event) + + def get_source_cursor(self): + return Cursor(self.dji.Source, self.dji.get_source) + def has_person_handle(self, handle): return self.dji.Person.filter(handle=handle).count() == 1 diff --git a/src/web/grampsdb/templatetags/my_tags.py b/src/web/grampsdb/templatetags/my_tags.py index c74ae98ca..19eebf7c8 100644 --- a/src/web/grampsdb/templatetags/my_tags.py +++ b/src/web/grampsdb/templatetags/my_tags.py @@ -1,54 +1,22 @@ from django.template import escape, Library -from web import libdjango -from web import djangodb -import web.grampsdb.models as models -from gen.lib.date import Date as GDate, Today -import DateHandler +from web.utils import * -dji = libdjango.DjangoInterface() register = Library() -_dd = DateHandler.displayer.display -_dp = DateHandler.parser.parse - -## FIXME: these dji function wrappers just use the functions -## written for the import/export. Can be done much more directly. - -def person_get_birth_date(person): - return person_get_event(person, models.EventType.BIRTH) -def person_get_death_date(person): - return person_get_event(person, models.EventType.DEATH) +events_table.is_safe = True +register.filter('events_table', events_table) person_get_birth_date.is_safe = True register.filter('person_get_birth_date', person_get_birth_date) + person_get_death_date.is_safe = True register.filter('person_get_death_date', person_get_death_date) -def display_date(obj): - date_tuple = dji.get_date(obj) - if date_tuple: - gdate = GDate() - gdate.unserialize(date_tuple) - return escape(_dd(gdate)) - else: - return "" display_date.is_safe = True register.filter('display_date', display_date) -def person_get_event(person, event_type): - event_ref_list = dji.get_event_ref_list(person) - index = libdjango.lookup_role_index(event_type, event_ref_list) - if index >= 0: - event_handle = event_ref_list[index][3] - # (False, [], [], u'b2cfa6cdec87392cf3b', (1, u'Primary')) - # WARNING: the same object can be referred to more than once - objs = models.EventRef.objects.filter(ref_object__handle=event_handle) - if objs.count() > 0: - return display_date(objs[0].ref_object) - else: - return "" - else: - return "" +person_get_event.is_safe = True +register.filter('person_get_events', person_get_event) def preview(text, width=40): text = text.replace("\n", " ") @@ -56,26 +24,6 @@ def preview(text, width=40): preview.is_safe = True register.filter('preview', preview) -def make_name(name, user): - if isinstance(name, models.Name): - surname = name.surname.strip() - if not surname: - surname = "[Missing]" - if user.is_authenticated(): - return escape("%s, %s" % (surname, name.first_name)) - else: - if djangodb.probably_alive(name.person.handle): - return escape("%s, %s" % (surname, "[Living]")) - else: - return escape("%s, %s" % (surname, name.first_name)) - elif name: - name = name.get(preferred=True) - if name: - return make_name(name, user) - else: - return "" - else: - return "" make_name.is_safe = True register.filter('make_name', make_name) diff --git a/src/web/utils.py b/src/web/utils.py new file mode 100644 index 000000000..d16a94e33 --- /dev/null +++ b/src/web/utils.py @@ -0,0 +1,149 @@ +import web.grampsdb.models as models +from web import libdjango +from web.djangodb import DjangoDb +from Simple import SimpleTable, SimpleAccess, make_basic_stylesheet +import Utils +import DbState +import DateHandler +from gen.lib.date import Date as GDate, Today +from gen.plug import BasePluginManager +from cli.grampscli import CLIManager +from django.template import escape + +dji = libdjango.DjangoInterface() + +_dd = DateHandler.displayer.display +_dp = DateHandler.parser.parse + +def register_plugins(): + dbstate = DbState.DbState() + climanager = CLIManager(dbstate, False) # don't load db + climanager.do_reg_plugins() + pmgr = BasePluginManager.get_instance() + return pmgr + +def probably_alive(handle): + db = DjangoDb() + return Utils.probably_alive(db.get_person_from_handle(handle), db) + +class Table(object): + """ + >>> table = Table() + >>> table.columns("Col1", "Col2", "Col3") + >>> table.row("1", "2", "3") + >>> table.row("4", "5", "6") + >>> table.get_html() + """ + def __init__(self): + self.db = DjangoDb() + self.access = SimpleAccess(self.db) + self.table = SimpleTable(self.access) + class Doc(object): + def __init__(self, doc): + self.doc = doc + # None is paperstyle, which is ignored: + self.doc = Doc(HtmlDoc.HtmlDoc(make_basic_stylesheet(), None)) + self.doc.doc._backend = HtmlBackend() + # You can set elements id, class, etc: + # self.doc.doc.htmllist += [Html('div', id="grampstextdoc")] + self.doc.doc.htmllist += [Html('div')] + + def columns(self, *args): + self.table.columns(*args) + + def row(self, *args): + self.table.row(*args) + + def get_html(self): + self.table.write(self.doc) # forces to htmllist + return str(self.doc.doc.htmllist[0]) + +_ = lambda text: text + +def events_table(djperson): + table = Table() + table.columns(_("Description"), + _("Type"), + _("ID"), + _("Date"), + _("Place"), + _("Role")) + person = table.db.get_person_from_handle(djperson.handle) + event_list = table.access.events(person) + for event in event_list: + djevent = dji.Event.get(handle=event.handle) + table.row( + djevent.description, + djevent.event_type.name, + djevent.gramps_id, + table.access.event_date_obj(event), + table.access.event_place(event), + "FIXME") + return table.get_html() + +## FIXME: these dji function wrappers just use the functions +## written for the import/export. Can be done much more directly. + +def person_get_birth_date(person): + return person_get_event(person, models.EventType.BIRTH) + +def person_get_death_date(person): + return person_get_event(person, models.EventType.DEATH) + +def display_date(obj): + date_tuple = dji.get_date(obj) + if date_tuple: + gdate = GDate() + gdate.unserialize(date_tuple) + return escape(_dd(gdate)) + else: + return "" + +def person_get_event(person, event_type=None): + event_ref_list = dji.get_event_ref_list(person) + if event_type: + index = libdjango.lookup_role_index(event_type, event_ref_list) + if index >= 0: + event_handle = event_ref_list[index][3] + # (False, [], [], u'b2cfa6cdec87392cf3b', (1, u'Primary')) + # WARNING: the same object can be referred to more than once + objs = models.EventRef.objects.filter(ref_object__handle=event_handle) + if objs.count() > 0: + return display_date(objs[0].ref_object) + else: + return "" + else: + return "" + else: + retval = [[obj.ref_object for obj in + models.EventRef.objects.filter(ref_object__handle=event_handle[3])] + for event_handle in event_ref_list] + return [j for i in retval for j in i] + +def make_name(name, user): + if isinstance(name, models.Name): + surname = name.surname.strip() + if not surname: + surname = "[Missing]" + if user.is_authenticated(): + return escape("%s, %s" % (surname, name.first_name)) + else: + if probably_alive(name.person.handle): + return escape("%s, %s" % (surname, "[Living]")) + else: + return escape("%s, %s" % (surname, name.first_name)) + elif name: + name = name.get(preferred=True) + if name: + return make_name(name, user) + else: + return "" + else: + return "" + +register_plugins() + +# works after registering plugins: +import HtmlDoc +from libhtmlbackend import HtmlBackend +from libhtml import Html