コード例 #1
0
def register_admin(cls, list_display=None):
    from django.contrib.admin.sites import site as default_site

    model_fields = get_model_fields_for_admin(cls)

    class CustomAdmin(MyAdmin):
        list_display = model_fields

    default_site.register(cls, admin_class=CustomAdmin)

    return cls
コード例 #2
0
ファイル: apps.py プロジェクト: dldevinc/paper-uploads
    def ready(self):
        from .signals import handlers
        from .models.collection import CollectionBase
        from .admin import CollectionAdminBase

        # Переименование поля файла или модели-владельца файла,
        # изменит также и соответствующие значения, хранящиеся в БД
        pre_migrate.connect(handlers.inject_rename_filefield_operations, sender=self)

        # автоматическая регистрация моделей галерей в админке
        for model in apps.get_models():
            if issubclass(model, CollectionBase) and not site.is_registered(model):
                site.register(model, CollectionAdminBase)
コード例 #3
0
        'id',
        'name',
        'undergrad',
        'views',
        'timestamp',
        'public',
    )
    list_display_links = ('id', )
    list_editable = (
        'name',
        'undergrad',
        'public',
    )
    list_filter = (
        'undergrad',
        'public',
    )
    search_fields = (
        'name',
        'description',
    )
    filter_horizontal = (
        'coordinators',
        'people',
        'r',
    )
    prepopulated_fields = {'slug': ('name', )}


site.register(Laboratory, LaboratoryAdmin)
コード例 #4
0
from django.contrib import admin, messages
from django.http import (HttpResponseRedirect, HttpResponse)

from canada_post.api import CanadaPostAPI
from canada_post_dp_shipping.models import (Box, OrderShippingService,
                                            ParcelDescription, ShipmentLink,
                                            Shipment)

from livesettings.functions import config_get_group

class BoxAdmin(admin.ModelAdmin):
    """
    Admin for Box model
    """
    list_display = ['__unicode__', 'girth', 'volume']
site.register(Box, BoxAdmin)

class LinkInline(admin.StackedInline):
    model = ShipmentLink
    readonly_fields = ['type', 'data']
    extra = 0

class ShipmentAdmin(admin.ModelAdmin):
    inlines = [LinkInline]
site.register(Shipment, ShipmentAdmin)

class ShipmentInline(admin.StackedInline):
    model = Shipment
    extra = 0

class ParcelAdmin(admin.ModelAdmin):
コード例 #5
0
ファイル: admin.py プロジェクト: NouryG/pychronia
from django.contrib.admin.sites import site
from models import JPlayer, Song, Artist, Credits

site.register(JPlayer)
site.register(Song)
site.register(Artist)
site.register(Credits)
コード例 #6
0
from django.contrib.admin.sites import site
from django.contrib.admin.options import ModelAdmin
from .models import Image, Tag


class ImageAdmin(ModelAdmin):
    prepopulated_fields = {'slug': ('title', )}
    list_display = ['title', 'slug', 'image', 'created', 'shooted']
    readonly_fields = ('created', )
    list_filter = ['created']


class TagAdmin(ModelAdmin):
    prepopulated_fields = {'slug': ('name', )}
    list_display = ('name', 'slug', 'slen')


site.register(Image, ImageAdmin)
site.register(Tag, TagAdmin)
コード例 #7
0
ファイル: admin.py プロジェクト: pombredanne/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from reviews.models import Review
from django.core.urlresolvers import reverse


class ReviewAdmin(ModelAdmin):
    def resource_link(self):
        content_type = self.content_type
        obj = content_type.model_class().objects.get(id=self.object_id)
        admin_url = reverse("admin:%s_%s_change" % (content_type.app_label, content_type.model), args=(self.object_id,))
        return """<a href="%s" target="_blank">on site</a> | <a href="%s" target="_blank">in admin</a>""" % (
            obj.get_absolute_url(),
            admin_url,
        )

    resource_link.allow_tags = True
    resource_link.short_description = u"View resource"

    list_display = ["__unicode__", resource_link, "timestamp"]
    readonly_fields = ["user", "content_type", "object_id"]

    def has_add_permission(self, request):
        return False


site.register(Review, ReviewAdmin)
コード例 #8
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from slider.models import Slide


class SlideAdmin(ModelAdmin):

    list_display = ["title", "microsite", "order"]
    list_editable = ["order"]


site.register(Slide, SlideAdmin)
コード例 #9
0
            'admin/tinymce/tinymce.min.js',
            'admin/tinymce/tinymce_init.js',
        )

    list_display = (
        'id',
        'name',
        'url',
        'timestamp',
        'public',
    )
    list_display_links = ('id', )
    list_editable = (
        'name',
        'url',
        'public',
    )
    list_filter = ('public', )
    search_fields = (
        'name',
        'description',
    )
    filter_horizontal = (
        'coordinators',
        'people',
    )
    prepopulated_fields = {'slug': ('name', )}


site.register(Project, ProjectAdmin)
コード例 #10
0
ファイル: admin.py プロジェクト: Hepri/django-enumfields
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.contrib import admin
from .models import MyModel
from django.contrib.admin.sites import AdminSite, site

class MyModelAdmin(admin.ModelAdmin):
    model = MyModel

site.register(MyModel, MyModelAdmin)
コード例 #11
0
ファイル: admin.py プロジェクト: euangoddard/eric
class InviteAdmin(ModelAdmin):
    
    list_display = ("key", "email", "invitees")
    
    inlines = (InviteeInlineAdmin, )
    
    def invitees(self, invite):
        invitee_names = invite.invitees.values_list("name", flat=True)
        if invitee_names:
            label = u", ".join(invitee_names)
        else:
            label = u"(No invitees)"
        return label


class InviteeAdmin(ModelAdmin):
    
    list_display = (
        "invite",
        "name",
        "is_attending",
        "special_requirements",
    )
    
    list_filter = ("is_attending", )


site.register(Invite, InviteAdmin)
site.register(Invitee, InviteeAdmin)
コード例 #12
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from users.models import RegistrationConfirmation, Role


def user(obj):
    user = obj.user
    return "%s <%s>" % (user.username, user.email)


class RegistrationConfirmationAdmin(ModelAdmin):

    list_filter = ["confirmed", ]
    list_display = [user, "key", "timestamp", "confirmed", ]
    readonly_fields = ["user", "key", "timestamp", "confirmed"]

    def has_add_permission(self, request):
        return False


site.register(RegistrationConfirmation, RegistrationConfirmationAdmin)
site.register(Role, ModelAdmin)
コード例 #13
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
# -*- coding: utf-8 -*-
"""
	DCAE - About - Admin:
		AboutAdmin

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site

from singletons.admin import SingletonAdmin
from reversion import VersionAdmin

from .models import About


class AboutAdmin(SingletonAdmin, VersionAdmin):
    # tinymce for textareas
    class Media:
        js = (
            'admin/tinymce/tinymce.min.js',
            'admin/tinymce/tinymce_init.js',
        )


site.register(About, AboutAdmin)
コード例 #14
0
    list_editable = (
        'faculty',
        'alumnus',
        'public',
    )
    list_filter = (
        'r',
        'alumnus',
        'public',
    )
    search_fields = (
        'first_name',
        'name',
        'degrees',
        'experience',
        'activity',
        'notes',
    )
    filter_horizontal = (
        'coordinator',
        'coord_bachelor',
        'coord_msc',
        'coord_phd',
        'rm',
    )
    prepopulated_fields = {'slug': ('name', )}


site.register(Role, RoleAdmin)
site.register(Member, MemberAdmin)
コード例 #15
0
ファイル: admin.py プロジェクト: depaolim/django_smart_raw_id
from django.contrib.admin import ModelAdmin
from django.contrib.admin.sites import site as admin_site

from smart_raw_id import SmartRawIdMixin

from .models import *


class ProductAdmin(ModelAdmin):
    pass


class SingleSaleAdmin(SmartRawIdMixin, ModelAdmin):
    list_display = ('id', 'product', 'price')
    raw_id_fields = ('product', )


class StockSaleAdmin(SmartRawIdMixin, ModelAdmin):
    list_display = ('id', 'price')
    raw_id_fields = ('products', )


admin_site.register(Product, ProductAdmin)
admin_site.register(SingleSale, SingleSaleAdmin)
admin_site.register(StockSale, StockSaleAdmin)
コード例 #16
0
ファイル: admin.py プロジェクト: ddahan/mailator-backend
from django.contrib import admin
from django.contrib.admin.sites import site

from core.models import *

site.register(Organization)
site.register(FieldValue)
site.register(LetterType)
site.register(Letter)
site.register(Field)
site.register(Dispatch)
site.register(Attachment)
コード例 #17
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
#-*- coding: utf-8 -*-
"""
	DCAE - Courses - Admin:
		CourseAdmin

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site
from reversion import VersionAdmin

from .models import Course

class CourseAdmin(VersionAdmin):
	class Media:
		js = (
			'admin/tinymce/tinymce.min.js',
			'admin/tinymce/tinymce_init.js',
		)

	list_display = ('id', 'name', 'undergrad', 'views', 'timestamp', 'public',)
	list_display_links = ('id',)
	list_editable = ('name', 'undergrad', 'public',)
	list_filter = ('undergrad', 'public',)
	search_fields = ('name', 'description',)
	filter_horizontal = ('coordinators', 'people','r',)
	prepopulated_fields = {'slug': ('name',)}


site.register(Course, CourseAdmin)
コード例 #18
0
ファイル: admin.py プロジェクト: dunjian/django-weixin
#!coding:utf-8
__author__ = 'akun'
from django.contrib.admin.sites import site
from .models import *


site.register(Entry)
site.register(Blog)
コード例 #19
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from curriculum.models import Standard, LearningObjectiveCategory, \
    AlignmentTag
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site


site.register(Standard, ModelAdmin)
site.register(LearningObjectiveCategory, ModelAdmin)
site.register(AlignmentTag, ModelAdmin)
コード例 #20
0
ファイル: __init__.py プロジェクト: colinbdclark/OER-Commons
from django import forms
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from materials.admin.community_item import CommunityItemAdmin
from materials.admin.course import CourseAdmin
from materials.admin.library import LibraryAdmin
from materials.models import Course, Library, CommunityItem
from materials.models.common import GeneralSubject,\
    Language, GeographicRelevance, Keyword, Author, Collection
from materials.models.community import CommunityType, CommunityTopic
from materials.models.course import CourseMaterialType
from materials.models.library import LibraryMaterialType
from materials.models.microsite import Microsite, Topic


site.register(GeneralSubject, ModelAdmin)
site.register(Language, ModelAdmin)
site.register(CourseMaterialType, ModelAdmin)
site.register(LibraryMaterialType, ModelAdmin)
site.register(CommunityType, ModelAdmin)
site.register(CommunityTopic, ModelAdmin)
site.register(GeographicRelevance, ModelAdmin)
site.register(Keyword, ModelAdmin)
site.register(Author, ModelAdmin)

site.register(Course, CourseAdmin)
site.register(Library, LibraryAdmin)
site.register(CommunityItem, CommunityItemAdmin)


class MicrositeForm(forms.ModelForm):
コード例 #21
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
        'id',
        'title',
        'evsdate',
        'evedate',
        'date',
        'expdate',
        'public',
    )
    list_display_links = ('id', )
    list_editable = (
        'title',
        'evsdate',
        'evedate',
        'date',
        'expdate',
        'public',
    )
    list_filter = ('public', )
    list_per_page = 20
    search_fields = (
        'title',
        'subtitle',
        'summary',
        'text',
    )

    prepopulated_fields = {'slug': ('title', )}


site.register(Announcement, AnnouncementAdmin)
コード例 #22
0
from canada_post.api import CanadaPostAPI
from canada_post_dp_shipping.models import (Box, OrderShippingService,
                                            ParcelDescription, ShipmentLink,
                                            Shipment, Manifest, ManifestLink)

from livesettings.functions import config_get_group

log = logging.getLogger("canada_post_dp_shipping.admin")

class BoxAdmin(admin.ModelAdmin):
    """
    Admin for Box model
    """
    list_display = ['__unicode__', 'girth', 'volume']
site.register(Box, BoxAdmin)

class LinkInline(admin.StackedInline):
    model = ShipmentLink
    readonly_fields = ['type', 'data']
    extra = 0

#class ShipmentAdmin(admin.ModelAdmin):
#    inlines = [LinkInline]
#    readonly_fields = ['parcel', ]
#site.register(Shipment, ShipmentAdmin)

class ShipmentInline(admin.StackedInline):
    model = Shipment
    extra = 0
コード例 #23
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from geo.models import Country, CountryIPDiapason, USState


site.register(Country, ModelAdmin)
site.register(USState, ModelAdmin)
site.register(CountryIPDiapason, ModelAdmin)
コード例 #24
0
ファイル: admin.py プロジェクト: T045T/loskoch_hackathon2012
from django.contrib.admin.sites import site

from core.models import Flatshare, PersonProfile

for model in [Flatshare, PersonProfile]:
    site.register(model)
コード例 #25
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from reports.models import Report


def download_link(obj):
    return """<a href="%s">Download</a>""" % obj.file.url
download_link.allow_tags = True


class ReportAdmin(ModelAdmin):


    list_display = ["__unicode__", download_link]
    list_filters = ["type"]

    def has_add_permission(self, request):
        return False

    def has_edit_permission(self, request):
        return False

site.register(Report, ReportAdmin)
コード例 #26
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
from django.contrib.admin.options import ModelAdmin
from django.contrib.admin.sites import site
from feedback.models import FeedbackMessage


class FeedbackMessageAdmin(ModelAdmin):

    list_display = ["subject", "type", "name", "email", "spam", "timestamp"]
    list_filter = ["type", "spam", "timestamp"]
    readonly_fields = ["name", "email", "type", "subject", "text", "timestamp"]


site.register(FeedbackMessage, FeedbackMessageAdmin)
コード例 #27
0
ファイル: admin.py プロジェクト: ddahan/mailator-backend
from django.contrib import admin
from django.contrib.admin.sites import site
from django.contrib.auth import get_user_model

from profiles.models import Customer

User = get_user_model()

# Register your models here.
site.register(User)
site.register(Customer)
コード例 #28
0
ファイル: admin.py プロジェクト: fepa/sparvnastet
from django.contrib import admin
from sparvnastet.apps.pages.models import Page, Category

__author__ = 'mathias'

from django.contrib.admin.sites import site

class PageAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug' : ('title', )}

site.register(Page, PageAdmin)
site.register(Category)
コード例 #29
0
        """
        以只读方式查看记录
        """
        entry = self.model.objects.get(pk=int(object_id))
        return HttpResponse("%s" % entry.content)

    def body_btn(self, model):
        """
        为存在body数据的记录添加查看按钮
        """
        meta = getattr(self.model, "_meta")
        info = meta.app_label, meta.model_name
        body = model.body
        ret = body and mark_safe(
            "<a href={path} >查看</a>".format(path=reverse_lazy(
                "admin:%s_%s_body" %
                info, args=(model.pk, ), kwargs={}))) or u""
        return ret

    body_btn.short_description = mark_safe(u"body")
    body_btn.allow_tags = True

    def change_view(self, request, object_id, form_url='', extra_context=None):
        """
        重写“修改”视图为只读
        """
        return self.readonly_view(request, object_id, extra_context)


site.register(Entry, EntryAdmin)
コード例 #30
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site
from reversion import VersionAdmin

from .models import Room


class RoomAdmin(VersionAdmin):
    list_display = (
        'id',
        'name',
        'timestamp',
        'public',
    )
    list_display_links = ('id', )
    list_editable = (
        'name',
        'public',
    )
    list_filter = ('public', )
    search_fields = (
        'name',
        'description',
    )
    prepopulated_fields = {'slug': ('name', )}


site.register(Room, RoomAdmin)
コード例 #31
0
ファイル: admin.py プロジェクト: dunjian/django-weixin
    def readonly_view(self, request, object_id, extra_context=None):
        """
        以只读方式查看记录
        """
        entry = self.model.objects.get(pk=int(object_id))
        return HttpResponse("%s" % entry.content)

    def body_btn(self, model):
        """
        为存在body数据的记录添加查看按钮
        """
        meta = getattr(self.model, "_meta")
        info = meta.app_label, meta.model_name
        body = model.body
        ret = body and mark_safe("<a href={path} >查看</a>".format(
            path=reverse_lazy("admin:%s_%s_body" % info, args=(model.pk, ), kwargs={})
        )) or u""
        return ret
    body_btn.short_description = mark_safe(u"body")
    body_btn.allow_tags = True

    def change_view(self, request, object_id, form_url='', extra_context=None):
        """
        重写“修改”视图为只读
        """
        return self.readonly_view(request, object_id, extra_context)


site.register(Entry, EntryAdmin)
コード例 #32
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
#-*- coding: utf-8 -*-
"""
	DCAE - Menu - Admin:
		MenuAdmin, MenuItem Inline

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin import StackedInline
from django.contrib.admin.sites import site

from singletons.admin import SingletonAdmin
from reversion import VersionAdmin

from .models import Menu, MenuItem


class MenuItemInline(StackedInline):
    model = MenuItem
    extra = 1
    max_num = 100
    classes = ('collapse closed', )
    inline_classes = ('collapse open', )


class MenuAdmin(SingletonAdmin, VersionAdmin):
    inlines = [MenuItemInline]


site.register(Menu, MenuAdmin)
コード例 #33
0
ファイル: models.py プロジェクト: density215/d215-miniblog
from django.contrib.admin.sites import site
from django.contrib.auth.models import User
from django.db import models
from django.template import defaultfilters
from django.utils.datetime_safe import date
from unidecode import unidecode


class Entry(models.Model):

    # Blog entry fields
    headline = models.CharField("Blog entry title", max_length=200)
    body = models.TextField("Blog Content")
    publishdate = models.DateField("Blog entry publishing date", default=date.today())
    publish = models.BooleanField("Publish Blog entry", default=False)

    # Meta data
    slug = models.SlugField(editable=False)  # the future
    author = models.ForeignKey(User, editable=False)
    created = models.DateTimeField(editable=False, auto_now_add=True)
    updated = models.DateTimeField(editable=False, auto_now=True)

    def save(self, force_insert=False, force_update=False, *args, **kwargs):
        self.slug = defaultfilters.slugify(unidecode(self.headline))[:50]
        super(Entry, self).save(force_insert=True)


# admin stuff
site.register(Entry)
コード例 #34
0
ファイル: admin.py プロジェクト: colinbdclark/OER-Commons
        """
        Given a model instance save it to the database.
        """
        if not obj.pk:
            obj.save()
        obj.refresh()
        obj.save()

    def get_urls(self):
        urls = patterns("",
            url("^(\d+)/harvest/$", self.admin_site.admin_view(add_job), name="harvester_add_job"),
        )
        return urls + super(RepositoryAdmin, self).get_urls()


site.register(Repository, RepositoryAdmin)


class JobAdmin(ModelAdmin):

    def status(self):
        status = self.get_status_display()
        if self.status == ERROR:
            status = u"""<a href="%s">%s (%i)</a>""" % (reverse("admin:harvester_job_errors", args=(self.id,)),
                                                          status,
                                                          self.errors.count())
        if self.status in (COMPLETE, ERROR, NO_RECORDS_MATCH, None):
            if status is None:
                status = u""
            status += u""" - <a href="%s">restart</a>""" % reverse("admin:harvester_job_restart", args=(self.id,))
        return status
コード例 #35
0
ファイル: admin.py プロジェクト: Hamdy/pictureme
from models import Photo
from django.contrib.admin.sites import site

site.register(Photo)
コード例 #36
0
from django.contrib.admin.sites import site
from .models import JPlayer, Song, Artist, Credits

site.register(JPlayer)
site.register(Song)
site.register(Artist)
site.register(Credits)
コード例 #37
0
from django.contrib import admin
from django.contrib.admin.sites import site
from Estudiantes.models import Estudiantes


class EstudiantesAdmin(admin.ModelAdmin):
    list_display = ("usuario", "cedula", "cert_votacion", "sexo")
    search_fields = ["cedula"]
    list_filter = ["cedula"]


site.register(Estudiantes, EstudiantesAdmin)
コード例 #38
0
ファイル: admin.py プロジェクト: klishin16/peer-review-system
    add_fieldsets = (
        (None, {
            'fields': ('email', 'password1', 'password2')
        }),
        ('Personal info', {
            'fields': ('name', 'surname', 'birth_date')
        }),
        ('Status', {
            'fields': ('is_teacher', )
        }),
    )

    search_fields = ('email', )
    ordering = ('email', )
    filter_horizontal = ()


class StudentProfileAdmin(admin.ModelAdmin):
    list_display = ['id', 'user', 'student_class']


class TeacherProfileAdmin(admin.ModelAdmin):
    list_display = ['id', 'user']


admin.site.register(CustomUser, CustomUserAdmin)
admin, site.register(StudentProfile, StudentProfileAdmin)
admin.site.register(TeacherProfile, TeacherProfileAdmin)

admin.site.unregister(Group)
コード例 #39
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
#-*- coding: utf-8 -*-
"""
	DCAE - Homepage - Admin:
		InfoAdmin

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site

from singletons.admin import SingletonAdmin
from reversion import VersionAdmin

from .models import Info


class InfoAdmin(SingletonAdmin, VersionAdmin):
    pass


site.register(Info, InfoAdmin)
コード例 #40
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
#-*- coding: utf-8 -*-
"""
	DCAE - Partners - Admin:
		PartnerAdmin

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site

from reversion import VersionAdmin

from .models import Partner


class PartnerAdmin(VersionAdmin):
	class Media:
		js = (
			'admin/tinymce/tinymce.min.js',
			'admin/tinymce/tinymce_init.js',
		)

	list_display = ('id', 'name', 'url', 'o', 'public',)
	list_display_links = ('id',)
	list_editable = ('url', 'o', 'public',)
	list_filter = ('public',)
	list_per_page = 20
	search_fields = ('name', 'description',)

site.register(Partner, PartnerAdmin)
コード例 #41
0
ファイル: admin.py プロジェクト: stefan-stanusi/dcae-licenta
	DCAE - Publications - Admin:
		GenreAdmin, PublicationAdmin

	@author: mijomir mecu <*****@*****.**>
"""
from django.contrib.admin.sites import site
from reversion import VersionAdmin

from .models import Genre, Publication


class GenreAdmin(VersionAdmin):
	list_display = ('id', 'name', 'timestamp',)
	list_display_links = ('id',)
	list_editable = ('name', )
	search_fields = ('name', 'description',)


class PublicationAdmin(VersionAdmin):
	list_display = ('id', 'gen', 'title', 'year', 'timestamp', 'public')
	list_display_links = ('id',)
	list_editable = ('public',)
	list_filter = ('gen', 'public',)
	search_fields = ('title', 'oauthors', 'publisher', 'city', 'review',
		'conference', 'other', 'abstract',)
	filter_horizontal = ('authors',)


site.register(Genre, GenreAdmin)
site.register(Publication, PublicationAdmin)
コード例 #42
0
ファイル: admin.py プロジェクト: ddavila92/prysindicato
from django.contrib.admin.sites import site
from Nota.models import Nota
from django.contrib import admin


class NotaAdmin(admin.ModelAdmin):
    list_display = ("materia", "estudiante", "deber", "actuacion", "leccion",
                    "examen", "supletorio")


site.register(Nota, NotaAdmin)
コード例 #43
0
ファイル: admin.py プロジェクト: dunjian/django-weixin
#!coding:utf-8
__author__ = 'akun'
from django.contrib.admin.sites import site
from .models import *

site.register(Entry)
site.register(Blog)
コード例 #44
0
from django.contrib import admin
from django.contrib.admin.sites import site

from .models import User, Todo

# Register your models here.


class UserAdmin(admin.ModelAdmin):
    list_display = ['email', 'first_name', 'last_name']


class TodoAdmin(admin.ModelAdmin):
    list_display = ['title', 'creator']


site.register(Todo, TodoAdmin)
site.register(User, UserAdmin)
コード例 #45
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.contrib import admin
from .models import MyModel
from django.contrib.admin.sites import AdminSite, site


class MyModelAdmin(admin.ModelAdmin):
    model = MyModel


site.register(MyModel, MyModelAdmin)
コード例 #46
0
ファイル: admin.py プロジェクト: pombredanne/OER-Commons
        """
        Given a model instance save it to the database.
        """
        if not obj.pk:
            obj.save()
        obj.refresh()
        obj.save()

    def get_urls(self):
        urls = patterns("",
            url("^(\d+)/harvest/$", self.admin_site.admin_view(add_job), name="harvester_add_job"),
        )
        return urls + super(RepositoryAdmin, self).get_urls()


site.register(Repository, RepositoryAdmin)


class JobAdmin(ModelAdmin):

    def status(self):
        status = self.get_status_display()
        if self.status == ERROR:
            status = u"""<a href="%s">%s (%i)</a>""" % (reverse("admin:harvester_job_errors", args=(self.id,)),
                                                          status,
                                                          self.errors.count())
        if self.status in (COMPLETE, ERROR, NO_RECORDS_MATCH, None):
            if status is None:
                status = u""
            status += u""" - <a href="%s">restart</a>""" % reverse("admin:harvester_job_restart", args=(self.id,))
        return status
コード例 #47
0
from django.contrib.admin.sites import site
from recipes.models import Recipe

site.register(Recipe)