troggle-unchained/expo/admin.py
substantialnoninfringinguser 625b2156e3 [svn] Weeks of local changes.
- Import is now non-destructive
- Parsers write output to a log file (path be specified in settings)
- databaseReset.py content been divided into separate functions which can be called for varying levels of deletion and importing
- control panel (view, template, urlpattern) added for deleting and importing
- Logins and signup fixed
- CaveArea model updated, view, hierarchical url patterns, and beginning of template added
- New site style
Copied from http://cucc@cucc.survex.com/svn/trunk/expoweb/troggle/, rev. 8324 by cucc @ 5/3/2009 5:56 AM
2009-05-13 06:15:48 +01:00

93 lines
2.7 KiB
Python

from troggle.expo.models import *
from django.contrib import admin
from django.forms import ModelForm
import django.forms as forms
from expo.forms import LogbookEntryForm
#from troggle.reversion.admin import VersionAdmin #django-reversion version control
#overriding admin save so we have the new since parsing field
class TroggleModelAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.new_since_parsing=True
obj.save()
class RoleInline(admin.TabularInline):
model = PersonRole
extra = 4
class SurvexBlockAdmin(TroggleModelAdmin):
inlines = (RoleInline,)
class ScannedImageInline(admin.TabularInline):
model = ScannedImage
extra = 4
class SurveyAdmin(TroggleModelAdmin):
inlines = (ScannedImageInline,)
class QMInline(admin.TabularInline):
model=QM
extra = 4
class PhotoInline(admin.TabularInline):
model = Photo
exclude = ['is_mugshot', ]
extra = 1
class PersonTripInline(admin.TabularInline):
model = PersonTrip
exclude = ['persontrip_next','Delete']
extra = 1
#class LogbookEntryAdmin(VersionAdmin):
class LogbookEntryAdmin(TroggleModelAdmin):
prepopulated_fields = {'slug':("title",)}
search_fields = ('title','expedition__year')
inlines = (PersonTripInline, PhotoInline)
form = LogbookEntryForm
#inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround
class PersonExpeditionInline(admin.TabularInline):
model = PersonExpedition
extra = 1
class PersonAdmin(TroggleModelAdmin):
search_fields = ('first_name','last_name')
inlines = (PersonExpeditionInline,)
class QMAdmin(TroggleModelAdmin):
search_fields = ('found_by__cave__kataster_number','number')
class PersonExpeditionAdmin(TroggleModelAdmin):
search_fields = ('person__first_name','expedition__year')
class CaveAdmin(TroggleModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number')
#inlines = (QMInline,)
extra = 4
admin.site.register(Photo)
admin.site.register(Subcave)
admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
admin.site.register(OtherCaveName)
admin.site.register(CaveAndEntrance)
admin.site.register(SurveyStation)
admin.site.register(Entrance)
admin.site.register(SurvexBlock, SurvexBlockAdmin)
admin.site.register(Expedition)
admin.site.register(Person,PersonAdmin)
admin.site.register(PersonRole)
admin.site.register(PersonExpedition,PersonExpeditionAdmin)
admin.site.register(Role)
admin.site.register(LogbookEntry, LogbookEntryAdmin)
admin.site.register(PersonTrip)
admin.site.register(QM, QMAdmin)
admin.site.register(Survey, SurveyAdmin)
admin.site.register(ScannedImage)