2020-07-31 14:55:26 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
''' Classes and modules for the administrative backend. '''
|
|
|
|
|
2020-07-19 00:13:49 +02:00
|
|
|
from django.contrib import admin
|
2020-07-28 20:15:34 +02:00
|
|
|
from django.contrib.auth import get_user_model
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
2020-09-14 17:26:17 +02:00
|
|
|
from lostplaces.models import *
|
2020-07-19 00:13:49 +02:00
|
|
|
|
2020-09-14 17:26:17 +02:00
|
|
|
from lostplaces.forms import ExplorerCreationForm, ExplorerChangeForm
|
2020-07-28 20:15:34 +02:00
|
|
|
|
2020-07-19 00:13:49 +02:00
|
|
|
# Register your models here.
|
|
|
|
|
2020-08-01 13:31:52 +02:00
|
|
|
class VoucherAdmin(admin.ModelAdmin):
|
2020-09-11 22:03:20 +02:00
|
|
|
fields = ['code', 'expires_when', 'created_when']
|
|
|
|
readonly_fields = ['created_when']
|
2020-09-18 21:03:05 +02:00
|
|
|
list_display = ('__str__', 'code', 'created_when', 'expires_when', 'valid')
|
2020-08-01 13:31:52 +02:00
|
|
|
|
2020-09-18 21:19:31 +02:00
|
|
|
def valid(self, instance):
|
|
|
|
return timezone.now() <= instance.expires_when
|
|
|
|
|
|
|
|
valid.boolean = True
|
|
|
|
|
2020-09-18 20:21:30 +02:00
|
|
|
class PhotoAlbumsAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('label', 'place', 'url' )
|
|
|
|
|
|
|
|
class PlacesAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'submitted_by', 'submitted_when')
|
|
|
|
|
2020-09-18 20:40:58 +02:00
|
|
|
class PlaceImagesAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('__str__', 'place', 'submitted_by')
|
|
|
|
|
2020-09-10 22:30:29 +02:00
|
|
|
admin.site.register(Explorer)
|
2020-08-01 13:31:52 +02:00
|
|
|
admin.site.register(Voucher, VoucherAdmin)
|
2020-09-18 20:21:30 +02:00
|
|
|
admin.site.register(Place, PlacesAdmin)
|
2020-09-18 20:40:58 +02:00
|
|
|
admin.site.register(PlaceImage, PlaceImagesAdmin)
|
2020-09-18 20:21:30 +02:00
|
|
|
admin.site.register(PhotoAlbum, PhotoAlbumsAdmin)
|