Ticket #6003: 00-admin-registration.2.diff

File 00-admin-registration.2.diff, 10.0 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/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'
     
    301301# This global object represents the default admin site, for the common case.
    302302# You can instantiate AdminSite in your own code to create a custom admin site.
    303303site = AdminSite()
     304
  • django/contrib/auth/admin.py

    === modified file 'django/contrib/auth/admin.py'
     
    5959            'username_help_text': User._meta.get_field('username').help_text,
    6060        }, context_instance=template.RequestContext(request))
    6161
    62 admin.site.register(Group, GroupAdmin)
    63 admin.site.register(User, UserAdmin)
    64 
     62def register(admin_site):
     63    admin_site.register(Group, GroupAdmin)
     64    admin_site.register(User, UserAdmin)
  • 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 from django.contrib.auth import admin
  • django/contrib/comments/models.py

    === modified file 'django/contrib/comments/models.py'
     
    273273
    274274    def __unicode__(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