mirror of
https://expo.survex.com/repositories/expoweb/.git/
synced 2024-11-27 01:32:03 +00:00
[svn r8308] Logbook entries are now at /YYYY-MM-DD/slug .
Try editing a logbook entry title in the admin now. The django built in auto slug field is fun and javascripty.
This commit is contained in:
parent
6f62771552
commit
333705092f
@ -24,6 +24,7 @@ class QMInline(admin.TabularInline):
|
|||||||
|
|
||||||
#class LogbookEntryAdmin(VersionAdmin):
|
#class LogbookEntryAdmin(VersionAdmin):
|
||||||
class LogbookEntryAdmin(admin.ModelAdmin):
|
class LogbookEntryAdmin(admin.ModelAdmin):
|
||||||
|
prepopulated_fields = {'slug':("title",)}
|
||||||
search_fields = ('title','expedition__year')
|
search_fields = ('title','expedition__year')
|
||||||
#inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround
|
#inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import os
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import datetime
|
import datetime
|
||||||
from decimal import Decimal, getcontext
|
from decimal import Decimal, getcontext
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
getcontext().prec=2 #use 2 significant figures for decimal calculations
|
getcontext().prec=2 #use 2 significant figures for decimal calculations
|
||||||
|
|
||||||
from models_survex import *
|
from models_survex import *
|
||||||
@ -211,6 +212,7 @@ class LogbookEntry(TroggleModel):
|
|||||||
cave = models.ForeignKey('Cave',blank=True,null=True)
|
cave = models.ForeignKey('Cave',blank=True,null=True)
|
||||||
place = models.CharField(max_length=100,blank=True,null=True)
|
place = models.CharField(max_length=100,blank=True,null=True)
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
|
slug = models.SlugField(max_length=100)
|
||||||
#href = models.CharField(max_length=100)
|
#href = models.CharField(max_length=100)
|
||||||
|
|
||||||
|
|
||||||
@ -224,7 +226,7 @@ class LogbookEntry(TroggleModel):
|
|||||||
ordering = ('-date',)
|
ordering = ('-date',)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return settings.URL_ROOT + "/logbookentry/" + str(self.pk)
|
return settings.URL_ROOT + reverse('logbookentry',kwargs={'date':self.date,'slug':self.slug})
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return "%s: (%s)" % (self.date, self.title)
|
return "%s: (%s)" % (self.date, self.title)
|
||||||
|
@ -87,8 +87,8 @@ def newQMlink(logbookentry):
|
|||||||
nextQMnumber=biggestQMnumber+1
|
nextQMnumber=biggestQMnumber+1
|
||||||
return settings.URL_ROOT + r'/admin/expo/qm/add/?' + r'found_by=' + str(logbookentry.pk) +'&number=' + str(nextQMnumber)
|
return settings.URL_ROOT + r'/admin/expo/qm/add/?' + r'found_by=' + str(logbookentry.pk) +'&number=' + str(nextQMnumber)
|
||||||
|
|
||||||
def logbookentry(request, logbookentry_pk):
|
def logbookentry(request, date, slug):
|
||||||
logbookentry = LogbookEntry.objects.get(pk = logbookentry_pk)
|
logbookentry = LogbookEntry.objects.get(date=date, slug=slug)
|
||||||
|
|
||||||
return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, 'newQMlink':newQMlink(logbookentry)})
|
return render_response(request, 'logbookentry.html', {'logbookentry': logbookentry, 'newQMlink':newQMlink(logbookentry)})
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@ import troggle.expo.models as models
|
|||||||
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
from troggle.parsers.people import GetPersonExpeditionNameLookup
|
||||||
from troggle.parsers.cavetab import GetCaveLookup
|
from troggle.parsers.cavetab import GetCaveLookup
|
||||||
|
|
||||||
|
from django.template.defaultfilters import slugify
|
||||||
|
|
||||||
import csv
|
import csv
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
@ -286,7 +288,7 @@ def SetDatesFromLogbookEntries(expedition):
|
|||||||
# lprevlogbookentry = logbookentry
|
# lprevlogbookentry = logbookentry
|
||||||
|
|
||||||
# This combined date / number key is a weird way of doing things. Use the primary key instead. If we are going to use the date for looking up entries, we should set it up to allow multiple results.
|
# This combined date / number key is a weird way of doing things. Use the primary key instead. If we are going to use the date for looking up entries, we should set it up to allow multiple results.
|
||||||
# # order by date for setting the references
|
# order by date for setting the references
|
||||||
# lprevlogbookentry = None
|
# lprevlogbookentry = None
|
||||||
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
# for logbookentry in expedition.logbookentry_set.order_by('date'):
|
||||||
# if lprevlogbookentry and lprevlogbookentry.date == logbookentry.date:
|
# if lprevlogbookentry and lprevlogbookentry.date == logbookentry.date:
|
||||||
@ -297,6 +299,9 @@ def SetDatesFromLogbookEntries(expedition):
|
|||||||
# logbookentry.href = "%s" % logbookentry.date
|
# logbookentry.href = "%s" % logbookentry.date
|
||||||
# logbookentry.save()
|
# logbookentry.save()
|
||||||
# lprevlogbookentry = logbookentry
|
# lprevlogbookentry = logbookentry
|
||||||
|
for logbookentry in expedition.logbookentry_set.all():
|
||||||
|
logbookentry.slug = slugify(logbookentry.title)
|
||||||
|
logbookentry.save()
|
||||||
|
|
||||||
|
|
||||||
def LoadLogbookForExpedition(expedition):
|
def LoadLogbookForExpedition(expedition):
|
||||||
|
@ -56,7 +56,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
{% if newQMlink %}
|
||||||
<a href="{{newQMlink}}">Add QM found on this trip</a>
|
<a href="{{newQMlink}}">Add QM found on this trip</a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="col1">
|
<div id="col1">
|
||||||
|
@ -23,7 +23,7 @@ urlpatterns = patterns('',
|
|||||||
|
|
||||||
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
|
||||||
url(r'^personexpedition/(?P<first_name>[A-Z]*[a-z]*)[^a-zA-Z]*(?P<last_name>[A-Z]*[a-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-z]*)/(?P<year>\d+)/?$', views_logbooks.personexpedition, name="personexpedition"),
|
||||||
url(r'^logbookentry/(.+)$', views_logbooks.logbookentry,name="logbookentry"),
|
url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),
|
||||||
|
|
||||||
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
|
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
|
||||||
url(r'^cavehref/(.+)$', views_caves.cavehref, name="cave"),
|
url(r'^cavehref/(.+)$', views_caves.cavehref, name="cave"),
|
||||||
|
Loading…
Reference in New Issue
Block a user