2017-12-26 17:46:27 +01:00
|
|
|
from django.contrib import admin
|
2018-02-27 05:03:56 +01:00
|
|
|
from django.utils.safestring import mark_safe
|
2017-12-26 17:46:27 +01:00
|
|
|
|
|
|
|
# Register your models here.
|
|
|
|
from .models.locale import Language, Continent, Country, SPR, City
|
2018-02-27 05:03:56 +01:00
|
|
|
from .models.profiles import UserProfile, Organization, Team, Member, Category, Topic
|
2017-12-26 17:46:27 +01:00
|
|
|
from .models.search import Searchable
|
2018-03-17 22:37:56 +01:00
|
|
|
from .models.events import Place, Event, EventPhoto, Attendee
|
2017-12-26 17:46:27 +01:00
|
|
|
|
|
|
|
admin.site.register(Language)
|
|
|
|
admin.site.register(Continent)
|
|
|
|
admin.site.register(Country)
|
|
|
|
|
|
|
|
class SPRAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('country',)
|
2018-01-04 05:44:27 +01:00
|
|
|
list_filter =('country',)
|
|
|
|
search_fields = ('name', 'country__name')
|
2017-12-26 17:46:27 +01:00
|
|
|
admin.site.register(SPR, SPRAdmin)
|
|
|
|
|
|
|
|
class CityAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('spr',)
|
2018-01-04 05:44:27 +01:00
|
|
|
list_filter =('spr__country',)
|
|
|
|
search_fields = ('name', 'spr__name')
|
2017-12-26 17:46:27 +01:00
|
|
|
admin.site.register(City, CityAdmin)
|
|
|
|
|
2018-01-27 03:06:33 +01:00
|
|
|
class ProfileAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('user', 'realname', 'avatar', 'web_url')
|
|
|
|
admin.site.register(UserProfile, ProfileAdmin)
|
2018-01-04 05:44:27 +01:00
|
|
|
|
|
|
|
class OrgAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'site')
|
|
|
|
admin.site.register(Organization, OrgAdmin)
|
2017-12-26 17:46:27 +01:00
|
|
|
|
|
|
|
class TeamAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('country', 'spr', 'city', 'owner_profile', 'admin_profiles', 'contact_profiles')
|
2018-02-13 13:33:23 +01:00
|
|
|
list_display = ('__str__', 'member_count', 'owner_profile', 'created_date')
|
|
|
|
ordering = ('-created_date',)
|
|
|
|
def member_count(self, team):
|
|
|
|
return team.members.all().count()
|
|
|
|
member_count.short_description = 'Members'
|
2017-12-26 17:46:27 +01:00
|
|
|
admin.site.register(Team, TeamAdmin)
|
|
|
|
|
2018-02-15 02:01:43 +01:00
|
|
|
class SearchableAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('event_url', 'start_time', 'federation_node', 'federation_time')
|
|
|
|
list_filter = ('federation_node',)
|
|
|
|
ordering = ('-start_time',)
|
|
|
|
admin.site.register(Searchable, SearchableAdmin)
|
2017-12-26 17:46:27 +01:00
|
|
|
|
|
|
|
class PlaceAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('city',)
|
|
|
|
admin.site.register(Place, PlaceAdmin)
|
|
|
|
|
|
|
|
class EventAdmin(admin.ModelAdmin):
|
|
|
|
raw_id_fields = ('place', 'created_by')
|
2018-03-11 08:19:44 +01:00
|
|
|
list_display = ('__str__', 'attendee_count', 'start_time', 'created_by', 'created_time')
|
|
|
|
ordering = ('-start_time',)
|
2018-02-13 13:33:23 +01:00
|
|
|
def attendee_count(self, event):
|
|
|
|
return event.attendees.all().count()
|
|
|
|
attendee_count.short_description = 'Attendees'
|
2017-12-26 17:46:27 +01:00
|
|
|
admin.site.register(Event, EventAdmin)
|
|
|
|
|
2018-03-18 17:37:23 +01:00
|
|
|
class EventPhotoAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('title', 'event', 'view')
|
|
|
|
def view(self, photo):
|
|
|
|
return mark_safe('<a href="%s" target="_blank"><img src="%s" height="90px"></a>' % (photo.src.url, photo.thumbnail.url))
|
|
|
|
view.short_description = 'Photo'
|
|
|
|
admin.site.register(EventPhoto, EventPhotoAdmin)
|
2018-03-17 22:37:56 +01:00
|
|
|
|
2018-03-04 20:10:37 +01:00
|
|
|
class MemberAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('__str__', 'role')
|
|
|
|
list_filter = ('role', 'team')
|
|
|
|
admin.site.register(Member, MemberAdmin)
|
|
|
|
|
|
|
|
class AttendeeAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('__str__', 'role', 'status')
|
|
|
|
list_filter = ('role', 'status')
|
|
|
|
admin.site.register(Attendee, AttendeeAdmin)
|
2018-01-24 05:15:14 +01:00
|
|
|
|
2018-02-27 05:03:56 +01:00
|
|
|
class CategoryAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'image')
|
|
|
|
def image(self, obj):
|
|
|
|
return (mark_safe('<img src="%s" title="%s" height="64px" />' % (obj.img_url, obj.name)))
|
|
|
|
image.short_description = 'Image'
|
|
|
|
admin.site.register(Category, CategoryAdmin)
|
2017-12-26 17:46:27 +01:00
|
|
|
|
2018-02-27 05:03:56 +01:00
|
|
|
class TopicAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ('name', 'category')
|
|
|
|
list_filter = ('category',)
|