Messages; fixes throughout

svn: r18333
This commit is contained in:
Doug Blank 2011-10-16 03:58:56 +00:00
parent 7b4b4136bf
commit 9e6bd3c4ba
4 changed files with 48 additions and 30 deletions

View File

@ -952,9 +952,9 @@ class SimpleAccess(object):
elif isinstance(obj, gen.lib.Place):
return place_name(self.dbase, obj.handle)
elif isinstance(obj, gen.lib.Repository):
return obj.type
return obj.gramps_id
elif isinstance(obj, gen.lib.Note):
return obj.type
return obj.gramps_id
elif obj is None:
return ""
else:

View File

@ -33,7 +33,6 @@
<li {{tview|currentSection:view.1 }}><a href="/{{view.1}}/">{{view.0}}</a></li>
{% endfor %}
{% if user.is_authenticated %}
<li><a href="/report">Reports</a></li>
{% if next %}
<li><a href="/logout/?next={{next}}">Logout</a></li>
{% else %}
@ -52,16 +51,13 @@
</ul>
{% endblock %}
</div>
<div class="content">
{% if error %}
<font color="red">{{error}}</font>
{% endif %}
{% if message %}
<font color="blue">{{message}}</font>
{% endif %}
<div class="grampsweb">
{% for message in messages %}
<font color="red">{{message}}</font>
{% endfor %}
{% block content %}
{% endblock %}
<div class="content">
</div>
</div>
<div id="footer">

View File

@ -91,7 +91,8 @@ class mGrampsType(models.Model):
name = models.CharField(max_length=40)
def __unicode__(self): return self.name
def __unicode__(self):
return str(self.name)
def get_default_type(self):
""" return a tuple default (val,name) """
@ -418,8 +419,9 @@ class PrimaryObject(models.Model):
#attributes = models.ManyToManyField("Attribute", blank=True, null=True)
cache = models.TextField(blank=True, null=True)
def __unicode__(self): return "%s: %s" % (self.__class__.__name__,
self.gramps_id)
def __unicode__(self):
return "%s: %s" % (self.__class__.__name__,
self.gramps_id)
class Person(PrimaryObject):
"""
@ -480,6 +482,11 @@ class Family(PrimaryObject):
# Others keys here:
# .lds_set
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 str("%s and %s" % (father, mother))
class Source(PrimaryObject):
title = models.CharField(max_length=50, blank=True)
author = models.CharField(max_length=50, blank=True)
@ -814,6 +821,9 @@ class Report(models.Model):
report_type = models.TextField(blank=True, null=True)
options = models.TextField(blank=True, null=True)
def __unicode__(self):
return str(self.name)
class Result(models.Model):
name = models.TextField(blank=True, null=True)
filename = models.TextField(blank=True, null=True)
@ -821,6 +831,9 @@ class Result(models.Model):
run_by = models.TextField('run by', blank=True, null=True)
status = models.TextField(blank=True, null=True)
def __unicode__(self):
return str(self.name)
TABLES = [
("abstract", mGrampsType),
("type", NameType),

View File

@ -62,6 +62,7 @@ VIEWS = [(_('People'), 'person', Name),
(_('Places'), 'place', Place),
(_('Repositories'), 'repository', Repository),
(_('Tags'), 'tag', Tag),
(_('Reports'), 'report', Report),
]
def context_processor(request):
@ -96,7 +97,7 @@ def logout_page(request):
logout(request)
# TODO: allow this once we have an error page
#if request.GET.has_key("next"):
# return redirect(request.GET.get("next"), context)
# return redirect(request.GET.get("next"))
return HttpResponseRedirect('/')
def user_page(request, username):
@ -132,7 +133,7 @@ def fix_person(request, person):
name.save()
order += 1
if request:
return redirect("/person/%s" % person.handle, request)
return redirect("/person/%s" % person.handle)
def set_date(obj):
obj.calendar = 0
@ -225,11 +226,9 @@ def view_name_detail(request, handle, order, action="view"):
view_template = "view_name_detail.html"
if action == "save":
context["action"] = "view"
return redirect("/person/%s/name/%d" %
(person.handle, name.order), context)
return redirect("/person/%s/name/%d" % (person.handle, name.order))
elif action == "back":
return redirect("/person/%s/" %
(person.handle), context)
return redirect("/person/%s/" % (person.handle))
else:
return render_to_response(view_template, context)
@ -280,23 +279,34 @@ def process_action(request, view, handle, action):
export_file(db, filename, lambda n: n) # callback
mimetype = 'text/plain'
elif report.report_type == "import":
context = RequestContext(request)
filename = download(args["i"], "/tmp/%s-%s.ged" % (str(profile.user.username), str(handle)))
if filename is not None:
import threading
def background():
import_file(db, filename, lambda n: n) # callback
try:
import_file(db, filename, lambda n: n) # callback
except:
message = "import_file failed."
request.user.message_set.create(message = message)
threading.Thread(target=background).start()
context["message"] = "Your data is now being imported..."
return redirect("/report/", context)
message = "Your data is now being imported..."
request.user.message_set.create(message = message)
return redirect("/report/")
else:
context["error"] = "No filename was provided or found."
return redirect("/report/", context)
message = "No filename was provided or found."
request.user.message_set.create(message = message)
return redirect("/report/")
else:
message = "Invalid report type '%s'" % report.report_type
request.user.message_set.create(message = message)
return redirect("/report/")
if os.path.exists(filename):
return send_file(request, filename, mimetype)
else:
context = RequestContext(request)
context["error"] = "Invalid report type '%s'" % report.report_type
return redirect("/report/", context)
return send_file(request, filename, mimetype)
message = "Failed: '%s' is not found" % filename
request.user.message_set.create(message=message)
return redirect("/report/")
# If failure, just fail for now:
context = RequestContext(request)
context["tview"] = "Results"
@ -462,8 +472,7 @@ def view_person_detail(request, view, handle, action="view"):
nf.model = name
# END NON-AUTHENTICATED ACCESS
if action == "save":
context["action"] = "view"
return redirect("/person/%s" % person.handle, context)
return redirect("/person/%s" % person.handle)
context["action"] = action
context["view"] = view
context["tview"] = _("Person")