Django

Code

Changeset 4948

Show
Ignore:
Timestamp:
04/06/07 23:36:02 (2 years ago)
Author:
adrian
Message:

newforms-admin: Converted django.contrib.comments model admin options to use new syntax

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/contrib/comments/models.py

    r4940 r4948  
    8787    site = models.ForeignKey(Site) 
    8888    objects = CommentManager() 
     89 
    8990    class Meta: 
    9091        verbose_name = _('comment') 
    9192        verbose_name_plural = _('comments') 
    9293        ordering = ('-submit_date',) 
    93     class Admin: 
    94         fields = ( 
    95             (None, {'fields': ('content_type', 'object_id', 'site')}), 
    96             ('Content', {'fields': ('user', 'headline', 'comment')}), 
    97             ('Ratings', {'fields': ('rating1', 'rating2', 'rating3', 'rating4', 'rating5', 'rating6', 'rating7', 'rating8', 'valid_rating')}), 
    98             ('Meta', {'fields': ('is_public', 'is_removed', 'ip_address')}), 
    99         ) 
    100         list_display = ('user', 'submit_date', 'content_type', 'get_content_object') 
    101         list_filter = ('submit_date',) 
    102         date_hierarchy = 'submit_date' 
    103         search_fields = ('comment', 'user__username') 
    104         raw_id_fields = ('user',) 
    10594 
    10695    def __repr__(self): 
     
    174163    approved = models.BooleanField(_('approved by staff')) 
    175164    site = models.ForeignKey(Site) 
     165 
    176166    class Meta: 
    177167        verbose_name = _('free comment') 
    178168        verbose_name_plural = _('free comments') 
    179169        ordering = ('-submit_date',) 
    180     class Admin: 
    181         fields = ( 
    182             (None, {'fields': ('content_type', 'object_id', 'site')}), 
    183             ('Content', {'fields': ('person_name', 'comment')}), 
    184             ('Meta', {'fields': ('submit_date', 'is_public', 'ip_address', 'approved')}), 
    185         ) 
    186         list_display = ('person_name', 'submit_date', 'content_type', 'get_content_object') 
    187         list_filter = ('submit_date',) 
    188         date_hierarchy = 'submit_date' 
    189         search_fields = ('comment', 'person_name') 
    190170 
    191171    def __repr__(self): 
     
    235215    scored_date = models.DateTimeField(_('score date'), auto_now=True) 
    236216    objects = KarmaScoreManager() 
     217 
    237218    class Meta: 
    238219        verbose_name = _('karma score') 
     
    266247    flag_date = models.DateTimeField(_('flag date'), auto_now_add=True) 
    267248    objects = UserFlagManager() 
     249 
    268250    class Meta: 
    269251        verbose_name = _('user flag') 
     
    278260    comment = models.ForeignKey(Comment) 
    279261    deletion_date = models.DateTimeField(_('deletion date'), auto_now_add=True) 
     262 
    280263    class Meta: 
    281264        verbose_name = _('moderator deletion') 
     
    285268    def __repr__(self): 
    286269        return _("Moderator deletion by %r") % self.user 
     270 
     271# Register the admin options for these models. 
     272# TODO: Maybe this should live in a separate module admin.py, but how would we 
     273# ensure that module was loaded? 
     274 
     275from django.contrib import admin 
     276 
     277class CommentAdmin(admin.ModelAdmin): 
     278    fields = ( 
     279        (None, {'fields': ('content_type', 'object_id', 'site')}), 
     280        ('Content', {'fields': ('user', 'headline', 'comment')}), 
     281        ('Ratings', {'fields': ('rating1', 'rating2', 'rating3', 'rating4', 'rating5', 'rating6', 'rating7', 'rating8', 'valid_rating')}), 
     282        ('Meta', {'fields': ('is_public', 'is_removed', 'ip_address')}), 
     283    ) 
     284    list_display = ('user', 'submit_date', 'content_type', 'get_content_object') 
     285    list_filter = ('submit_date',) 
     286    date_hierarchy = 'submit_date' 
     287    search_fields = ('comment', 'user__username') 
     288    raw_id_fields = ('user',) 
     289 
     290class FreeCommentAdmin(admin.ModelAdmin): 
     291    fields = ( 
     292        (None, {'fields': ('content_type', 'object_id', 'site')}), 
     293        ('Content', {'fields': ('person_name', 'comment')}), 
     294        ('Meta', {'fields': ('submit_date', 'is_public', 'ip_address', 'approved')}), 
     295    ) 
     296    list_display = ('person_name', 'submit_date', 'content_type', 'get_content_object') 
     297    list_filter = ('submit_date',) 
     298    date_hierarchy = 'submit_date' 
     299    search_fields = ('comment', 'person_name') 
     300 
     301admin.site.register(Comment, CommentAdmin) 
     302admin.site.register(FreeComment, FreeCommentAdmin)