Working on private/protected non-logged-in viewing/searching
svn: r13721
This commit is contained in:
parent
ca061d3607
commit
1d86ecd6fb
@ -3,10 +3,10 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Event #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>Event Type</th>
|
||||
<th>Description</th>
|
||||
@ -29,6 +29,7 @@
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Media #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>MIME Type</th>
|
||||
<th>Date</th>
|
||||
|
156
src/data/templates/view_name_detail.html
Normal file
156
src/data/templates/view_name_detail.html
Normal file
@ -0,0 +1,156 @@
|
||||
{% extends "view_page_detail.html" %}
|
||||
{% load my_tags %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
$('#tabs').tabs();
|
||||
});
|
||||
</script>
|
||||
|
||||
<div class="content" id="IndividualDetail">
|
||||
<h3>{{person.name_set|make_name:user}}</h3>
|
||||
<div id="summaryarea">
|
||||
<table class="infolist"> {% comment %} 5 cols {% endcomment %}
|
||||
<tbody>
|
||||
|
||||
{% if user.is_authenticated %}
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Family:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"surname"}}</td>
|
||||
<td class="ColumnAttribute">Prefix:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"prefix"}}</td>
|
||||
<td rowspan="5" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
|
||||
</tr>
|
||||
<td class="ColumnAttribute" colspan="2"></td>
|
||||
<td class="ColumnAttribute">Suffix:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"suffix"}}</td>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Given:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"first_name"}}</td>
|
||||
<td class="ColumnAttribute">Call Name:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"call"}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Type:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"name_type"}}</td>
|
||||
<td class="ColumnAttribute">Patronymic:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"patronymic"}}</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<td class="ColumnAttribute" colspan="2"></td>
|
||||
<td class="ColumnAttribute">Title:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"title"}}</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Gender:</td>
|
||||
<td class="ColumnValue" id="data">{{person.gender_type|escape}}</td>
|
||||
<td class="ColumnAttribute">ID:</td>
|
||||
<td class="ColumnValue" id="data">{{person.gramps_id|escape}}</td>
|
||||
<td class="ColumnAttribute">Marker:</td>
|
||||
<td class="ColumnValue" id="data">{{person.marker_type|escape}}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% else %}
|
||||
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Family:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"surname"}}</td>
|
||||
<td class="ColumnAttribute">Prefix:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
<td rowspan="5" colspan="2" style="border:solid 2px #7D5925;">Image:</td>
|
||||
</tr>
|
||||
<td class="ColumnAttribute" colspan="2"></td>
|
||||
<td class="ColumnAttribute">Suffix:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Given:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
<td class="ColumnAttribute">Call Name:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Type:</td>
|
||||
<td class="ColumnValue" id="data">{{person.name_set|preferred:"name_type"}}</td>
|
||||
<td class="ColumnAttribute">Patronymic:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
</tr>
|
||||
</tr>
|
||||
<td class="ColumnAttribute" colspan="2"></td>
|
||||
<td class="ColumnAttribute">Title:</td>
|
||||
<td class="ColumnValue" id="data">[Private]</td>
|
||||
<tr>
|
||||
<tr>
|
||||
<td class="ColumnAttribute">Gender:</td>
|
||||
<td class="ColumnValue" id="data">{{person.gender_type|escape}}</td>
|
||||
<td class="ColumnAttribute">ID:</td>
|
||||
<td class="ColumnValue" id="data">{{person.gramps_id|escape}}</td>
|
||||
<td class="ColumnAttribute">Marker:</td>
|
||||
<td class="ColumnValue" id="data"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<!-- Tabs -->
|
||||
<h2 class="demoHeaders">Tabs</h2>
|
||||
|
||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
|
||||
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active"><a href="#tab-events">Events</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-names">Names</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-sources">Sources</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-attributes">Attributes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-addresses">Addresses</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-notes">Notes</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-gallery">Gallery</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-internet">Internet</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-association">Associations</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-lds">LDS</a></li>
|
||||
<li class="ui-corner-top ui-state-default"><a href="#tab-references">References</a></li>
|
||||
</ul>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom" id="tab-events">
|
||||
<!-- Events -->
|
||||
{{ person|person_event_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-names">
|
||||
{{ person|person_name_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-sources">
|
||||
{{ person|person_source_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-attributes">
|
||||
{{ person|person_attribute_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-addresses">
|
||||
{{ person|person_address_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-notes">
|
||||
{{ person|person_note_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-gallery">
|
||||
{{ person|person_gallery_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-internet">
|
||||
{{ person|person_internet_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-association">
|
||||
{{ person|person_association_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-lds">
|
||||
{{ person|person_lds_table:user|safe }}
|
||||
</div>
|
||||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide" id="tab-references">
|
||||
{{ person|person_reference_table:user|safe }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Note #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>Note Type</th>
|
||||
<th>Text</th>
|
||||
@ -24,7 +24,6 @@
|
||||
{% else %}
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -9,7 +9,7 @@
|
||||
<p id="description">
|
||||
<form name="SearchForm">
|
||||
<input type="submit" value="Search:"></submit>
|
||||
<input name="search" id="get_focus" type="input" size="50" value="{{search}}"></input>
|
||||
<input autocomplete="off" name="search" id="get_focus" type="input" size="50" value="{{search}}"></input>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
{% else %}
|
||||
[<a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a>]
|
||||
{% endifequal %}
|
||||
<b>Matches</b>: {{page.paginator.count}}/{{total}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -78,6 +79,7 @@
|
||||
{% else %}
|
||||
[<a href="?page={{page.paginator.num_pages}}{{search_query}}">last</a>]
|
||||
{% endifequal %}
|
||||
<b>Matches</b>: {{page.paginator.count}}/{{total}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Place #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>Title</th>
|
||||
</tr>
|
||||
@ -21,8 +21,6 @@
|
||||
<td><a href="/{{view}}/{{place.handle|escape}}">{{place.title|escape}}</a>
|
||||
{% else %}
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -3,10 +3,11 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="95%">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Repository #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>Type</th>
|
||||
<th>Name</th>
|
||||
@ -24,7 +25,6 @@
|
||||
{% else %}
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
{% block table_data %}
|
||||
|
||||
<table cellspacing="0" class="infolist surname">
|
||||
<table cellspacing="0" class="infolist surname" width="90%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Source #</th>
|
||||
<th>#</th>
|
||||
<th>ID</th>
|
||||
<th>Title</th>
|
||||
<th>Pub Info</th>
|
||||
|
@ -45,7 +45,7 @@ from web.grampsdb.models import *
|
||||
_ = lambda text: text
|
||||
|
||||
# Views: [(Nice name plural, /name/handle, Model), ]
|
||||
VIEWS = [(_('People'), 'person', Person),
|
||||
VIEWS = [(_('People'), 'person', Name),
|
||||
(_('Families'), 'family', Family),
|
||||
(_('Events'), 'event', Event),
|
||||
(_('Notes'), 'note', Note),
|
||||
@ -102,6 +102,19 @@ def user_page(request, username):
|
||||
context["cview"] = _('User')
|
||||
return render_to_response('user_page.html', context)
|
||||
|
||||
def view_name_detail(request, handle, id):
|
||||
view_template = "view_name_detail.html"
|
||||
name = Name.objects.get(id=id)
|
||||
person = Person.objects.get(handle=handle)
|
||||
context = RequestContext(request)
|
||||
context["cview"] = 'Name'
|
||||
context["view"] = 'name'
|
||||
context["handle"] = handle
|
||||
context["id"] = id
|
||||
context["name"] = name
|
||||
context["person"] = person
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
def view_detail(request, view, handle):
|
||||
if view == "event":
|
||||
try:
|
||||
@ -160,69 +173,215 @@ def view_detail(request, view, handle):
|
||||
context["handle"] = handle
|
||||
context[view] = obj
|
||||
return render_to_response(view_template, context)
|
||||
|
||||
|
||||
def view(request, view):
|
||||
cview = view.title()
|
||||
search = ""
|
||||
if view == "event":
|
||||
object_list = Event.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Event.objects \
|
||||
.filter((Q(gramps_id__icontains=search) |
|
||||
Q(event_type__name__icontains=search) |
|
||||
Q(place__title__icontains=search)) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Event.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_events.html'
|
||||
total = Event.objects.all().count()
|
||||
elif view == "family":
|
||||
object_list = Family.objects.all().order_by("gramps_id")
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
if request.user.is_authenticated():
|
||||
if "," in search:
|
||||
surname, first = [term.strip() for term in
|
||||
search.split(",", 1)]
|
||||
object_list = Family.objects \
|
||||
.filter((Q(father__name__surname__istartswith=surname) &
|
||||
Q(father__name__first_name__istartswith=first)) |
|
||||
(Q(mother__name__surname__istartswith=surname) &
|
||||
Q(mother__name__first_name__istartswith=first))
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else: # no comma
|
||||
object_list = Family.objects \
|
||||
.filter(Q(gramps_id__icontains=search) |
|
||||
Q(family_rel_type__name__icontains=search) |
|
||||
Q(father__name__surname__istartswith=search) |
|
||||
Q(father__name__first_name__istartswith=search) |
|
||||
Q(mother__name__surname__istartswith=search) |
|
||||
Q(mother__name__first_name__istartswith=search)
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
if "," in search:
|
||||
search, trash = [term.strip() for term in search.split(",", 1)]
|
||||
object_list = Family.objects \
|
||||
.filter((Q(gramps_id__icontains=search) |
|
||||
Q(family_rel_type__name__icontains=search) |
|
||||
Q(father__name__surname__istartswith=search) |
|
||||
Q(mother__name__surname__istartswith=search)) &
|
||||
Q(private=False)
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else: # no search
|
||||
if request.user.is_authenticated():
|
||||
object_list = Family.objects.all().order_by("gramps_id")
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
object_list = Family.objects.filter(private=False).order_by("gramps_id")
|
||||
view_template = 'view_families.html'
|
||||
total = Family.objects.all().count()
|
||||
elif view == "media":
|
||||
object_list = Media.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Media.objects \
|
||||
.filter(Q(gramps_id__icontains=search) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Media.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_media.html'
|
||||
total = Media.objects.all().count()
|
||||
elif view == "note":
|
||||
object_list = Note.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Note.objects \
|
||||
.filter((Q(gramps_id__icontains=search) |
|
||||
Q(note_type__name__icontains=search) |
|
||||
Q(text__icontains=search)) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Note.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_notes.html'
|
||||
total = Note.objects.all().count()
|
||||
elif view == "person":
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
if request.user.is_authenticated():
|
||||
if "," in search:
|
||||
surname, first_name = [term.strip() for term in search.split(",", 1)]
|
||||
surname, first_name = [term.strip() for term in
|
||||
search.split(",", 1)]
|
||||
object_list = Name.objects \
|
||||
.filter(surname__istartswith=surname,
|
||||
first_name__istartswith=first_name) \
|
||||
.order_by("surname", "first_name")
|
||||
.filter(Q(surname__istartswith=surname,
|
||||
first_name__istartswith=first_name)) \
|
||||
.order_by("surname", "first_name")
|
||||
else:
|
||||
object_list = Name.objects \
|
||||
.filter(Q(surname__icontains=search) |
|
||||
Q(first_name__icontains=search) |
|
||||
Q(suffix__icontains=search) |
|
||||
Q(prefix__icontains=search) |
|
||||
Q(patronymic__icontains=search) |
|
||||
Q(title__icontains=search) |
|
||||
Q(person__gramps_id__icontains=search)
|
||||
.filter((Q(surname__icontains=search) |
|
||||
Q(first_name__icontains=search) |
|
||||
Q(suffix__icontains=search) |
|
||||
Q(prefix__icontains=search) |
|
||||
Q(patronymic__icontains=search) |
|
||||
Q(title__icontains=search) |
|
||||
Q(person__gramps_id__icontains=search))
|
||||
) \
|
||||
.order_by("surname", "first_name")
|
||||
else:
|
||||
# FIXME: non-authenticated users don't get to search first_names
|
||||
# BEGIN NON-AUTHENTICATED users
|
||||
if "," in search:
|
||||
search, first_name = [term.strip() for term in search.split(",", 1)]
|
||||
search, trash = [term.strip() for term in search.split(",", 1)]
|
||||
object_list = Name.objects \
|
||||
.filter(surname__istartswith=search) \
|
||||
.filter(Q(surname__istartswith=search) &
|
||||
Q(private=False) &
|
||||
Q(person__private=False)
|
||||
) \
|
||||
.order_by("surname", "first_name")
|
||||
# END NON-AUTHENTICATED users
|
||||
else:
|
||||
object_list = Name.objects.order_by("surname", "first_name")
|
||||
if request.user.is_authenticated():
|
||||
object_list = Name.objects.all().order_by("surname", "first_name")
|
||||
else:
|
||||
# BEGIN NON-AUTHENTICATED users
|
||||
object_list = Name.objects.filter(Q(private=False) &
|
||||
Q(person__private=False)).order_by("surname", "first_name")
|
||||
# END NON-AUTHENTICATED users
|
||||
view_template = 'view_people.html'
|
||||
total = Name.objects.all().count()
|
||||
elif view == "place":
|
||||
object_list = Place.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Place.objects \
|
||||
.filter((Q(gramps_id__icontains=search) |
|
||||
Q(title__icontains=search)
|
||||
) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Place.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_places.html'
|
||||
total = Place.objects.all().count()
|
||||
elif view == "repository":
|
||||
object_list = Repository.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Repository.objects \
|
||||
.filter((Q(gramps_id__icontains=search) |
|
||||
Q(name__icontains=search) |
|
||||
Q(repository_type__name__icontains=search)
|
||||
) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Repository.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_repositories.html'
|
||||
total = Repository.objects.all().count()
|
||||
elif view == "source":
|
||||
object_list = Source.objects.all().order_by("gramps_id")
|
||||
if request.user.is_authenticated():
|
||||
private = Q()
|
||||
else:
|
||||
# NON-AUTHENTICATED users
|
||||
private = Q(private=False)
|
||||
if request.GET.has_key("search"):
|
||||
search = request.GET.get("search")
|
||||
object_list = Source.objects \
|
||||
.filter(Q(gramps_id__icontains=search) &
|
||||
private
|
||||
) \
|
||||
.order_by("gramps_id")
|
||||
else:
|
||||
object_list = Source.objects.filter(private).order_by("gramps_id")
|
||||
view_template = 'view_sources.html'
|
||||
total = Source.objects.all().count()
|
||||
else:
|
||||
raise Http404("Requested page type not known")
|
||||
|
||||
if request.user.is_authenticated():
|
||||
paginator = Paginator(object_list, 50)
|
||||
else:
|
||||
paginator = Paginator(object_list, 15)
|
||||
paginator = Paginator(object_list, 19)
|
||||
|
||||
try:
|
||||
page = int(request.GET.get('page', '1'))
|
||||
@ -239,6 +398,7 @@ def view(request, view):
|
||||
context["view"] = view
|
||||
context["cview"] = cview
|
||||
context["search"] = search
|
||||
context["total"] = total
|
||||
if search:
|
||||
context["search_query"] = ("&search=%s" % escape(search))
|
||||
else:
|
||||
|
@ -39,7 +39,7 @@ from django.contrib import admin
|
||||
admin.autodiscover()
|
||||
|
||||
from web.grampsdb.views import (main_page, user_page, logout_page,
|
||||
view, view_detail)
|
||||
view, view_detail, view_name_detail)
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Specific matches first:
|
||||
@ -68,6 +68,7 @@ urlpatterns += patterns('',
|
||||
url(r'^person/(?P<handle>(\w+))/$', view_detail,
|
||||
{"view": "person"}, name="view-person-detail"),
|
||||
(r'^(?P<view>(\w+))/(?P<handle>(\w+))/$', view_detail),
|
||||
(r'^person/(?P<handle>(\w+))/name/(?P<id>(\w+))$', view_name_detail),
|
||||
)
|
||||
|
||||
# In urls:
|
||||
|
@ -60,7 +60,8 @@ def register_plugins():
|
||||
|
||||
def probably_alive(handle):
|
||||
db = DjangoDb()
|
||||
return Utils.probably_alive(db.get_person_from_handle(handle), db)
|
||||
person = db.get_person_from_handle(handle)
|
||||
return Utils.probably_alive(person, db)
|
||||
|
||||
def format_number(number, with_grouping=True):
|
||||
# FIXME: should be user's setting
|
||||
|
Loading…
Reference in New Issue
Block a user