示例#1
0
        'name',
        'date',
        'slug',
    )

    ordering = ['-date']
    filter_horizontal = ()

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            form.text_initial = obj.text
            return form

    pass


register_model_admin(News, NewsAdmin)
示例#2
0
    add_fieldsets = (
        ('Gallery', {
            'fields': ('name', 'file')
        }),
        ('Gallery Photos', {
            'fields': ()
        }),
    )

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            return form

    pass


register_model_admin(Gallery, GalleryAdmin)
示例#3
0
        ('Event Description', {'fields': ('text', 'file')}),
        ('Location and Time', {'fields': ('date', 'address', 'geolocation')}),
    )

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (
            obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            form.text_initial = obj.text
            form.date_initial = obj.date
            form.address_initial = obj.address
            form.geolocation_initial = obj.geolocation
            return form

    pass


register_model_admin(Event, EventAdmin)
示例#4
0
        ('Page content', {'fields': ('text', 'file')})
    )

    add_fieldsets = (
        ('Page', {'fields': ('name',)}),
        ('Page content', {'fields': ('text', 'file')})
    )

    search_fields = ('author__first_name', 'author__last_name',
                     'name', 'date', 'slug',)

    ordering = ['-date']
    filter_horizontal = ()

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            form.text_initial = obj.text
            return form

    pass


register_model_admin(Post, PostAdmin)
示例#5
0
        ('School name', {'fields': ('name', 'type_school',)}),
        ('School Contact',
         {'fields': ('telephone', 'fax', 'email', 'website', 'file',)}),
        ('Location', {'fields': ('address', 'geolocation',)}),
    )

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (
            obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            form.address_initial = obj.address
            form.geolocation_initial = obj.geolocation
            return form

    pass


register_model_admin(School, SchoolAdmin)
示例#6
0
                     'subcategory', 'subject', 'author', 'date')

    ordering = ['date']
    filter_horizontal = ()

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            self.readonly_fields = self.add_readonly_fields
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            self.readonly_fields = self.change_readonly_fields
            form = self.change_form
            form.current_user = request.user
            form.text_initial = obj.text
            return form


register_model_admin(Subject, SubjectAdmin)
register_model_admin(SubjectPost, SubjectPostAdmin)
register_model_admin(Subcategory, SubcategoryAdmin)
示例#7
0
from django.contrib import admin

from editables.models import Editable
from utility.admin import register_model_admin


class EditableAdmin(admin.ModelAdmin):

    icon = '<i class="material-icons">content_cut</i>'
    list_display = ['editable_type']

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (
            obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'


register_model_admin(Editable, EditableAdmin)
示例#8
0
        'date',
        'type_registration',
        'text',
        'slug',
    )

    ordering = ['date']
    filter_horizontal = ()

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'

    def get_form(self, request, obj=None, **kwargs):
        if obj is None:
            self.fieldsets = self.add_fieldsets
            form = self.add_form
            form.current_user = request.user
            return form
        else:
            self.fieldsets = self.change_fieldsets
            form = self.change_form
            return form

    pass


register_model_admin(Registration, RegistrationAdmin)
示例#9
0
            form.current_user = request.user
            return form
        else:
            form = self.change_form
            form.order_initial = obj.order
            return form

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'


class SubcategoryAdmin(admin.ModelAdmin):
    icon = '<i class="material-icons">dashboard</i>'
    list_display = ['name', 'my_url_link']

    def my_url_link(self, obj):
        return '<a href="%s">%s</a>' % (obj.url_link, 'Access')

    my_url_link.allow_tags = True
    my_url_link.short_description = 'Link to page'


register_model_admin(Category, PageAdmin)
register_model_admin(Subcategory, SubcategoryAdmin)

register_model_admin(Article, ArticleAdmin)
register_model_admin(SimplePage, SimplePageAdmin)