cciw-website / cciw / cciwmain / admin.py

from cciw.cciwmain.models import Site, Person, Camp, Forum, NewsItem, Topic, Gallery, Photo, Post, Poll, PollOption, MenuLink, HtmlChunk, Permission, Member, Award, PersonalAward, Message
from django.contrib import admin

class SiteAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {'fields': ('short_name', 'long_name', 'info')}),
    )

class PersonAdmin(admin.ModelAdmin):
    filter_horizontal = ('users',)

class CampAdmin(admin.ModelAdmin):
    fieldsets = (
        (None, {'fields': ('year', 'number', 'age', 'start_date', 'end_date',
                           'chaplain', 'leaders', 'site', 'previous_camp',
                           'online_applications', 'admins')
                }
        ),
    )
    ordering = ('-year','number')
    def leaders(camp):
        return camp.leaders_formatted
    list_display = ('year', 'number', leaders, 'chaplain', 'age', 'site', 'start_date')
    list_display_links = ('number', leaders)
    list_filter = ('age', 'site')
    filter_horizontal = ('leaders', 'admins')
    date_hierarchy = 'start_date'

class ForumAdmin(admin.ModelAdmin):
    pass

class NewsItemAdmin(admin.ModelAdmin):
    list_display = ('subject', 'created_at', 'created_by')

class TopicAdmin(admin.ModelAdmin):
    list_display = ('subject', 'started_by', 'created_at')
    search_fields = ('subject',)
    date_hierarchy = 'created_at'

class GalleryAdmin(admin.ModelAdmin):
    pass

class PhotoAdmin(admin.ModelAdmin):
    pass

class PostAdmin(admin.ModelAdmin):
    list_display = ('__unicode__', 'posted_by', 'posted_at')
    search_fields = ('message',)
    date_hierarchy = 'posted_at'

class PollOptionInline(admin.TabularInline):
    model = PollOption

class PollAdmin(admin.ModelAdmin):
    list_display = ('title', 'created_by', 'voting_starts')
    radio_fields = {'rules': admin.HORIZONTAL}
    inlines = [
        PollOptionInline,
        ]

class PollOptionAdmin(admin.ModelAdmin):
    list_display = ('text', 'poll')

class MenuLinkAdmin(admin.ModelAdmin):
    list_display = ('title', 'url', 'listorder','visible','parent_item')

class HtmlChunkAdmin(admin.ModelAdmin):
    list_display = ('name', 'page_title', 'menu_link')

class PermissionAdmin(admin.ModelAdmin):
    pass

class MemberAdmin(admin.ModelAdmin):
    search_fields = (
        'user_name', 'real_name', 'email'
    )
    list_display = (
        'user_name', 'real_name', 'email', 'date_joined', 'last_seen'
    )
    list_filter = (
        'dummy_member',
        'hidden',
        'banned',
        'moderated',
    )
    radio_fields = {'message_option': admin.HORIZONTAL}
    filter_horizontal = ('permissions',)

class AwardAdmin(admin.ModelAdmin):
    list_display = ('name', 'year')

class PersonalAwardAdmin(admin.ModelAdmin):
    list_display = ('award', 'member','reason', 'date_awarded')
    list_filter = ('award',)

class MessageAdmin(admin.ModelAdmin):
    list_display = ('to_member', 'from_member', 'time')

admin.site.register(Site, SiteAdmin)
admin.site.register(Person, PersonAdmin)
admin.site.register(Camp, CampAdmin)
admin.site.register(Forum, ForumAdmin)
admin.site.register(NewsItem, NewsItemAdmin)
admin.site.register(Topic, TopicAdmin)
admin.site.register(Gallery, GalleryAdmin)
admin.site.register(Photo, PhotoAdmin)
admin.site.register(Post, PostAdmin)
admin.site.register(Poll, PollAdmin)
admin.site.register(PollOption, PollOptionAdmin)
admin.site.register(MenuLink, MenuLinkAdmin)
admin.site.register(HtmlChunk, HtmlChunkAdmin)
admin.site.register(Permission, PermissionAdmin)
admin.site.register(Member, MemberAdmin)
admin.site.register(Award, AwardAdmin)
admin.site.register(PersonalAward, PersonalAwardAdmin)
admin.site.register(Message, MessageAdmin)

from django.contrib.auth import admin
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.