Ticket #6003: 00-admin-registration.diff

File 00-admin-registration.diff, 11.9 KB (added by Petr Marhoun <petr.marhoun@…>, 17 years ago)
  • django/conf/app_template/admin.py

    === added file 'django/conf/app_template/admin.py'
     
     1from django.contrib import admin
     2import models
     3
     4def register(site_admin):
     5    pass # Register your models here.
  • django/conf/project_template/admin.py

    === added file 'django/conf/project_template/admin.py'
     
     1from django.contrib import admin
     2
     3# Import admins from your or contrib applications.
     4from django.contrib.auth import admin as auth_admin
     5from django.contrib.sites import admin as sites_admin
     6
     7# Register admins from your or contrib applications.
     8admin_site = admin.AdminSite()
     9auth_admin.register(admin_site)
     10sites_admin.register(admin_site)
  • django/contrib/auth/admin.py

    === added file 'django/contrib/auth/admin.py'
     
     1from django.utils.translation import ugettext as _
     2from django.contrib import admin
     3from django.contrib.auth import models
     4
     5class GroupAdmin(admin.ModelAdmin):
     6    search_fields = ('name',)
     7    filter_horizontal = ('permissions',)
     8
     9class UserAdmin(admin.ModelAdmin):
     10    fieldsets = (
     11        (None, {'fields': ('username', 'password')}),
     12        (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
     13        (_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),
     14        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
     15        (_('Groups'), {'fields': ('groups',)}),
     16    )
     17    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
     18    list_filter = ('is_staff', 'is_superuser')
     19    search_fields = ('username', 'first_name', 'last_name', 'email')
     20    filter_horizontal = ('user_permissions',)
     21
     22    def add_view(self, request):
     23        from django.contrib.admin.views.auth import user_add_stage
     24        return user_add_stage(request)
     25
     26def register(admin_site):
     27    admin_site.register(models.Group, GroupAdmin)
     28    admin_site.register(models.User, UserAdmin)
  • django/contrib/comments/admin.py

    === added file 'django/contrib/comments/admin.py'
     
     1from django.contrib import admin
     2from django.contrib.comments import models
     3
     4class CommentAdmin(admin.ModelAdmin):
     5    fieldsets = (
     6        (None, {'fields': ('content_type', 'object_id', 'site')}),
     7        ('Content', {'fields': ('user', 'headline', 'comment')}),
     8        ('Ratings', {'fields': ('rating1', 'rating2', 'rating3', 'rating4', 'rating5', 'rating6', 'rating7', 'rating8', 'valid_rating')}),
     9        ('Meta', {'fields': ('is_public', 'is_removed', 'ip_address')}),
     10    )
     11    list_display = ('user', 'submit_date', 'content_type', 'get_content_object')
     12    list_filter = ('submit_date',)
     13    date_hierarchy = 'submit_date'
     14    search_fields = ('comment', 'user__username')
     15    raw_id_fields = ('user',)
     16
     17class FreeCommentAdmin(admin.ModelAdmin):
     18    fieldsets = (
     19        (None, {'fields': ('content_type', 'object_id', 'site')}),
     20        ('Content', {'fields': ('person_name', 'comment')}),
     21        ('Meta', {'fields': ('submit_date', 'is_public', 'ip_address', 'approved')}),
     22    )
     23    list_display = ('person_name', 'submit_date', 'content_type', 'get_content_object')
     24    list_filter = ('submit_date',)
     25    date_hierarchy = 'submit_date'
     26    search_fields = ('comment', 'person_name')
     27
     28def register(admin_site):
     29    admin_site.register(models.Comment, CommentAdmin)
     30    admin_site.register(models.FreeComment, FreeCommentAdmin)
  • django/contrib/flatpages/admin.py

    === added file 'django/contrib/flatpages/admin.py'
     
     1from django.contrib import admin
     2from django.contrib.flatpages import models
     3
     4class FlatPageAdmin(admin.ModelAdmin):
     5    fieldsets = (
     6        (None, {'fields': ('url', 'title', 'content', 'sites')}),
     7        ('Advanced options', {'classes': 'collapse', 'fields': ('enable_comments', 'registration_required', 'template_name')}),
     8    )
     9    list_filter = ('sites',)
     10    search_fields = ('url', 'title')
     11
     12def register(admin_site):
     13    admin_site.register(models.FlatPage, FlatPageAdmin)
  • django/contrib/redirects/admin.py

    === added file 'django/contrib/redirects/admin.py'
     
     1from django.contrib import admin
     2from django.contrib.redirects import models
     3
     4class RedirectAdmin(admin.ModelAdmin):
     5    list_filter = ('site',)
     6    search_fields = ('old_path', 'new_path')
     7
     8def register(admin_site):
     9    admin_site.register(models.Redirect, RedirectAdmin)
     10
  • django/contrib/sites/admin.py

    === added file 'django/contrib/sites/admin.py'
     
     1from django.contrib import admin
     2from django.contrib.sites import models
     3
     4class SiteAdmin(admin.ModelAdmin):
     5    list_display = ('domain', 'name')
     6    search_fields = ('domain', 'name')
     7
     8def register(site):
     9    site.register(models.Site, SiteAdmin)
  • django/conf/project_template/urls.py

    === modified file 'django/conf/project_template/urls.py'
     
    11from django.conf.urls.defaults import *
    22
    33# Uncomment this for admin:
    4 #from django.contrib import admin
     4#import admin
    55
    66urlpatterns = patterns('',
    77    # Example:
     
    1111    #(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    1212
    1313    # Uncomment this for admin:
    14     #('^admin/(.*)', admin.site.root),
     14    #('^admin/(.*)', admin.admin_site.root),
    1515)
  • django/contrib/admin/__init__.py

    === modified file 'django/contrib/admin/__init__.py'
     
    11from django.contrib.admin.options import ModelAdmin
    22from django.contrib.admin.options import StackedInline, TabularInline
    3 from django.contrib.admin.sites import AdminSite, site
     3from django.contrib.admin.sites import AdminSite
  • django/contrib/admin/sites.py

    === modified file 'django/contrib/admin/sites.py'
     
    300300# This global object represents the default admin site, for the common case.
    301301# You can instantiate AdminSite in your own code to create a custom admin site.
    302302site = AdminSite()
     303
  • django/contrib/auth/models.py

    === modified file 'django/contrib/auth/models.py'
     
    364364
    365365    def is_authenticated(self):
    366366        return False
    367 
    368 # Register the admin options for these models.
    369 # TODO: Maybe this should live in a separate module admin.py, but how would we
    370 # ensure that module was loaded?
    371 
    372 from django.contrib import admin
    373 
    374 class GroupAdmin(admin.ModelAdmin):
    375     search_fields = ('name',)
    376     filter_horizontal = ('permissions',)
    377 
    378 class UserAdmin(admin.ModelAdmin):
    379     fieldsets = (
    380         (None, {'fields': ('username', 'password')}),
    381         (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
    382         (_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser', 'user_permissions')}),
    383         (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
    384         (_('Groups'), {'fields': ('groups',)}),
    385     )
    386     list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff')
    387     list_filter = ('is_staff', 'is_superuser')
    388     search_fields = ('username', 'first_name', 'last_name', 'email')
    389     filter_horizontal = ('user_permissions',)
    390 
    391     def add_view(self, request):
    392         from django.contrib.admin.views.auth import user_add_stage
    393         return user_add_stage(request)
    394 
    395 admin.site.register(Group, GroupAdmin)
    396 admin.site.register(User, UserAdmin)
  • django/contrib/comments/models.py

    === modified file 'django/contrib/comments/models.py'
     
    273273
    274274    def __repr__(self):
    275275        return _("Moderator deletion by %r") % self.user
    276 
    277 # Register the admin options for these models.
    278 # TODO: Maybe this should live in a separate module admin.py, but how would we
    279 # ensure that module was loaded?
    280 
    281 from django.contrib import admin
    282 
    283 class CommentAdmin(admin.ModelAdmin):
    284     fieldsets = (
    285         (None, {'fields': ('content_type', 'object_id', 'site')}),
    286         ('Content', {'fields': ('user', 'headline', 'comment')}),
    287         ('Ratings', {'fields': ('rating1', 'rating2', 'rating3', 'rating4', 'rating5', 'rating6', 'rating7', 'rating8', 'valid_rating')}),
    288         ('Meta', {'fields': ('is_public', 'is_removed', 'ip_address')}),
    289     )
    290     list_display = ('user', 'submit_date', 'content_type', 'get_content_object')
    291     list_filter = ('submit_date',)
    292     date_hierarchy = 'submit_date'
    293     search_fields = ('comment', 'user__username')
    294     raw_id_fields = ('user',)
    295 
    296 class FreeCommentAdmin(admin.ModelAdmin):
    297     fieldsets = (
    298         (None, {'fields': ('content_type', 'object_id', 'site')}),
    299         ('Content', {'fields': ('person_name', 'comment')}),
    300         ('Meta', {'fields': ('submit_date', 'is_public', 'ip_address', 'approved')}),
    301     )
    302     list_display = ('person_name', 'submit_date', 'content_type', 'get_content_object')
    303     list_filter = ('submit_date',)
    304     date_hierarchy = 'submit_date'
    305     search_fields = ('comment', 'person_name')
    306 
    307 admin.site.register(Comment, CommentAdmin)
    308 admin.site.register(FreeComment, FreeCommentAdmin)
  • django/contrib/flatpages/models.py

    === modified file 'django/contrib/flatpages/models.py'
     
    2525
    2626    def get_absolute_url(self):
    2727        return self.url
    28 
    29 # Register the admin options for these models.
    30 # TODO: Maybe this should live in a separate module admin.py, but how would we
    31 # ensure that module was loaded?
    32 
    33 from django.contrib import admin
    34 
    35 class FlatPageAdmin(admin.ModelAdmin):
    36     fieldsets = (
    37         (None, {'fields': ('url', 'title', 'content', 'sites')}),
    38         ('Advanced options', {'classes': 'collapse', 'fields': ('enable_comments', 'registration_required', 'template_name')}),
    39     )
    40     list_filter = ('sites',)
    41     search_fields = ('url', 'title')
    42 
    43 admin.site.register(FlatPage, FlatPageAdmin)
  • django/contrib/redirects/models.py

    === modified file 'django/contrib/redirects/models.py'
     
    1818
    1919    def __unicode__(self):
    2020        return "%s ---> %s" % (self.old_path, self.new_path)
    21 
    22 # Register the admin options for these models.
    23 # TODO: Maybe this should live in a separate module admin.py, but how would we
    24 # ensure that module was loaded?
    25 
    26 from django.contrib import admin
    27 
    28 class RedirectAdmin(admin.ModelAdmin):
    29     list_filter = ('site',)
    30     search_fields = ('old_path', 'new_path')
    31 
    32 admin.site.register(Redirect, RedirectAdmin)
    33 
  • django/contrib/sites/models.py

    === modified file 'django/contrib/sites/models.py'
     
    4242    def __unicode__(self):
    4343        return self.domain
    4444
    45 # Register the admin options for these models.
    46 # TODO: Maybe this should live in a separate module admin.py, but how would we
    47 # ensure that module was loaded?
    48 
    49 from django.contrib import admin
    50 
    51 class SiteAdmin(admin.ModelAdmin):
    52     list_display = ('domain', 'name')
    53     search_fields = ('domain', 'name')
    54 
    55 admin.site.register(Site, SiteAdmin)
    56 
    5745class RequestSite(object):
    5846    """
    5947    A class that shares the primary interface of Site (i.e., it has
Back to Top