Breadcrumbs on all pages; refactor menus and views
svn: r18334
This commit is contained in:
@@ -29,8 +29,27 @@
|
|||||||
{% block navigation %}
|
{% block navigation %}
|
||||||
<ul>
|
<ul>
|
||||||
<li {{ tview|currentSection:"home" }}><a href="/">Home</a></li>
|
<li {{ tview|currentSection:"home" }}><a href="/">Home</a></li>
|
||||||
{% for view in views %}
|
{% for title in menu %}
|
||||||
<li {{tview|currentSection:view.1 }}><a href="/{{view.1}}/">{{view.0}}</a></li>
|
{# (<Nice name>, /<path>/, <Model> | None, Need authentication ) #}
|
||||||
|
{% if title.3 %}
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<li {{tview|currentSection:title.1 }}>
|
||||||
|
{% if title.1 %}
|
||||||
|
<a href="/{{title.1}}/">{{title.0}}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<a href="/">{{title.0}}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
{# don't show #}
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<li {{tview|currentSection:title.1 }}>
|
||||||
|
{% if title.1 %}
|
||||||
|
<a href="/{{title.1}}/">{{title.0}}</a></li>
|
||||||
|
{% else %}
|
||||||
|
<a href="/">{{title.0}}</a></li>
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if user.is_authenticated %}
|
{% if user.is_authenticated %}
|
||||||
{% if next %}
|
{% if next %}
|
||||||
|
@@ -26,8 +26,10 @@ Database information:</p>
|
|||||||
</tr>
|
</tr>
|
||||||
{% for view in views %}
|
{% for view in views %}
|
||||||
<tr class="{% cycle odd,even %}">
|
<tr class="{% cycle odd,even %}">
|
||||||
|
{% if view.2 %}
|
||||||
<td align="left"><a href="/{{view.1}}">{{view.0}}</a></td>
|
<td align="left"><a href="/{{view.1}}">{{view.0}}</a></td>
|
||||||
<td align="right"><a href="/{{view.1}}">{{view.2.objects.count|format_number}}</td>
|
<td align="left"><a href="/{{view.1}}">{{view.2.objects.count|format_number}}</td>
|
||||||
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
{{ "/browse|Browse,/event|Events"|breadcrumb}}
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
<table class="infolist">
|
<table class="infolist">
|
||||||
<trbody>
|
<trbody>
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
{{ "/browse|Browse,/family|Families"|breadcrumb}}
|
||||||
|
|
||||||
<h3>{{family.father|make_name:user}} and {{family.mother|make_name:user}}</h3>
|
<h3>{{family.father|make_name:user}} and {{family.mother|make_name:user}}</h3>
|
||||||
|
|
||||||
|
@@ -10,6 +10,8 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/media|Media"|breadcrumb}}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Event type:</td><td> {{event.event_type|escape}}</td><td>Date:</td><td></td>
|
<td>Event type:</td><td> {{event.event_type|escape}}</td><td>Date:</td><td></td>
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/person|People,/person/{0}|Person"|breadcrumb:person.handle}}
|
||||||
|
|
||||||
<h3>{{person|make_name:user}} [{{person.gramps_id}}]</h3>
|
<h3>{{person|make_name:user}} [{{person.gramps_id}}]</h3>
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
<table class="infolist"> {% comment %} 4 cols {% endcomment %}
|
<table class="infolist"> {% comment %} 4 cols {% endcomment %}
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/note|Notes"|breadcrumb}}
|
||||||
|
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
<table class="infolist">
|
<table class="infolist">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
<div id="description" style="padding: 10pt 10pt 10pt 10pt;">
|
<div id="description" style="padding: 10pt 10pt 10pt 10pt;">
|
||||||
<form name="SearchForm">
|
<form name="SearchForm">
|
||||||
|
{% if tview != "Report" %}
|
||||||
|
{{ "/browse|Browse"|breadcrumb}}
|
||||||
|
{% endif %}
|
||||||
<input type="submit" value="Search:"></input>
|
<input type="submit" value="Search:"></input>
|
||||||
<input autocomplete="off" name="search" id="get_focus" type="text" size="50" value="{{search}}"></input>
|
<input autocomplete="off" name="search" id="get_focus" type="text" size="50" value="{{search}}"></input>
|
||||||
</form>
|
</form>
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/person|People"|breadcrumb}}
|
||||||
|
|
||||||
<h3>{{nameform|render_name:user}} [{{person.gramps_id}}]</h3>
|
<h3>{{nameform|render_name:user}} [{{person.gramps_id}}]</h3>
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
<table class="infolist"> {% comment %} 5 cols {% endcomment %}
|
<table class="infolist"> {% comment %} 5 cols {% endcomment %}
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/place|Places"|breadcrumb}}
|
||||||
|
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
|
|
||||||
<table class="infolist">
|
<table class="infolist">
|
||||||
|
@@ -4,6 +4,9 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/report|Reports"|breadcrumb}}
|
||||||
|
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
|
|
||||||
<form name="RunForm" action="/report/{{report.handle}}/run">
|
<form name="RunForm" action="/report/{{report.handle}}/run">
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/repository|Repositories"|breadcrumb}}
|
||||||
|
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
|
|
||||||
<table class="infolist">
|
<table class="infolist">
|
||||||
|
@@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/source|Sources"|breadcrumb}}
|
||||||
|
|
||||||
<h3>{{source.title|escape}}</h3>
|
<h3>{{source.title|escape}}</h3>
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
<table class="infolist"> {% comment %} 2 cols {% endcomment %}
|
<table class="infolist"> {% comment %} 2 cols {% endcomment %}
|
||||||
|
@@ -11,6 +11,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="content" id="IndividualDetail">
|
<div class="content" id="IndividualDetail">
|
||||||
|
|
||||||
|
{{ "/browse|Browse,/tag|Tags"|breadcrumb}}
|
||||||
|
|
||||||
<div id="summaryarea">
|
<div id="summaryarea">
|
||||||
|
|
||||||
<table class="infolist">
|
<table class="infolist">
|
||||||
|
@@ -4,6 +4,7 @@ from django import template
|
|||||||
from django.template import escape, Library
|
from django.template import escape, Library
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from webapp.utils import *
|
from webapp.utils import *
|
||||||
|
from webapp.grampsdb.views import VIEWS
|
||||||
import webapp.utils
|
import webapp.utils
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
@@ -104,8 +105,29 @@ def missing(data):
|
|||||||
missing.is_safe = True
|
missing.is_safe = True
|
||||||
register.filter('missing', missing)
|
register.filter('missing', missing)
|
||||||
|
|
||||||
def currentSection(view1, view2):
|
def getViewName(item):
|
||||||
if view1.strip().lower() == view2.strip().lower():
|
for view in VIEWS:
|
||||||
|
if view[1] == item:
|
||||||
|
return view[0]
|
||||||
|
if item == "name":
|
||||||
|
return "Names"
|
||||||
|
return "Unknown View"
|
||||||
|
|
||||||
|
def breadcrumb(path, arg=None):
|
||||||
|
if arg:
|
||||||
|
path = path.replace("{0}", arg)
|
||||||
|
retval = ""
|
||||||
|
for item in path.split(","):
|
||||||
|
p, name = item.split("|")
|
||||||
|
retval += '<a href="%s">%s</a> > ' % (p, name)
|
||||||
|
return "<p>%s</p>" % retval
|
||||||
|
breadcrumb.is_safe = True
|
||||||
|
register.filter('breadcrumb', breadcrumb)
|
||||||
|
|
||||||
|
def currentSection(view1, view2): # tview, menu
|
||||||
|
if view1.strip().lower() in [view[1] for view in VIEWS] and view2 == "browse":
|
||||||
|
return "class=CurrentSection"
|
||||||
|
elif view1.strip().lower() == view2.strip().lower():
|
||||||
return "class=CurrentSection"
|
return "class=CurrentSection"
|
||||||
return ""
|
return ""
|
||||||
currentSection.is_safe = True
|
currentSection.is_safe = True
|
||||||
|
@@ -52,8 +52,15 @@ import const
|
|||||||
|
|
||||||
_ = lambda text: text
|
_ = lambda text: text
|
||||||
|
|
||||||
|
# Menu: (<Nice name>, /<path>/, <Model> | None, Need authentication )
|
||||||
|
MENU = [
|
||||||
|
(_('Browse'), 'browse', None, False),
|
||||||
|
(_('Reports'), 'report', Report, True),
|
||||||
|
(_('User'), 'user', None, True),
|
||||||
|
]
|
||||||
# Views: [(<Nice name plural>, /<name>/handle, <Model>), ]
|
# Views: [(<Nice name plural>, /<name>/handle, <Model>), ]
|
||||||
VIEWS = [(_('People'), 'person', Name),
|
VIEWS = [
|
||||||
|
(_('People'), 'person', Name),
|
||||||
(_('Families'), 'family', Family),
|
(_('Families'), 'family', Family),
|
||||||
(_('Events'), 'event', Event),
|
(_('Events'), 'event', Event),
|
||||||
(_('Notes'), 'note', Note),
|
(_('Notes'), 'note', Note),
|
||||||
@@ -62,7 +69,6 @@ VIEWS = [(_('People'), 'person', Name),
|
|||||||
(_('Places'), 'place', Place),
|
(_('Places'), 'place', Place),
|
||||||
(_('Repositories'), 'repository', Repository),
|
(_('Repositories'), 'repository', Repository),
|
||||||
(_('Tags'), 'tag', Tag),
|
(_('Tags'), 'tag', Tag),
|
||||||
(_('Reports'), 'report', Report),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def context_processor(request):
|
def context_processor(request):
|
||||||
@@ -79,6 +85,7 @@ def context_processor(request):
|
|||||||
# Other things for all environments:
|
# Other things for all environments:
|
||||||
context["gramps_version"] = const.VERSION
|
context["gramps_version"] = const.VERSION
|
||||||
context["views"] = VIEWS
|
context["views"] = VIEWS
|
||||||
|
context["menu"] = MENU
|
||||||
context["True"] = True
|
context["True"] = True
|
||||||
context["False"] = False
|
context["False"] = False
|
||||||
context["default"] = ""
|
context["default"] = ""
|
||||||
@@ -100,7 +107,17 @@ def logout_page(request):
|
|||||||
# return redirect(request.GET.get("next"))
|
# return redirect(request.GET.get("next"))
|
||||||
return HttpResponseRedirect('/')
|
return HttpResponseRedirect('/')
|
||||||
|
|
||||||
def user_page(request, username):
|
def browse_page(request):
|
||||||
|
context = RequestContext(request)
|
||||||
|
context["view"] = 'browse'
|
||||||
|
context["tview"] = _('Browse')
|
||||||
|
return render_to_response('browse_page.html', context)
|
||||||
|
|
||||||
|
def user_page(request, username=None):
|
||||||
|
if request.user.is_authenticated():
|
||||||
|
if username is None:
|
||||||
|
profile = request.user.get_profile()
|
||||||
|
username = profile.user.username
|
||||||
try:
|
try:
|
||||||
user = User.objects.get(username=username)
|
user = User.objects.get(username=username)
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
@@ -110,6 +127,8 @@ def user_page(request, username):
|
|||||||
context["view"] = 'user'
|
context["view"] = 'user'
|
||||||
context["tview"] = _('User')
|
context["tview"] = _('User')
|
||||||
return render_to_response('user_page.html', context)
|
return render_to_response('user_page.html', context)
|
||||||
|
else:
|
||||||
|
raise Http404(_("Requested page is not accessible."))
|
||||||
|
|
||||||
def fix_person(request, person):
|
def fix_person(request, person):
|
||||||
try:
|
try:
|
||||||
@@ -255,7 +274,7 @@ def process_action(request, view, handle, action):
|
|||||||
profile = request.user.get_profile()
|
profile = request.user.get_profile()
|
||||||
report = Report.objects.get(handle=handle)
|
report = Report.objects.get(handle=handle)
|
||||||
if action == "run":
|
if action == "run":
|
||||||
args = {"off": "pdf"} # basic defaults
|
args = {"off": "pdf", "iff": "ged"} # basic defaults
|
||||||
# override from given defaults in table:
|
# override from given defaults in table:
|
||||||
if report.options:
|
if report.options:
|
||||||
for pair in str(report.options).split(" "):
|
for pair in str(report.options).split(" "):
|
||||||
@@ -266,7 +285,7 @@ def process_action(request, view, handle, action):
|
|||||||
if request.GET.has_key("options"):
|
if request.GET.has_key("options"):
|
||||||
options = str(request.GET.get("options"))
|
options = str(request.GET.get("options"))
|
||||||
if options:
|
if options:
|
||||||
for pair in options.split("%3D"): # from webpage
|
for pair in options.split(" "): # from webpage
|
||||||
if "=" in pair:
|
if "=" in pair:
|
||||||
key, value = pair.split("=", 1)
|
key, value = pair.split("=", 1)
|
||||||
args[key] = value
|
args[key] = value
|
||||||
@@ -279,7 +298,9 @@ def process_action(request, view, handle, action):
|
|||||||
export_file(db, filename, lambda n: n) # callback
|
export_file(db, filename, lambda n: n) # callback
|
||||||
mimetype = 'text/plain'
|
mimetype = 'text/plain'
|
||||||
elif report.report_type == "import":
|
elif report.report_type == "import":
|
||||||
filename = download(args["i"], "/tmp/%s-%s.ged" % (str(profile.user.username), str(handle)))
|
filename = download(args["i"], "/tmp/%s-%s.%s" % (str(profile.user.username),
|
||||||
|
str(handle),
|
||||||
|
args["iff"]))
|
||||||
if filename is not None:
|
if filename is not None:
|
||||||
import threading
|
import threading
|
||||||
def background():
|
def background():
|
||||||
@@ -309,7 +330,6 @@ def process_action(request, view, handle, action):
|
|||||||
return redirect("/report/")
|
return redirect("/report/")
|
||||||
# If failure, just fail for now:
|
# If failure, just fail for now:
|
||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["tview"] = "Results"
|
|
||||||
#context["view"] = view
|
#context["view"] = view
|
||||||
#context["handle"] = handle
|
#context["handle"] = handle
|
||||||
#context["action"] = action
|
#context["action"] = action
|
||||||
@@ -321,6 +341,7 @@ def view_detail(request, view, handle, action="view"):
|
|||||||
context = RequestContext(request)
|
context = RequestContext(request)
|
||||||
context["action"] = action
|
context["action"] = action
|
||||||
context["view"] = view
|
context["view"] = view
|
||||||
|
context["tview"] = _('Browse')
|
||||||
if view == "event":
|
if view == "event":
|
||||||
try:
|
try:
|
||||||
obj = Event.objects.get(handle=handle)
|
obj = Event.objects.get(handle=handle)
|
||||||
|
@@ -117,6 +117,14 @@ for table, entries in [("grampsdb.config",
|
|||||||
("handle", '"ex_gpkg"'),
|
("handle", '"ex_gpkg"'),
|
||||||
("options", '"off=gramps"'),
|
("options", '"off=gramps"'),
|
||||||
("report_type", '"export"')),
|
("report_type", '"export"')),
|
||||||
|
(("name", '"GEDCOM Import"'),
|
||||||
|
("handle", '"im_ged"'),
|
||||||
|
("options", '"iff=ged i=http://arborvita.free.fr/Kennedy/Kennedy.ged"'),
|
||||||
|
("report_type", '"import"')),
|
||||||
|
(("name", '"Gramps package (portable XML) Import"'),
|
||||||
|
("handle", '"im_gpkg"'),
|
||||||
|
("options", '"iff=gramps i=http://gramps.svn.sourceforge.net/viewvc/gramps/trunk/example/gramps/example.gramps?revision=18333"'),
|
||||||
|
("report_type", '"import"')),
|
||||||
])]:
|
])]:
|
||||||
entry_count = 0
|
entry_count = 0
|
||||||
for entry in entries:
|
for entry in entries:
|
||||||
|
@@ -40,7 +40,7 @@ admin.autodiscover()
|
|||||||
|
|
||||||
from webapp.grampsdb.views import (main_page, user_page, logout_page,
|
from webapp.grampsdb.views import (main_page, user_page, logout_page,
|
||||||
process_action, view, view_detail,
|
process_action, view, view_detail,
|
||||||
view_name_detail)
|
view_name_detail, browse_page)
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
# Specific matches first:
|
# Specific matches first:
|
||||||
@@ -63,7 +63,9 @@ urlpatterns += patterns('',
|
|||||||
# The rest will match views:
|
# The rest will match views:
|
||||||
urlpatterns += patterns('',
|
urlpatterns += patterns('',
|
||||||
(r'^$', main_page),
|
(r'^$', main_page),
|
||||||
|
(r'^user/$', user_page),
|
||||||
(r'^user/(\w+)/$', user_page),
|
(r'^user/(\w+)/$', user_page),
|
||||||
|
(r'^browse/$', browse_page),
|
||||||
(r'^login/$', 'django.contrib.auth.views.login'),
|
(r'^login/$', 'django.contrib.auth.views.login'),
|
||||||
(r'^logout/$', logout_page),
|
(r'^logout/$', logout_page),
|
||||||
(r'^(?P<view>(\w+))/$', view),
|
(r'^(?P<view>(\w+))/$', view),
|
||||||
|
Reference in New Issue
Block a user