mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 05:55:06 +00:00
remove garbage & duplicated code
This commit is contained in:
@@ -24,18 +24,6 @@ from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||
|
||||
import troggle.settings as settings
|
||||
|
||||
# Django uses Context, not RequestContext when you call render
|
||||
# to_response. We always want to use RequestContext, so that
|
||||
# django adds the context from settings.TEMPLATE_CONTEXT_PROCESSORS.
|
||||
# This way we automatically get necessary settings variables passed
|
||||
# to each template. So we use a custom method, render_response
|
||||
# instead of render_to_response. Hopefully future Django releases
|
||||
# will make this unnecessary.
|
||||
|
||||
# from troggle.alwaysUseRequestContext import render_response
|
||||
|
||||
# Deprecated in 1.11.29
|
||||
# @django.db.models.permalink #this allows the nice get_absolute_url syntax we are using
|
||||
|
||||
def getNotablePersons():
|
||||
notablepersons = []
|
||||
@@ -82,14 +70,10 @@ def expedition(request, expeditionname):
|
||||
LoadLogbookForExpedition(this_expedition)
|
||||
return render(request,'expedition.html', {'expedition': this_expedition, 'expeditions':expeditions, 'personexpeditiondays':personexpeditiondays, 'settings':settings, 'dateditems': dateditems })
|
||||
|
||||
|
||||
def get_absolute_url(self):
|
||||
return ('expedition', (expedition.year))
|
||||
|
||||
# replaced by statistics page
|
||||
# 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
|
||||
|
||||
|
||||
class Expeditions_tsvListView(ListView):
|
||||
"""This uses the Django built-in shortcut mechanism
|
||||
@@ -176,90 +160,6 @@ def logbookSearch(request, extra):
|
||||
|
||||
return render(request,'logbooksearch.html',
|
||||
{ 'query_string': query_string, 'found_entries': found_entries, })
|
||||
#context_instance=RequestContext(request))
|
||||
|
||||
def personForm(request,pk):
|
||||
person=Person.objects.get(pk=pk)
|
||||
form=PersonForm(instance=person)
|
||||
return render(request,'personform.html', {'form':form,})
|
||||
|
||||
# tried to delete all this, and the reference in urls.py, but got impenetrable django error message
|
||||
# @login_required_if_public
|
||||
# def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
||||
# expedition = Expedition.objects.get(year=expeditionyear)
|
||||
# PersonTripFormSet, TripForm = getTripForm(expedition)
|
||||
# if pslug and pdate:
|
||||
# previousdate = datetime.date(*[int(x) for x in pdate.split("-")])
|
||||
# previouslbe = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition)
|
||||
# assert previouslbe.filename
|
||||
# if request.method == 'POST': # If the form has been submitted...
|
||||
# tripForm = TripForm(request.POST) # A form bound to the POST data
|
||||
# personTripFormSet = PersonTripFormSet(request.POST)
|
||||
# if tripForm.is_valid() and personTripFormSet.is_valid(): # All validation rules pass
|
||||
# dateStr = tripForm.cleaned_data["date"].strftime("%Y-%m-%d")
|
||||
# directory = os.path.join(settings.EXPOWEB,
|
||||
# "years",
|
||||
# expedition.year,
|
||||
# "autologbook")
|
||||
# filename = os.path.join(directory,
|
||||
# dateStr + "." + slugify(tripForm.cleaned_data["title"])[:50] + ".html")
|
||||
# if not os.path.isdir(directory):
|
||||
# os.mkdir(directory)
|
||||
# if pslug and pdate:
|
||||
# delLogbookEntry(previouslbe)
|
||||
# f = open(filename, "w")
|
||||
# template = loader.get_template('dataformat/logbookentry.html')
|
||||
# context = Context({'trip': tripForm.cleaned_data,
|
||||
# 'persons': personTripFormSet.cleaned_data,
|
||||
# 'date': dateStr,
|
||||
# 'expeditionyear': expeditionyear})
|
||||
# f.write(template.render(context))
|
||||
# f.close()
|
||||
# print((logbookparsers.parseAutoLogBookEntry(filename)))
|
||||
# return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
||||
# else:
|
||||
# if pslug and pdate:
|
||||
# if previouslbe.cave:
|
||||
# tripForm = TripForm(initial={"date": previousdate,
|
||||
# "title": previouslbe.title,
|
||||
# "cave": previouslbe.cave.reference(),
|
||||
# "location": None,
|
||||
# "caveOrLocation": "cave",
|
||||
# "html": previouslbe.text})
|
||||
# else:
|
||||
# tripForm = TripForm(initial={"date": previousdate,
|
||||
# "title": previouslbe.title,
|
||||
# "cave": None,
|
||||
# "location": previouslbe.place,
|
||||
# "caveOrLocation": "location",
|
||||
# "html": previouslbe.text})
|
||||
# personTripFormSet = PersonTripFormSet(initial=[{"name": get_name(py.personexpedition),
|
||||
# "TU": py.time_underground,
|
||||
# "author": py.is_logbook_entry_author}
|
||||
# for py in previouslbe.persontrip_set.all()])
|
||||
# else:
|
||||
# tripForm = TripForm() # An unbound form
|
||||
# personTripFormSet = PersonTripFormSet()
|
||||
|
||||
# return render(request, 'newlogbookentry.html', {
|
||||
# 'tripForm': tripForm,
|
||||
# 'personTripFormSet': personTripFormSet,
|
||||
|
||||
# })
|
||||
|
||||
# @login_required_if_public
|
||||
# def deleteLogbookEntry(request, expeditionyear, date = None, slug = None):
|
||||
# expedition = Expedition.objects.get(year=expeditionyear)
|
||||
# previousdate = datetime.date(*[int(x) for x in date.split("-")])
|
||||
# previouslbe = LogbookEntry.objects.get(slug = slug, date = previousdate, expedition = expedition)
|
||||
# delLogbookEntry(previouslbe)
|
||||
# return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
||||
|
||||
# def delLogbookEntry(lbe):
|
||||
# for pt in lbe.persontrip_set.all():
|
||||
# pt.delete()
|
||||
# lbe.delete()
|
||||
# os.remove(lbe.filename)
|
||||
|
||||
def get_people(request, expeditionslug):
|
||||
exp = Expedition.objects.get(year = expeditionslug)
|
||||
|
||||
Reference in New Issue
Block a user