2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-29 13:21:54 +00:00

[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 118d132797
commit d8a215a575
6 changed files with 40 additions and 19 deletions

View File

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

View File

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

View File

@ -17,8 +17,11 @@ from models_survex import *
class TroggleModel(models.Model): class TroggleModel(models.Model):
new_since_parsing = models.BooleanField(default=False, editable=False) new_since_parsing = models.BooleanField(default=False, editable=False)
def object_name(self):
return self._meta.object_name
def get_admin_url(self): 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: class Meta:
abstract = True abstract = True
@ -26,8 +29,11 @@ class TroggleModel(models.Model):
class TroggleImageModel(ImageModel): class TroggleImageModel(ImageModel):
new_since_parsing = models.BooleanField(default=False, editable=False) new_since_parsing = models.BooleanField(default=False, editable=False)
def object_name(self):
return self._meta.object_name
def get_admin_url(self): 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: class Meta:
abstract = True abstract = True
@ -42,7 +48,7 @@ class Expedition(TroggleModel):
return self.year return self.year
class Meta: class Meta:
ordering = ('year',) ordering = ('-year',)
get_latest_by = 'date_from' get_latest_by = 'date_from'
def get_absolute_url(self): def get_absolute_url(self):

View File

@ -1,3 +1,4 @@
from localsettings import *
import os import os
import urlparse import urlparse
# Django settings for troggle project. # Django settings for troggle project.
@ -35,11 +36,10 @@ USE_I18N = True
ADMIN_MEDIA_PREFIX = '/troggle/media-admin/' ADMIN_MEDIA_PREFIX = '/troggle/media-admin/'
PHOTOS_ROOT = os.path.join(EXPOWEB, 'photos') PHOTOS_ROOT = os.path.join(EXPOWEB, 'photos')
if URL_ROOT: MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/')
MEDIA_URL = urlparse.urljoin(URL_ROOT , '/site_media/') SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/')
SURVEYS_URL = urlparse.urljoin(URL_ROOT , '/survey_scans/') PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/')
PHOTOS_URL = urlparse.urljoin(URL_ROOT , '/photos/') SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/')
SVX_URL = urlparse.urljoin(URL_ROOT , '/survex/')
APPEND_SLASH = False APPEND_SLASH = False
SMART_APPEND_SLASH = True SMART_APPEND_SLASH = True
@ -87,5 +87,3 @@ INSTALLED_APPS = (
'troggle.expo', 'troggle.expo',
'troggle.imagekit', '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 expo.models import *
from django.views.generic.create_update import create_object from django.views.generic.create_update import create_object
from django.contrib import admin from django.contrib import admin
from django.views.generic.list_detail import object_list
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns('', urlpatterns = patterns('',
@ -14,8 +15,8 @@ urlpatterns = patterns('',
url(r'^$', views_other.frontpage, name="frontpage"), url(r'^$', views_other.frontpage, name="frontpage"),
url(r'^todo/$', views_other.todo, name="todo"), url(r'^todo/$', views_other.todo, name="todo"),
url(r'^caveindex/?$', views_caves.caveindex, name="caveindex"), url(r'^caves/?$', views_caves.caveindex, name="caveindex"),
url(r'^personindex$', views_logbooks.personindex, name="personindex"), url(r'^people/?$', views_logbooks.personindex, name="personindex"),
#(r'^person/(?P<person_id>\d*)/?$', views_logbooks.person), #(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'^person/(\w+_\w+)$', views_logbooks.person, name="person"),
url(r'^expedition/(\d+)$', views_logbooks.expedition, name="expedition"), 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'^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"), url(r'^logbookentry/(?P<date>.*)/(?P<slug>.*)/?$', views_logbooks.logbookentry,name="logbookentry"),