[svn] Add: new generic object list template object_list.html, and convenience filter named "link" for making links from objects, and make expeditions list page using those two. Also, fixed survey parsing in databaseReset.py

This commit is contained in:
substantialnoninfringinguser 2009-05-15 03:29:19 +01:00
parent 8538ef27a1
commit 5f93301493
6 changed files with 40 additions and 19 deletions

View File

@ -47,6 +47,7 @@ def import_QMs():
def import_surveys():
import parsers.surveys
parsers.surveys.parseSurveys(logfile=settings.LOGFILE)
def reset():
reload_db()

View File

@ -3,20 +3,19 @@ from imagekit import processors
class ResizeThumb(processors.Resize):
width = 100
height = 75
crop = True
crop = False
class ResizeDisplay(processors.Resize):
width = 600
class EnhanceThumb(processors.Adjustment):
contrast = 1.2
sharpness = 1.1
#class EnhanceThumb(processors.Adjustment):
#contrast = 1.2
#sharpness = 2
class Thumbnail(ImageSpec):
access_as = 'thumbnail_image'
pre_cache = True
processors = [ResizeThumb, EnhanceThumb]
processors = [ResizeThumb]
class Display(ImageSpec):
increment_count = True

View File

@ -17,8 +17,11 @@ from models_survex import *
class TroggleModel(models.Model):
new_since_parsing = models.BooleanField(default=False, editable=False)
def object_name(self):
return self._meta.object_name
def get_admin_url(self):
return settings.URL_ROOT + "/admin/expo/" + self._meta.object_name.lower() + "/" + str(self.pk)
return settings.URL_ROOT + "/admin/expo/" + self.object_name.lower() + "/" + str(self.pk)
class Meta:
abstract = True
@ -26,8 +29,11 @@ class TroggleModel(models.Model):
class TroggleImageModel(ImageModel):
new_since_parsing = models.BooleanField(default=False, editable=False)
def object_name(self):
return self._meta.object_name
def get_admin_url(self):
return settings.URL_ROOT + "/admin/expo/" + self._meta.object_name.lower() + "/" + str(self.pk)
return settings.URL_ROOT + "/admin/expo/" + self.object_name.lower() + "/" + str(self.pk)
class Meta:
abstract = True
@ -42,7 +48,7 @@ class Expedition(TroggleModel):
return self.year
class Meta:
ordering = ('year',)
ordering = ('-year',)
get_latest_by = 'date_from'
def get_absolute_url(self):

View File

@ -1,3 +1,4 @@
from localsettings import *
import os
import urlparse
# Django settings for troggle project.
@ -35,11 +36,10 @@ USE_I18N = True
ADMIN_MEDIA_PREFIX = '/troggle/media-admin/'
PHOTOS_ROOT = os.path.join(EXPOWEB, 'photos')
if URL_ROOT:
MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/')
SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/')
PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/')
SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/')
MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/')
SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/')
PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/')
SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/')
APPEND_SLASH = False
SMART_APPEND_SLASH = True
@ -86,6 +86,4 @@ INSTALLED_APPS = (
'troggle.profiles',
'troggle.expo',
'troggle.imagekit',
)
from localsettings import *
)

View File

@ -0,0 +1,15 @@
{% extends "base.html" %}
{% load link %}
{% block title %}Troggle: all {{object_list.1.meta.object_name}} objects{%endblock%}
{% block contentheader %}
<h1>All {{object_list.0.object_name}} objects</h1>
{% endblock contentheader %}
{% block content %}
<ul>
{% for object in object_list %}
| {{ object|link }}
{% endfor %} |
</ul>
{% endblock content %}

View File

@ -7,6 +7,7 @@ from expo.views_survex import *
from expo.models import *
from django.views.generic.create_update import create_object
from django.contrib import admin
from django.views.generic.list_detail import object_list
admin.autodiscover()
urlpatterns = patterns('',
@ -14,8 +15,8 @@ urlpatterns = patterns('',
url(r'^$', views_other.frontpage, name="frontpage"),
url(r'^todo/$', views_other.todo, name="todo"),
url(r'^caveindex/?$', views_caves.caveindex, name="caveindex"),
url(r'^personindex$', views_logbooks.personindex, name="personindex"),
url(r'^caves/?$', views_caves.caveindex, name="caveindex"),
url(r'^people/?$', views_logbooks.personindex, name="personindex"),
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person),
@ -23,6 +24,7 @@ urlpatterns = patterns('',
#url(r'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"),
url(r'^expeditions/?$', object_list, {'queryset':Expedition.objects.all(),'template_name':'expeditions.html'},name="expeditionlist"),
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/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),