2009-05-13 05:13:38 +01:00
|
|
|
from troggle.expo.models import *
|
|
|
|
from django.contrib import admin
|
2009-05-13 06:08:04 +01:00
|
|
|
from django.forms import ModelForm
|
|
|
|
import django.forms as forms
|
2009-05-13 06:13:31 +01:00
|
|
|
from expo.forms import LogbookEntryForm
|
2009-05-13 05:55:00 +01:00
|
|
|
#from troggle.reversion.admin import VersionAdmin #django-reversion version control
|
2009-05-13 05:13:38 +01:00
|
|
|
|
2009-05-13 05:21:27 +01:00
|
|
|
class RoleInline(admin.TabularInline):
|
|
|
|
model = PersonRole
|
|
|
|
extra = 4
|
|
|
|
|
|
|
|
class SurvexBlockAdmin(admin.ModelAdmin):
|
|
|
|
inlines = (RoleInline,)
|
|
|
|
|
2009-05-13 05:31:44 +01:00
|
|
|
class ScannedImageInline(admin.TabularInline):
|
2009-05-13 05:27:43 +01:00
|
|
|
model = ScannedImage
|
|
|
|
extra = 4
|
|
|
|
|
|
|
|
class SurveyAdmin(admin.ModelAdmin):
|
2009-05-13 05:31:44 +01:00
|
|
|
inlines = (ScannedImageInline,)
|
|
|
|
|
2009-05-13 06:08:04 +01:00
|
|
|
class QMInline(admin.TabularInline):
|
|
|
|
model=QM
|
|
|
|
extra = 4
|
|
|
|
|
2009-05-13 06:13:31 +01:00
|
|
|
class PhotoInline(admin.TabularInline):
|
|
|
|
model = Photo
|
|
|
|
exclude = ['is_mugshot', ]
|
|
|
|
extra = 1
|
|
|
|
|
|
|
|
class PersonTripInline(admin.TabularInline):
|
|
|
|
model = PersonTrip
|
|
|
|
exclude = ['persontrip_next','Delete']
|
|
|
|
extra = 1
|
|
|
|
|
2009-05-13 05:55:00 +01:00
|
|
|
#class LogbookEntryAdmin(VersionAdmin):
|
2009-05-13 05:31:44 +01:00
|
|
|
class LogbookEntryAdmin(admin.ModelAdmin):
|
2009-05-13 06:09:55 +01:00
|
|
|
prepopulated_fields = {'slug':("title",)}
|
2009-05-13 05:40:56 +01:00
|
|
|
search_fields = ('title','expedition__year')
|
2009-05-13 06:13:31 +01:00
|
|
|
inlines = (PersonTripInline, PhotoInline)
|
|
|
|
form = LogbookEntryForm
|
2009-05-13 06:08:04 +01:00
|
|
|
#inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround
|
2009-05-13 05:27:43 +01:00
|
|
|
|
2009-05-13 05:48:10 +01:00
|
|
|
class PersonExpeditionInline(admin.TabularInline):
|
|
|
|
model = PersonExpedition
|
|
|
|
extra = 1
|
2009-05-13 06:13:31 +01:00
|
|
|
|
|
|
|
|
2009-05-13 05:48:10 +01:00
|
|
|
|
2009-05-13 05:35:29 +01:00
|
|
|
class PersonAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ('first_name','last_name')
|
2009-05-13 05:48:10 +01:00
|
|
|
inlines = (PersonExpeditionInline,)
|
2009-05-13 06:02:04 +01:00
|
|
|
|
|
|
|
class QMAdmin(admin.ModelAdmin):
|
2009-05-13 06:08:04 +01:00
|
|
|
search_fields = ('found_by__cave__kataster_number','number')
|
2009-05-13 06:02:04 +01:00
|
|
|
def save_model(self, request, obj, form, change):
|
|
|
|
obj.new_since_parsing=True
|
|
|
|
obj.save()
|
2009-05-13 06:08:04 +01:00
|
|
|
|
2009-05-13 05:35:29 +01:00
|
|
|
class PersonExpeditionAdmin(admin.ModelAdmin):
|
2009-05-13 05:40:56 +01:00
|
|
|
search_fields = ('person__first_name','expedition__year')
|
2009-05-13 05:35:29 +01:00
|
|
|
|
2009-05-13 05:52:15 +01:00
|
|
|
class CaveAdmin(admin.ModelAdmin):
|
|
|
|
search_fields = ('official_name','kataster_number','unofficial_number')
|
2009-05-13 06:08:04 +01:00
|
|
|
#inlines = (QMInline,)
|
2009-05-13 05:52:15 +01:00
|
|
|
extra = 4
|
|
|
|
|
2009-05-13 06:02:04 +01:00
|
|
|
|
|
|
|
|
2009-05-13 05:25:17 +01:00
|
|
|
admin.site.register(Photo)
|
2009-05-13 05:52:15 +01:00
|
|
|
admin.site.register(Cave, CaveAdmin)
|
2009-05-13 05:13:38 +01:00
|
|
|
admin.site.register(Area)
|
|
|
|
admin.site.register(OtherCaveName)
|
|
|
|
admin.site.register(CaveAndEntrance)
|
|
|
|
admin.site.register(SurveyStation)
|
|
|
|
admin.site.register(Entrance)
|
2009-05-13 05:21:27 +01:00
|
|
|
admin.site.register(SurvexBlock, SurvexBlockAdmin)
|
2009-05-13 05:13:38 +01:00
|
|
|
admin.site.register(Expedition)
|
2009-05-13 05:35:29 +01:00
|
|
|
admin.site.register(Person,PersonAdmin)
|
2009-05-13 05:21:27 +01:00
|
|
|
admin.site.register(PersonRole)
|
2009-05-13 05:35:29 +01:00
|
|
|
admin.site.register(PersonExpedition,PersonExpeditionAdmin)
|
2009-05-13 05:21:27 +01:00
|
|
|
admin.site.register(Role)
|
2009-05-13 05:31:44 +01:00
|
|
|
admin.site.register(LogbookEntry, LogbookEntryAdmin)
|
2009-05-13 05:13:38 +01:00
|
|
|
admin.site.register(PersonTrip)
|
2009-05-13 06:08:04 +01:00
|
|
|
admin.site.register(QM, QMAdmin)
|
2009-05-13 05:27:43 +01:00
|
|
|
admin.site.register(Survey, SurveyAdmin)
|
|
|
|
admin.site.register(ScannedImage)
|
2009-05-13 05:25:17 +01:00
|
|
|
|