All pastes #141924 Raw Edit

Untitled

public python v1 · immutable
#141924 ·published 2006-08-21 05:01 UTC
rendered paste body
EXCUSE_STATUS_CHOICES = (    ('Y', 'Yes'),    ('N', 'No'),    ('M', 'Maybe'))class Excuse(models.Model):    title = models.CharField(maxlength=255)    event = models.ForeignKey(Event)    author = models.ForeignKey(User)    reason = models.TextField()    status = models.CharField(maxlength=1, choices=EXCUSE_STATUS_CHOICES)    def save(self):        userID = currentUser().id        if gettattr(self, 'author_id', None) is None:            self.author_id = userID        if gettattr(self, 'status', None) is None:            self.status = 'M'    class Admin:        fields = ()        list_display = ('author', 'event', 'status')    def __str__(self): return self.titleclass ExcuseAdminOptions(AdminOptions):    def _fields(self):        user = currentUser()        if user is None or user.is_anonymous():            return ()        elif user.has_perm('status.change_excuse'):            return ((None, {'fields' : ('title', 'event', 'reason', 'status')}))        else:            return ((None, {'fields' : ('title', 'event', 'reason')}))    fields = property(_fields)del Excuse._meta.admin.fieldsExcuse._meta.admin.__class__ = ExcuseAdminOptions