mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-17 00:37:09 +00:00
First implementation of html API, both TSV and JSON
This commit is contained in:
@@ -41,7 +41,7 @@ def getNotablePersons():
|
||||
for person in Person.objects.all():
|
||||
if person.bisnotable():
|
||||
notablepersons.append(person)
|
||||
return notablepersons
|
||||
return notablepersons
|
||||
|
||||
|
||||
def personindex(request):
|
||||
@@ -84,13 +84,28 @@ def expedition(request, expeditionname):
|
||||
def get_absolute_url(self):
|
||||
return ('expedition', (expedition.year))
|
||||
|
||||
class ExpeditionListView(ListView):
|
||||
class ExpeditionListView(ListView): # django thus expects a template called "expedition_list.html"
|
||||
# from the name of the object not the name of the class.
|
||||
model = Expedition
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ExpeditionListView, self).get_context_data(**kwargs)
|
||||
context['now'] = timezone.now()
|
||||
return context
|
||||
|
||||
class Expeditions_tsvListView(ListView):
|
||||
"""This uses the Django built-in shortcut mechanism
|
||||
It defaults to use a template with name <app-label>/<model-name>_list.html.
|
||||
https://www.agiliq.com/blog/2017/12/when-and-how-use-django-listview/
|
||||
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Generic_views
|
||||
Either a queryset variable or set_queryset() function is used, but not needed
|
||||
if you want all the obejcts of a particaulr type in which case just set model = <object>
|
||||
"""
|
||||
template_name = 'core/expeditions_tsv_list.html' # if not present then uses core/expedition_list.html
|
||||
#queryset = Expedition.objects.all()
|
||||
#context_object_name = 'expedition'
|
||||
model = Expedition # equivalent to .objects.all() for a queryset
|
||||
|
||||
class Expeditions_jsonListView(ListView):
|
||||
template_name = 'core/expeditions_json_list.html'
|
||||
model = Expedition
|
||||
|
||||
|
||||
def person(request, first_name='', last_name='', ):
|
||||
this_person = Person.objects.get(first_name = first_name, last_name = last_name)
|
||||
|
||||
Reference in New Issue
Block a user