mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-22 15:21:52 +00:00
Removing editLogbookEntry capability
This commit is contained in:
parent
924c5a3bf8
commit
69b843a824
@ -73,6 +73,7 @@ class EntranceLetterForm(ModelForm):
|
|||||||
model = CaveAndEntrance
|
model = CaveAndEntrance
|
||||||
exclude = ('cave', 'entrance')
|
exclude = ('cave', 'entrance')
|
||||||
|
|
||||||
|
#This was all commneted out by Martin Green in 2012 !
|
||||||
#class PersonForm(ModelForm):
|
#class PersonForm(ModelForm):
|
||||||
# class Meta:
|
# class Meta:
|
||||||
# model = Person
|
# model = Person
|
||||||
|
@ -85,7 +85,6 @@ def get_absolute_url(self):
|
|||||||
return ('expedition', (expedition.year))
|
return ('expedition', (expedition.year))
|
||||||
|
|
||||||
class ExpeditionListView(ListView):
|
class ExpeditionListView(ListView):
|
||||||
|
|
||||||
model = Expedition
|
model = Expedition
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
@ -93,7 +92,6 @@ class ExpeditionListView(ListView):
|
|||||||
context['now'] = timezone.now()
|
context['now'] = timezone.now()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
def person(request, first_name='', last_name='', ):
|
def person(request, first_name='', last_name='', ):
|
||||||
this_person = Person.objects.get(first_name = first_name, last_name = last_name)
|
this_person = Person.objects.get(first_name = first_name, last_name = last_name)
|
||||||
|
|
||||||
@ -168,82 +166,83 @@ def personForm(request,pk):
|
|||||||
form=PersonForm(instance=person)
|
form=PersonForm(instance=person)
|
||||||
return render(request,'personform.html', {'form':form,})
|
return render(request,'personform.html', {'form':form,})
|
||||||
|
|
||||||
@login_required_if_public
|
# tried to delete all this, and the reference in urls.py, but got impenetrable django error message
|
||||||
def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
# @login_required_if_public
|
||||||
expedition = Expedition.objects.get(year=expeditionyear)
|
# def newLogbookEntry(request, expeditionyear, pdate = None, pslug = None):
|
||||||
PersonTripFormSet, TripForm = getTripForm(expedition)
|
# expedition = Expedition.objects.get(year=expeditionyear)
|
||||||
if pslug and pdate:
|
# PersonTripFormSet, TripForm = getTripForm(expedition)
|
||||||
previousdate = datetime.date(*[int(x) for x in pdate.split("-")])
|
# if pslug and pdate:
|
||||||
previouslbe = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition)
|
# previousdate = datetime.date(*[int(x) for x in pdate.split("-")])
|
||||||
assert previouslbe.filename
|
# previouslbe = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition)
|
||||||
if request.method == 'POST': # If the form has been submitted...
|
# assert previouslbe.filename
|
||||||
tripForm = TripForm(request.POST) # A form bound to the POST data
|
# if request.method == 'POST': # If the form has been submitted...
|
||||||
personTripFormSet = PersonTripFormSet(request.POST)
|
# tripForm = TripForm(request.POST) # A form bound to the POST data
|
||||||
if tripForm.is_valid() and personTripFormSet.is_valid(): # All validation rules pass
|
# personTripFormSet = PersonTripFormSet(request.POST)
|
||||||
dateStr = tripForm.cleaned_data["date"].strftime("%Y-%m-%d")
|
# if tripForm.is_valid() and personTripFormSet.is_valid(): # All validation rules pass
|
||||||
directory = os.path.join(settings.EXPOWEB,
|
# dateStr = tripForm.cleaned_data["date"].strftime("%Y-%m-%d")
|
||||||
"years",
|
# directory = os.path.join(settings.EXPOWEB,
|
||||||
expedition.year,
|
# "years",
|
||||||
"autologbook")
|
# expedition.year,
|
||||||
filename = os.path.join(directory,
|
# "autologbook")
|
||||||
dateStr + "." + slugify(tripForm.cleaned_data["title"])[:50] + ".html")
|
# filename = os.path.join(directory,
|
||||||
if not os.path.isdir(directory):
|
# dateStr + "." + slugify(tripForm.cleaned_data["title"])[:50] + ".html")
|
||||||
os.mkdir(directory)
|
# if not os.path.isdir(directory):
|
||||||
if pslug and pdate:
|
# os.mkdir(directory)
|
||||||
delLogbookEntry(previouslbe)
|
# if pslug and pdate:
|
||||||
f = open(filename, "w")
|
# delLogbookEntry(previouslbe)
|
||||||
template = loader.get_template('dataformat/logbookentry.html')
|
# f = open(filename, "w")
|
||||||
context = Context({'trip': tripForm.cleaned_data,
|
# template = loader.get_template('dataformat/logbookentry.html')
|
||||||
'persons': personTripFormSet.cleaned_data,
|
# context = Context({'trip': tripForm.cleaned_data,
|
||||||
'date': dateStr,
|
# 'persons': personTripFormSet.cleaned_data,
|
||||||
'expeditionyear': expeditionyear})
|
# 'date': dateStr,
|
||||||
f.write(template.render(context))
|
# 'expeditionyear': expeditionyear})
|
||||||
f.close()
|
# f.write(template.render(context))
|
||||||
print((logbookparsers.parseAutoLogBookEntry(filename)))
|
# f.close()
|
||||||
return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
# print((logbookparsers.parseAutoLogBookEntry(filename)))
|
||||||
else:
|
# return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
||||||
if pslug and pdate:
|
# else:
|
||||||
if previouslbe.cave:
|
# if pslug and pdate:
|
||||||
tripForm = TripForm(initial={"date": previousdate,
|
# if previouslbe.cave:
|
||||||
"title": previouslbe.title,
|
# tripForm = TripForm(initial={"date": previousdate,
|
||||||
"cave": previouslbe.cave.reference(),
|
# "title": previouslbe.title,
|
||||||
"location": None,
|
# "cave": previouslbe.cave.reference(),
|
||||||
"caveOrLocation": "cave",
|
# "location": None,
|
||||||
"html": previouslbe.text})
|
# "caveOrLocation": "cave",
|
||||||
else:
|
# "html": previouslbe.text})
|
||||||
tripForm = TripForm(initial={"date": previousdate,
|
# else:
|
||||||
"title": previouslbe.title,
|
# tripForm = TripForm(initial={"date": previousdate,
|
||||||
"cave": None,
|
# "title": previouslbe.title,
|
||||||
"location": previouslbe.place,
|
# "cave": None,
|
||||||
"caveOrLocation": "location",
|
# "location": previouslbe.place,
|
||||||
"html": previouslbe.text})
|
# "caveOrLocation": "location",
|
||||||
personTripFormSet = PersonTripFormSet(initial=[{"name": get_name(py.personexpedition),
|
# "html": previouslbe.text})
|
||||||
"TU": py.time_underground,
|
# personTripFormSet = PersonTripFormSet(initial=[{"name": get_name(py.personexpedition),
|
||||||
"author": py.is_logbook_entry_author}
|
# "TU": py.time_underground,
|
||||||
for py in previouslbe.persontrip_set.all()])
|
# "author": py.is_logbook_entry_author}
|
||||||
else:
|
# for py in previouslbe.persontrip_set.all()])
|
||||||
tripForm = TripForm() # An unbound form
|
# else:
|
||||||
personTripFormSet = PersonTripFormSet()
|
# tripForm = TripForm() # An unbound form
|
||||||
|
# personTripFormSet = PersonTripFormSet()
|
||||||
|
|
||||||
return render(request, 'newlogbookentry.html', {
|
# return render(request, 'newlogbookentry.html', {
|
||||||
'tripForm': tripForm,
|
# 'tripForm': tripForm,
|
||||||
'personTripFormSet': personTripFormSet,
|
# 'personTripFormSet': personTripFormSet,
|
||||||
|
|
||||||
})
|
# })
|
||||||
|
|
||||||
@login_required_if_public
|
# @login_required_if_public
|
||||||
def deleteLogbookEntry(request, expeditionyear, date = None, slug = None):
|
# def deleteLogbookEntry(request, expeditionyear, date = None, slug = None):
|
||||||
expedition = Expedition.objects.get(year=expeditionyear)
|
# expedition = Expedition.objects.get(year=expeditionyear)
|
||||||
previousdate = datetime.date(*[int(x) for x in date.split("-")])
|
# previousdate = datetime.date(*[int(x) for x in date.split("-")])
|
||||||
previouslbe = LogbookEntry.objects.get(slug = slug, date = previousdate, expedition = expedition)
|
# previouslbe = LogbookEntry.objects.get(slug = slug, date = previousdate, expedition = expedition)
|
||||||
delLogbookEntry(previouslbe)
|
# delLogbookEntry(previouslbe)
|
||||||
return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
# return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
|
||||||
|
|
||||||
def delLogbookEntry(lbe):
|
# def delLogbookEntry(lbe):
|
||||||
for pt in lbe.persontrip_set.all():
|
# for pt in lbe.persontrip_set.all():
|
||||||
pt.delete()
|
# pt.delete()
|
||||||
lbe.delete()
|
# lbe.delete()
|
||||||
os.remove(lbe.filename)
|
# os.remove(lbe.filename)
|
||||||
|
|
||||||
def get_people(request, expeditionslug):
|
def get_people(request, expeditionslug):
|
||||||
exp = Expedition.objects.get(year = expeditionslug)
|
exp = Expedition.objects.get(year = expeditionslug)
|
||||||
|
@ -63,7 +63,7 @@ an "S" for a survey trip. The colours are the same for people on the same trip.
|
|||||||
<form action="" method="GET"><input type="submit" name="reload" value="Reload"></form>
|
<form action="" method="GET"><input type="submit" name="reload" value="Reload"></form>
|
||||||
|
|
||||||
<h3>Logbooks and survey trips per day</h3>
|
<h3>Logbooks and survey trips per day</h3>
|
||||||
<a href="{% url "newLogBookEntry" expeditionyear=expedition.year %}">New logbook entry</a>
|
|
||||||
<table class="expeditionlogbooks">
|
<table class="expeditionlogbooks">
|
||||||
<tr><th>Date</th><th>Logged trips</th><th>Surveys</th></tr>
|
<tr><th>Date</th><th>Logged trips</th><th>Surveys</th></tr>
|
||||||
{% regroup dateditems|dictsort:"date" by date as dates %}
|
{% regroup dateditems|dictsort:"date" by date as dates %}
|
||||||
|
2
urls.py
2
urls.py
@ -47,7 +47,7 @@ actualurlpatterns = [
|
|||||||
url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"),
|
url(r'^expeditions/?$', views_logbooks.ExpeditionListView.as_view(), name="expeditions"),
|
||||||
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-zA-Z&;]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z&;]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-zA-Z&;]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||||
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
||||||
url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), # Needed !
|
# url(r'^newlogbookentry/(?P<expeditionyear>.*)$', views_logbooks.newLogbookEntry, name="newLogBookEntry"), # Needed !
|
||||||
# url(r'^editlogbookentry/(?P<expeditionyear>[^/]*)/(?P<pdate>[^/]*)/(?P<pslug>[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), # working !
|
# url(r'^editlogbookentry/(?P<expeditionyear>[^/]*)/(?P<pdate>[^/]*)/(?P<pslug>[^/]*)/$', views_logbooks.newLogbookEntry, name="editLogBookEntry"), # working !
|
||||||
# url(r'^deletelogbookentry/(?P<expeditionyear>[^/]*)/(?P<date>[^/]*)/(?P<slug>[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"),
|
# url(r'^deletelogbookentry/(?P<expeditionyear>[^/]*)/(?P<date>[^/]*)/(?P<slug>[^/]*)/$', views_logbooks.deleteLogbookEntry, name="deleteLogBookEntry"),
|
||||||
url(r'^newfile', views_other.newFile, name="newFile"), # oddly broken, needs investigating more
|
url(r'^newfile', views_other.newFile, name="newFile"), # oddly broken, needs investigating more
|
||||||
|
Loading…
Reference in New Issue
Block a user