Webapp: use cuni for python3 compatibility
svn: r22989
This commit is contained in:
parent
653cb3882b
commit
8e8a2b7c6a
@ -36,6 +36,7 @@ from gramps.gen.lib.date import Date as GDate, Today
|
||||
from gramps.gen.utils.id import create_id, create_uid
|
||||
|
||||
from gramps.webapp.grampsdb.profile import Profile
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#
|
||||
@ -106,7 +107,7 @@ class mGrampsType(models.Model):
|
||||
name = models.CharField(max_length=40)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
return cuni(self.name)
|
||||
|
||||
def get_default_type(self):
|
||||
""" return a tuple default (val,name) """
|
||||
@ -178,10 +179,10 @@ class EventType(mGrampsType):
|
||||
val = models.IntegerField('event type', choices=_DATAMAP, blank=False)
|
||||
|
||||
def get_url(self):
|
||||
return u"/event/?search=type%%3D%s" % self.name
|
||||
return cuni("/event/?search=type%%3D%s") % self.name
|
||||
|
||||
def get_link(self):
|
||||
return u"<a href='%s'>%s</a>" % (self.get_url(), self.name)
|
||||
return cuni("<a href='%s'>%s</a>") % (self.get_url(), self.name)
|
||||
|
||||
|
||||
class FamilyRelType(mGrampsType):
|
||||
@ -403,7 +404,7 @@ class Config(models.Model):
|
||||
value = models.TextField('value')
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.setting)
|
||||
return cuni(self.setting)
|
||||
|
||||
class Tag(models.Model):
|
||||
handle = models.CharField(max_length=19, unique=True)
|
||||
@ -418,13 +419,13 @@ class Tag(models.Model):
|
||||
priority = models.IntegerField('priority', blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
return cuni(self.name)
|
||||
|
||||
def get_url(self):
|
||||
return u"/tag/%s" % self.handle
|
||||
return cuni("/tag/%s") % self.handle
|
||||
|
||||
def get_link(self):
|
||||
return u"<a href='%s'>%s</a>" % (self.get_url(), self.name)
|
||||
return cuni("<a href='%s'>%s</a>") % (self.get_url(), self.name)
|
||||
|
||||
# Just the following have tag lists:
|
||||
# ---------------------------------
|
||||
@ -454,11 +455,11 @@ class PrimaryObject(models.Model):
|
||||
cache = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s: %s" % (self.__class__.__name__,
|
||||
return cuni("%s: %s") % (self.__class__.__name__,
|
||||
self.gramps_id)
|
||||
|
||||
def get_url(self):
|
||||
return u"/%s/%s" % (self.__class__.__name__.lower(),
|
||||
return cuni("/%s/%s") % (self.__class__.__name__.lower(),
|
||||
self.handle)
|
||||
|
||||
class MyFamilies(models.Model):
|
||||
@ -510,7 +511,7 @@ class Person(PrimaryObject):
|
||||
return ""
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s [%s]" % (self.get_primary_name(), self.gramps_id)
|
||||
return cuni("%s [%s]") % (self.get_primary_name(), self.gramps_id)
|
||||
|
||||
def make_tag_list(self):
|
||||
return tuple()
|
||||
@ -546,7 +547,7 @@ class Family(PrimaryObject):
|
||||
def __unicode__(self):
|
||||
father = self.father.get_primary_name() if self.father else "No father"
|
||||
mother = self.mother.get_primary_name() if self.mother else "No mother"
|
||||
return u"%s and %s" % (father, mother)
|
||||
return cuni("%s and %s") % (father, mother)
|
||||
|
||||
class Citation(DateObject, PrimaryObject):
|
||||
confidence = models.IntegerField(blank=True, null=True)
|
||||
@ -557,7 +558,7 @@ class Citation(DateObject, PrimaryObject):
|
||||
object_id_field="object_id")
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] (%s, %s) to %s" % (self.gramps_id,
|
||||
return cuni("[%s] (%s, %s) to %s") % (self.gramps_id,
|
||||
self.confidence,
|
||||
self.page,
|
||||
self.source)
|
||||
@ -572,7 +573,7 @@ class Source(PrimaryObject):
|
||||
abbrev = models.CharField("Abbreviation", max_length=50, blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] %s" % (self.gramps_id,
|
||||
return cuni("[%s] %s") % (self.gramps_id,
|
||||
self.title)
|
||||
|
||||
# Other keys here:
|
||||
@ -587,7 +588,7 @@ class Event(DateObject, PrimaryObject):
|
||||
object_id_field="object_id")
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] (%s) %s" % (self.gramps_id,
|
||||
return cuni("[%s] (%s) %s") % (self.gramps_id,
|
||||
self.event_type,
|
||||
self.description)
|
||||
|
||||
@ -601,7 +602,7 @@ class Repository(PrimaryObject):
|
||||
#url_list = models.ManyToManyField('Url', null=True, blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"[%s] %s" % (self.gramps_id, self.name)
|
||||
return cuni("[%s] %s") % (self.gramps_id, self.name)
|
||||
|
||||
# Others keys here:
|
||||
# .address_set
|
||||
@ -615,10 +616,10 @@ class Place(PrimaryObject):
|
||||
#url_list = models.ManyToManyField('Url', null=True, blank=True)
|
||||
|
||||
def get_selection_string(self):
|
||||
return u"%s [%s]" % (self.title, self.gramps_id)
|
||||
return cuni("%s [%s]") % (self.title, self.gramps_id)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.title)
|
||||
return cuni(self.title)
|
||||
|
||||
# Others keys here:
|
||||
# .url_set
|
||||
@ -638,7 +639,7 @@ class Media(DateObject, PrimaryObject):
|
||||
return tuple()
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.desc)
|
||||
return cuni(self.desc)
|
||||
|
||||
class Note(PrimaryObject):
|
||||
note_type = models.ForeignKey('NoteType', verbose_name="Type")
|
||||
@ -653,7 +654,7 @@ class Note(PrimaryObject):
|
||||
return tuple()
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.gramps_id)
|
||||
return cuni(self.gramps_id)
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
#
|
||||
@ -691,11 +692,11 @@ class Surname(models.Model):
|
||||
order = models.PositiveIntegerField()
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.surname)
|
||||
return cuni(self.surname)
|
||||
|
||||
def get_url(self):
|
||||
# /person/handle/name/1/surname/2
|
||||
return u"/person/%s/name/%s/surname/%s" % (self.name.person.handle,
|
||||
return cuni("/person/%s/name/%s/surname/%s") % (self.name.person.handle,
|
||||
self.name.order,
|
||||
self.order)
|
||||
|
||||
@ -726,14 +727,14 @@ class Name(DateObject, SecondaryObject):
|
||||
surname = self.surname_set.get(primary=True)
|
||||
except:
|
||||
surname = "[No primary surname]"
|
||||
return u"%s, %s" % (surname, self.first_name)
|
||||
return cuni("%s, %s") % (surname, self.first_name)
|
||||
|
||||
def get_selection_string(self):
|
||||
try:
|
||||
surname = self.surname_set.get(primary=True)
|
||||
except:
|
||||
surname = "[No primary surname]"
|
||||
return u"%s, %s [%s]" % (surname, self.first_name, self.person.gramps_id)
|
||||
return cuni("%s, %s [%s]") % (surname, self.first_name, self.person.gramps_id)
|
||||
|
||||
@staticmethod
|
||||
def get_dummy():
|
||||
@ -757,7 +758,7 @@ class Name(DateObject, SecondaryObject):
|
||||
|
||||
def get_url(self):
|
||||
# /person/handle/name/1
|
||||
return u"/person/%s/name/%s" % (self.person.handle, self.order)
|
||||
return cuni("/person/%s/name/%s") % (self.person.handle, self.order)
|
||||
|
||||
class Lds(DateObject, SecondaryObject):
|
||||
"""
|
||||
@ -889,7 +890,7 @@ class BaseRef(models.Model):
|
||||
# /person/3536453463/reference/event/2
|
||||
ref_by = self.object_type.model_class().objects.get(id=self.object_id)
|
||||
ref_to = self.get_reference_to()
|
||||
return u"/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
|
||||
return cuni("/%s/%s/reference/%s/%s") % (ref_by.__class__.__name__.lower(),
|
||||
ref_by.handle,
|
||||
ref_to.__class__.__name__.lower(),
|
||||
self.order)
|
||||
@ -899,7 +900,7 @@ class Log(BaseRef):
|
||||
cache = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return u"%s: %s on %s by %s" % (self.log_type,
|
||||
return cuni("%s: %s on %s by %s") % (self.log_type,
|
||||
self.referenced_by,
|
||||
self.last_changed,
|
||||
self.last_changed_by)
|
||||
@ -911,14 +912,14 @@ class NoteRef(BaseRef):
|
||||
return self.ref_object
|
||||
|
||||
def __unicode__(self):
|
||||
return u"NoteRef to " + unicode(self.ref_object)
|
||||
return cuni("NoteRef to ") + cuni(self.ref_object)
|
||||
|
||||
class EventRef(BaseRef):
|
||||
ref_object = models.ForeignKey('Event')
|
||||
role_type = models.ForeignKey('EventRoleType')
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.ref_object)
|
||||
return cuni(self.ref_object)
|
||||
|
||||
def get_reference_to(self):
|
||||
return self.ref_object
|
||||
@ -927,7 +928,7 @@ class EventRef(BaseRef):
|
||||
# /person/3536453463/reference/event/2
|
||||
ref_by = self.object_type.model_class().objects.get(id=self.object_id)
|
||||
ref_to = self.ref_object
|
||||
return u"/%s/%s/reference/%s/%s" % (ref_by.__class__.__name__.lower(),
|
||||
return cuni("/%s/%s/reference/%s/%s") % (ref_by.__class__.__name__.lower(),
|
||||
ref_by.handle,
|
||||
ref_to.__class__.__name__.lower(),
|
||||
self.order)
|
||||
@ -941,7 +942,7 @@ class RepositoryRef(BaseRef):
|
||||
return self.ref_object
|
||||
|
||||
def __unicode__(self):
|
||||
return u"RepositoryRef to " + unicode(self.ref_object)
|
||||
return cuni("RepositoryRef to ") + cuni(self.ref_object)
|
||||
|
||||
class PersonRef(BaseRef):
|
||||
ref_object = models.ForeignKey('Person')
|
||||
@ -951,13 +952,13 @@ class PersonRef(BaseRef):
|
||||
return self.ref_object
|
||||
|
||||
def __unicode__(self):
|
||||
return u"PersonRef to " + unicode(self.ref_object)
|
||||
return cuni("PersonRef to ") + cuni(self.ref_object)
|
||||
|
||||
class CitationRef(BaseRef):
|
||||
citation = models.ForeignKey('Citation')
|
||||
|
||||
def __unicode__(self):
|
||||
return u"CitationRef to " + unicode(self.citation)
|
||||
return cuni("CitationRef to ") + cuni(self.citation)
|
||||
|
||||
def get_reference_to(self):
|
||||
return self.citation
|
||||
@ -974,10 +975,10 @@ class ChildRef(BaseRef):
|
||||
|
||||
def get_url(self):
|
||||
# FIXME: go to child reference
|
||||
return u"/person/%s" % self.ref_object.handle
|
||||
return cuni("/person/%s") % self.ref_object.handle
|
||||
|
||||
def __unicode__(self):
|
||||
return u"ChildRef to " + unicode(self.ref_object)
|
||||
return cuni("ChildRef to ") + cuni(self.ref_object)
|
||||
|
||||
class MediaRef(BaseRef):
|
||||
x1 = models.IntegerField()
|
||||
@ -990,7 +991,7 @@ class MediaRef(BaseRef):
|
||||
return self.ref_object
|
||||
|
||||
def __unicode__(self):
|
||||
return u"MediaRef to " + unicode(self.ref_object)
|
||||
return cuni("MediaRef to ") + cuni(self.ref_object)
|
||||
|
||||
class Report(models.Model):
|
||||
gramps_id = models.TextField(blank=True, null=True)
|
||||
@ -1000,7 +1001,7 @@ class Report(models.Model):
|
||||
options = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
return cuni(self.name)
|
||||
|
||||
class Result(models.Model):
|
||||
name = models.TextField(blank=True, null=True)
|
||||
@ -1010,7 +1011,7 @@ class Result(models.Model):
|
||||
status = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return unicode(self.name)
|
||||
return cuni(self.name)
|
||||
|
||||
TABLES = [
|
||||
("abstract", mGrampsType),
|
||||
|
@ -54,6 +54,7 @@ import gramps.webapp.grampsdb.models as models
|
||||
import gramps.webapp.grampsdb.forms as forms
|
||||
from gramps.webapp import libdjango
|
||||
from gramps.webapp.dbdjango import DbDjango
|
||||
from gramps.gen.constfunc import cuni
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -145,7 +146,7 @@ def get_person_from_handle(db, handle):
|
||||
print("error in get_person_from_handle:", file=sys.stderr)
|
||||
import sys, traceback
|
||||
cla, exc, trbk = sys.exc_info()
|
||||
print(_("Error") + (u" : %s %s" %(cla, exc)), file=sys.stderr)
|
||||
print(_("Error") + (cuni(" : %s %s") %(cla, exc)), file=sys.stderr)
|
||||
traceback.print_exc()
|
||||
return None
|
||||
|
||||
@ -250,18 +251,18 @@ class Table(object):
|
||||
self.table.set_link_col(links)
|
||||
|
||||
def get_html(self):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
# The HTML writer escapes data:
|
||||
self.table.write(self.doc, self.column_widths) # forces to htmllist
|
||||
# FIXME: do once, or once per table?
|
||||
self.doc.doc.build_style_declaration(self.id) # can pass id, for whole
|
||||
# FIXME: don't want to repeat this, unless diff for each table:
|
||||
retval += u"<style>%s</style>" % self.doc.doc.style_declaration
|
||||
retval += cuni("<style>%s</style>") % self.doc.doc.style_declaration
|
||||
# We have a couple of HTML bits that we want to unescape:
|
||||
return retval + unicode(self.doc.doc.htmllist[0]).replace("&nbsp;", " ")
|
||||
return retval + cuni(self.doc.doc.htmllist[0]).replace("&nbsp;", " ")
|
||||
|
||||
def build_args(**kwargs):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
first = True
|
||||
for key in kwargs:
|
||||
if kwargs[key] is not "":
|
||||
@ -270,7 +271,7 @@ def build_args(**kwargs):
|
||||
first = False
|
||||
else:
|
||||
retval += "&"
|
||||
retval += u"%s=%s" % (key, kwargs[key])
|
||||
retval += cuni("%s=%s") % (key, kwargs[key])
|
||||
return retval
|
||||
|
||||
def build_search(request):
|
||||
@ -280,8 +281,8 @@ def build_search(request):
|
||||
|
||||
def make_button(text, url, *args):
|
||||
newargs = []
|
||||
kwargs = u""
|
||||
last = u""
|
||||
kwargs = cuni("")
|
||||
last = cuni("")
|
||||
for arg in args:
|
||||
if isinstance(arg, STRTYPE) and arg.startswith("?"):
|
||||
kwargs = arg
|
||||
@ -296,7 +297,7 @@ def make_button(text, url, *args):
|
||||
if text[0] in "+$-?x" or text in ["x", "^", "v", "<", "<<", ">", ">>"]:
|
||||
return mark_safe(make_image_button(text, url, kwargs, last))
|
||||
else:
|
||||
return mark_safe(u"""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""" %
|
||||
return mark_safe(cuni("""<input type="button" value="%s" onclick="document.location.href='%s%s%s'"/>""") %
|
||||
(text, url, kwargs, last))
|
||||
|
||||
def make_image_button(text, url, kwargs, last):
|
||||
@ -369,10 +370,10 @@ def make_image_button2(button, text, url, kwargs="", last=""):
|
||||
filename = "/images/scalable/add-parent-existing-family.svg"
|
||||
elif button == "add spouse to new family":
|
||||
filename = "/images/scalable/gramps-parents.svg"
|
||||
return u"""<img height="22" width="22" alt="%s" title="%s" src="%s" onmouseover="buttonOver(this)" onmouseout="buttonOut(this)" onclick="document.location.href='%s%s%s'" style="background-color: lightgray; border: 1px solid lightgray; border-radius:5px; margin: 0px 1px; padding: 1px;" />""" % (text, text, filename, url, kwargs, last)
|
||||
return cuni("""<img height="22" width="22" alt="%s" title="%s" src="%s" onmouseover="buttonOver(this)" onmouseout="buttonOut(this)" onclick="document.location.href='%s%s%s'" style="background-color: lightgray; border: 1px solid lightgray; border-radius:5px; margin: 0px 1px; padding: 1px;" />""") % (text, text, filename, url, kwargs, last)
|
||||
|
||||
def event_table(obj, user, act, url, args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-events"
|
||||
table = Table("event_table")
|
||||
@ -400,18 +401,18 @@ def event_table(obj, user, act, url, args):
|
||||
djevent.gramps_id,
|
||||
display_date(djevent),
|
||||
get_title(djevent.place),
|
||||
unicode(event_ref.role_type))
|
||||
cuni(event_ref.role_type))
|
||||
links.append(('URL', event_ref.get_url()))
|
||||
has_data = True
|
||||
count += 1
|
||||
table.links(links)
|
||||
retval += u"""<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
|
||||
retval += cuni("""<div style="background-color: lightgray; padding: 2px 0px 0px 2px">""")
|
||||
if user.is_superuser and act == "view":
|
||||
retval += make_button(_("+Add New Event"), (url % args).replace("$act", "add"))
|
||||
retval += make_button(_("$Add Existing Event"), (url % args).replace("$act", "share"))
|
||||
else:
|
||||
retval += u"""<div style="height: 26px;"></div>""" # to keep tabs same height
|
||||
retval += u"""</div>"""
|
||||
retval += cuni("""<div style="height: 26px;"></div>""") # to keep tabs same height
|
||||
retval += cuni("""</div>""")
|
||||
retval += table.get_html()
|
||||
if user.is_superuser and act == "view":
|
||||
count = 1
|
||||
@ -419,16 +420,16 @@ def event_table(obj, user, act, url, args):
|
||||
retval = retval.replace("}}", """</div>""")
|
||||
for (djevent, event_ref) in event_list:
|
||||
item = obj.__class__.__name__.lower()
|
||||
retval = retval.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/eventref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/eventref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/eventref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[x%d]]" % count, make_button("x", cuni("/%s/%s/remove/eventref/%d") % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[^%d]]" % count, make_button("^", cuni("/%s/%s/up/eventref/%d") % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[v%d]]" % count, make_button("v", cuni("/%s/%s/down/eventref/%d") % (item, obj.handle, count)))
|
||||
count += 1
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def history_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-history"
|
||||
table = Table("history_table")
|
||||
@ -442,23 +443,23 @@ def history_table(obj, user, act):
|
||||
object_id=obj.id,
|
||||
object_type=obj_type):
|
||||
table.row(
|
||||
u"%s on %s by %s" % (entry.log_type,
|
||||
cuni("%s on %s by %s") % (entry.log_type,
|
||||
entry.last_changed,
|
||||
entry.last_changed_by),
|
||||
entry.reason)
|
||||
has_data = True
|
||||
table.row(
|
||||
u"Latest on %s by %s" % (obj.last_changed,
|
||||
cuni("Latest on %s by %s") % (obj.last_changed,
|
||||
obj.last_changed_by),
|
||||
"Current status")
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def name_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-names"
|
||||
table = Table("name_table")
|
||||
@ -475,20 +476,20 @@ def name_table(obj, user, act, url=None, *args):
|
||||
object_id=name.id).count() > 0
|
||||
note_refs = dji.NoteRef.filter(object_type=obj_type,
|
||||
object_id=name.id)
|
||||
note = u""
|
||||
note = cuni("")
|
||||
if note_refs.count() > 0:
|
||||
try:
|
||||
note = dji.Note.get(id=note_refs[0].object_id).text[:50]
|
||||
except:
|
||||
note = None
|
||||
table.row(make_name(name, user),
|
||||
unicode(name.name_type) + ["", " (preferred)"][int(name.preferred)],
|
||||
cuni(name.name_type) + ["", " (preferred)"][int(name.preferred)],
|
||||
name.group_as,
|
||||
["No", "Yes"][citationq],
|
||||
note)
|
||||
links.append(('URL',
|
||||
# url is "/person/%s/name"
|
||||
(url % name.person.handle) + (u"/%s" % name.order)))
|
||||
(url % name.person.handle) + (cuni("/%s") % name.order)))
|
||||
has_data = True
|
||||
table.links(links)
|
||||
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
|
||||
@ -499,13 +500,13 @@ def name_table(obj, user, act, url=None, *args):
|
||||
retval += """</div>"""
|
||||
retval += table.get_html()
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def surname_table(obj, user, act, url=None, *args):
|
||||
person_handle = args[0]
|
||||
order = args[1]
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-surnames"
|
||||
table = Table("surname_table")
|
||||
@ -523,19 +524,19 @@ def surname_table(obj, user, act, url=None, *args):
|
||||
name = None
|
||||
if name:
|
||||
for surname in name.surname_set.all().order_by("order"):
|
||||
table.row(unicode(surname.order), surname)
|
||||
table.row(cuni(surname.order), surname)
|
||||
has_data = True
|
||||
retval += table.get_html()
|
||||
else:
|
||||
retval += u"<p id='error'>No such name order = %s</p>" % order
|
||||
retval += cuni("<p id='error'>No such name order = %s</p>") % order
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def citation_table(obj, user, act, url=None, *args):
|
||||
# FIXME: how can citation_table and source_table both be on same
|
||||
# page? This causes problems with form names, tab names, etc.
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-sources"
|
||||
table = Table("citation_table")
|
||||
@ -556,8 +557,8 @@ def citation_table(obj, user, act, url=None, *args):
|
||||
citation_ref.citation.handle)
|
||||
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
|
||||
citation.gramps_id,
|
||||
unicode(citation.confidence),
|
||||
unicode(citation.page),
|
||||
cuni(citation.confidence),
|
||||
cuni(citation.page),
|
||||
)
|
||||
links.append(('URL', citation_ref.get_url()))
|
||||
has_data = True
|
||||
@ -577,16 +578,16 @@ def citation_table(obj, user, act, url=None, *args):
|
||||
count = 1
|
||||
for citation_ref in citation_refs:
|
||||
item = obj.__class__.__name__.lower()
|
||||
retval = retval.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/citationref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/citationref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/citationref/%d" % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[x%d]]" % count, make_button("x", cuni("/%s/%s/remove/citationref/%d") % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[^%d]]" % count, make_button("^", cuni("/%s/%s/up/citationref/%d") % (item, obj.handle, count)))
|
||||
retval = retval.replace("[[v%d]]" % count, make_button("v", cuni("/%s/%s/down/citationref/%d") % (item, obj.handle, count)))
|
||||
count += 1
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def repository_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-repositories"
|
||||
table = Table("repository_table")
|
||||
@ -617,7 +618,7 @@ def repository_table(obj, user, act, url=None, *args):
|
||||
repository.gramps_id,
|
||||
repository.name,
|
||||
repo_ref.call_number,
|
||||
unicode(repository.repository_type),
|
||||
cuni(repository.repository_type),
|
||||
)
|
||||
has_data = True
|
||||
count += 1
|
||||
@ -627,17 +628,17 @@ def repository_table(obj, user, act, url=None, *args):
|
||||
count = 1
|
||||
for repo_ref in refs:
|
||||
item = obj.__class__.__name__.lower()
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/repositoryref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/repositoryref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/repositoryref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", cuni("/%s/%s/remove/repositoryref/%d") % (item, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", cuni("/%s/%s/up/repositoryref/%d") % (item, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", cuni("/%s/%s/down/repositoryref/%d") % (item, obj.handle, count)))
|
||||
count += 1
|
||||
retval += text
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def note_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-notes"
|
||||
table = Table("note_table")
|
||||
@ -657,7 +658,7 @@ def note_table(obj, user, act, url=None, *args):
|
||||
note = note_ref.ref_object
|
||||
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser else "",
|
||||
note.gramps_id,
|
||||
unicode(note.note_type),
|
||||
cuni(note.note_type),
|
||||
note.text[:50]
|
||||
)
|
||||
links.append(('URL', note_ref.get_url()))
|
||||
@ -678,17 +679,17 @@ def note_table(obj, user, act, url=None, *args):
|
||||
count = 1
|
||||
for note_ref in note_refs:
|
||||
item = obj.__class__.__name__.lower()
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/noteref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/noteref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/noteref/%d" % (item, obj.handle, count)))
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", cuni("/%s/%s/remove/noteref/%d") % (item, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", cuni("/%s/%s/up/noteref/%d") % (item, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", cuni("/%s/%s/down/noteref/%d") % (item, obj.handle, count)))
|
||||
count += 1
|
||||
retval += text
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def data_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-data"
|
||||
table = Table("data_table")
|
||||
@ -729,9 +730,9 @@ def data_table(obj, user, act, url=None, *args):
|
||||
text = text.replace("}}", """</div>""")
|
||||
count = 1
|
||||
for repo_ref in refs:
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", u"/%s/%s/remove/attribute/%d" % (item_class, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", u"/%s/%s/up/attribute/%d" % (item_class, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", u"/%s/%s/down/attribute/%d" % (item_class, obj.handle, count)))
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", cuni("/%s/%s/remove/attribute/%d") % (item_class, obj.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", cuni("/%s/%s/up/attribute/%d") % (item_class, obj.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", cuni("/%s/%s/down/attribute/%d") % (item_class, obj.handle, count)))
|
||||
count += 1
|
||||
retval += text
|
||||
if has_data:
|
||||
@ -739,7 +740,7 @@ def data_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def attribute_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-attributes"
|
||||
table = Table("attribute_table")
|
||||
@ -766,7 +767,7 @@ def attribute_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def address_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-addresses"
|
||||
table = Table("address_table")
|
||||
@ -797,7 +798,7 @@ def address_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def media_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-media"
|
||||
table = Table("media_table")
|
||||
@ -813,7 +814,7 @@ def media_table(obj, user, act, url=None, *args):
|
||||
media = table.db.get_object_from_handle(
|
||||
media_ref.ref_object.handle)
|
||||
table.row(table.db.get_object_from_handle(media.handle),
|
||||
unicode(media_ref.ref_object.desc),
|
||||
cuni(media_ref.ref_object.desc),
|
||||
media_ref.ref_object.path)
|
||||
has_data = True
|
||||
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
|
||||
@ -829,7 +830,7 @@ def media_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def internet_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-internet"
|
||||
table = Table("internet_table")
|
||||
@ -839,13 +840,13 @@ def internet_table(obj, user, act, url=None, *args):
|
||||
if user.is_authenticated() or obj.public:
|
||||
urls = dji.Url.filter(person=obj)
|
||||
for url_obj in urls:
|
||||
table.row(unicode(url_obj.url_type),
|
||||
table.row(cuni(url_obj.url_type),
|
||||
url_obj.path,
|
||||
url_obj.desc)
|
||||
has_data = True
|
||||
retval += """<div style="background-color: lightgray; padding: 2px 0px 0px 2px">"""
|
||||
if user.is_superuser and url and act == "view":
|
||||
retval += make_button(_("+Add Internet"), (unicode(url) % args))
|
||||
retval += make_button(_("+Add Internet"), (cuni(url) % args))
|
||||
else:
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
retval += """</div>"""
|
||||
@ -855,7 +856,7 @@ def internet_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def association_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-associations"
|
||||
table = Table("association_table")
|
||||
@ -899,7 +900,7 @@ def association_table(obj, user, act, url=None, *args):
|
||||
|
||||
def location_table(obj, user, act, url=None, *args):
|
||||
# obj is Place or Address
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-alternatelocations"
|
||||
table = Table("location_table")
|
||||
@ -933,7 +934,7 @@ def location_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def lds_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-lds"
|
||||
table = Table("lds_table")
|
||||
@ -946,9 +947,9 @@ def lds_table(obj, user, act, url=None, *args):
|
||||
obj_type = ContentType.objects.get_for_model(obj)
|
||||
ldss = obj.lds_set.all().order_by("order")
|
||||
for lds in ldss:
|
||||
table.row(unicode(lds.lds_type),
|
||||
table.row(cuni(lds.lds_type),
|
||||
display_date(lds),
|
||||
unicode(lds.status),
|
||||
cuni(lds.status),
|
||||
lds.temple,
|
||||
get_title(lds.place))
|
||||
has_data = True
|
||||
@ -964,11 +965,11 @@ def lds_table(obj, user, act, url=None, *args):
|
||||
return retval
|
||||
|
||||
def person_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
text1 = u""
|
||||
text2 = u""
|
||||
text1 = cuni("")
|
||||
text2 = cuni("")
|
||||
table1 = Table("person_reference_table", style="background-color: #f4f0ec;")
|
||||
table1.columns(
|
||||
"As Spouse",
|
||||
@ -1044,11 +1045,11 @@ def person_reference_table(obj, user, act):
|
||||
retval += """<div style="overflow: auto; height:%spx;">""" % TAB_HEIGHT
|
||||
retval += text1 + text2 + "</div>"
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def note_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("note_reference_table")
|
||||
@ -1072,7 +1073,7 @@ def note_reference_table(obj, user, act):
|
||||
return retval
|
||||
|
||||
def event_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("event_reference_table")
|
||||
@ -1096,11 +1097,11 @@ def event_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def repository_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("repository_reference_table")
|
||||
@ -1120,11 +1121,11 @@ def repository_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def citation_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("citation_reference_table")
|
||||
@ -1144,11 +1145,11 @@ def citation_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def source_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("source_reference_table")
|
||||
@ -1166,11 +1167,11 @@ def source_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def media_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("media_reference_table")
|
||||
@ -1190,11 +1191,11 @@ def media_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def place_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("place_reference_table")
|
||||
@ -1213,11 +1214,11 @@ def place_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
def tag_reference_table(obj, user, act):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-references"
|
||||
table = Table("tag_reference_table")
|
||||
@ -1237,7 +1238,7 @@ def tag_reference_table(obj, user, act):
|
||||
retval += table.get_html()
|
||||
retval += nbsp("") # to keep tabs same height
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
class Link(object):
|
||||
@ -1250,7 +1251,7 @@ class Link(object):
|
||||
return self.string
|
||||
|
||||
def children_table(obj, user, act, url=None, *args):
|
||||
retval = u""
|
||||
retval = cuni("")
|
||||
has_data = False
|
||||
cssid = "tab-children"
|
||||
table = Table("children_table")
|
||||
@ -1276,8 +1277,8 @@ def children_table(obj, user, act, url=None, *args):
|
||||
child = childref.ref_object
|
||||
if user.is_authenticated() or obj.public:
|
||||
table.row(Link("{{[[x%d]][[^%d]][[v%d]]}}" % (count, count, count)) if user.is_superuser and url and act == "view" else "",
|
||||
unicode(count),
|
||||
u"[%s]" % child.gramps_id,
|
||||
cuni(count),
|
||||
cuni("[%s]") % child.gramps_id,
|
||||
render_name(child, user),
|
||||
child.gender_type,
|
||||
childref.father_rel_type,
|
||||
@ -1289,8 +1290,8 @@ def children_table(obj, user, act, url=None, *args):
|
||||
count += 1
|
||||
else:
|
||||
table.row("",
|
||||
unicode(count),
|
||||
u"[%s]" % child.gramps_id,
|
||||
cuni(count),
|
||||
cuni("[%s]") % child.gramps_id,
|
||||
render_name(child, user) if not child.private else "[Private]",
|
||||
child.gender_type if not child.private else "[Private]",
|
||||
"[Private]",
|
||||
@ -1311,9 +1312,9 @@ def children_table(obj, user, act, url=None, *args):
|
||||
text = text.replace("}}", """</div>""")
|
||||
count = 1
|
||||
for childref in childrefs:
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", u"/family/%s/remove/child/%d" % (family.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", u"/family/%s/up/child/%d" % (family.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", u"/family/%s/down/child/%d" % (family.handle, count)))
|
||||
text = text.replace("[[x%d]]" % count, make_button("x", cuni("/family/%s/remove/child/%d") % (family.handle, count)))
|
||||
text = text.replace("[[^%d]]" % count, make_button("^", cuni("/family/%s/up/child/%d") % (family.handle, count)))
|
||||
text = text.replace("[[v%d]]" % count, make_button("v", cuni("/family/%s/down/child/%d") % (family.handle, count)))
|
||||
count += 1
|
||||
retval += make_button(_("+Add New Person as Child"), (url.replace("$act", "add") % args))
|
||||
retval += make_button(_("$Add Existing Person as Child"), (url.replace("$act", "share") % args))
|
||||
@ -1322,7 +1323,7 @@ def children_table(obj, user, act, url=None, *args):
|
||||
retval += """</div>"""
|
||||
retval += text
|
||||
if has_data:
|
||||
retval += u""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""" % cssid
|
||||
retval += cuni(""" <SCRIPT LANGUAGE="JavaScript">setHasData("%s", 1)</SCRIPT>\n""") % cssid
|
||||
return retval
|
||||
|
||||
## FIXME: these dji function wrappers just use the functions
|
||||
@ -1344,9 +1345,9 @@ def display_date(obj):
|
||||
return ""
|
||||
|
||||
def media_link(handle, user, act):
|
||||
retval = u"""<a href="%s"><img src="%s" /></a>""" % (
|
||||
u"/media/%s/full" % handle,
|
||||
u"/media/%s/thumbnail" % handle)
|
||||
retval = cuni("""<a href="%s"><img src="%s" /></a>""") % (
|
||||
cuni("/media/%s/full") % handle,
|
||||
cuni("/media/%s/thumbnail") % handle)
|
||||
return retval
|
||||
|
||||
def render(formfield, user, act, id=None, url=None, *args):
|
||||
@ -1357,14 +1358,14 @@ def render(formfield, user, act, id=None, url=None, *args):
|
||||
try:
|
||||
item = getattr(formfield.form.model, fieldname)
|
||||
if (item.__class__.__name__ == 'ManyRelatedManager'):
|
||||
retval = u", ".join([i.get_link() for i in item.all()])
|
||||
retval = cuni(", ").join([i.get_link() for i in item.all()])
|
||||
else:
|
||||
if url:
|
||||
retval = u"""<a href="%s">%s</a>""" % (url % args, item)
|
||||
retval = cuni("""<a href="%s">%s</a>""") % (url % args, item)
|
||||
elif hasattr(item, "get_link"):
|
||||
retval = item.get_link()
|
||||
else:
|
||||
retval = unicode(item)
|
||||
retval = cuni(item)
|
||||
#### Some cleanup:
|
||||
if fieldname == "private": # obj.private
|
||||
if retval == "True":
|
||||
@ -1379,7 +1380,7 @@ def render(formfield, user, act, id=None, url=None, *args):
|
||||
except:
|
||||
# name, "prefix"
|
||||
try:
|
||||
retval = unicode(formfield.form.data[fieldname])
|
||||
retval = cuni(formfield.form.data[fieldname])
|
||||
except:
|
||||
retval = "[None]"
|
||||
else: # show as widget
|
||||
@ -1405,7 +1406,7 @@ def render_name(name, user, act=None):
|
||||
surname = name.surname_set.get(primary=True)
|
||||
except:
|
||||
surname = "[No primary surname]"
|
||||
return u"%s, %s" % (surname, name.first_name)
|
||||
return cuni("%s, %s") % (surname, name.first_name)
|
||||
elif isinstance(name, forms.NameForm):
|
||||
if not user.is_authenticated():
|
||||
name.model.sanitize()
|
||||
@ -1413,7 +1414,7 @@ def render_name(name, user, act=None):
|
||||
surname = name.model.surname_set.get(primary=True)
|
||||
except:
|
||||
surname = "[No primary surname]"
|
||||
return u"%s, %s" % (surname,
|
||||
return cuni("%s, %s") % (surname,
|
||||
name.model.first_name)
|
||||
elif isinstance(name, Person): # name is a Person
|
||||
person = name
|
||||
@ -1429,7 +1430,7 @@ def render_name(name, user, act=None):
|
||||
surname = name.surname_set.get(primary=True)
|
||||
except:
|
||||
surname = "[No primary surname]"
|
||||
return u"%s, %s" % (surname, name.first_name)
|
||||
return cuni("%s, %s") % (surname, name.first_name)
|
||||
elif isinstance(name, models.Person): # django person
|
||||
person = name
|
||||
try:
|
||||
@ -1464,7 +1465,7 @@ def person_get_event(person, event_type=None):
|
||||
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'))
|
||||
# (False, [], [], cuni('b2cfa6cdec87392cf3b'), (1, cuni('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:
|
||||
@ -1524,7 +1525,7 @@ class StyledNoteFormatter(object):
|
||||
return self.styled_note(note.get_styledtext())
|
||||
|
||||
def styled_note(self, styledtext):
|
||||
text = unicode(styledtext)
|
||||
text = cuni(styledtext)
|
||||
if not text:
|
||||
return ''
|
||||
s_tags = styledtext.get_tags()
|
||||
@ -1541,13 +1542,13 @@ class StyledNoteFormatter(object):
|
||||
if obj:
|
||||
handle = obj.handle
|
||||
else:
|
||||
raise AttributeError("gramps_id '%s' not found in '%s'" %
|
||||
handle, obj_class)
|
||||
raise AttributeError(cuni("gramps_id '%s' not found in '%s'") %
|
||||
(handle, obj_class))
|
||||
else:
|
||||
raise AttributeError(u"invalid gramps_id lookup "
|
||||
u"in table name '%s'" % obj_class)
|
||||
raise AttributeError(cuni("invalid gramps_id lookup ") +
|
||||
cuni("in table name '%s'") % obj_class)
|
||||
# handle, ppl
|
||||
return u"/%s/%s" % (obj_class.lower(), handle)
|
||||
return cuni("/%s/%s") % (obj_class.lower(), handle)
|
||||
|
||||
class WebAppParser(HTMLParser):
|
||||
BOLD = 0
|
||||
@ -1657,7 +1658,7 @@ class WebAppParser(HTMLParser):
|
||||
href = attrs["href"]
|
||||
if href.startswith("/"):
|
||||
parts = href.split("/")
|
||||
arg = u"gramps://%s/handle/%s" % (parts[-2].title(), parts[-1])
|
||||
arg = cuni("gramps://%s/handle/%s") % (parts[-2].title(), parts[-1])
|
||||
else:
|
||||
arg = href
|
||||
else:
|
||||
@ -1673,7 +1674,7 @@ class WebAppParser(HTMLParser):
|
||||
self.__tags[key].append((start_pos, len(self.__text)))
|
||||
|
||||
def tags(self):
|
||||
# [((code, u''), string/num, [(start, stop), ...]), ...]
|
||||
# [((code, cuni('')), string/num, [(start, stop), ...]), ...]
|
||||
return [(key[0], key[1], self.__tags[key]) for key in self.__tags]
|
||||
|
||||
def text(self):
|
||||
|
Loading…
Reference in New Issue
Block a user