示例#1
0
    def save(self, bulletin, commit=True, permanent=False):
        # must only be invoked by a subclass, where bulletin is a proper instance
        if hasattr(bulletin, 'owner'):
          if bulletin.owner != self._request.user:
            bulletin.moderated_by = self._request.user

        else:
          bulletin.owner = self._request.user
        
        if not hasattr(bulletin, 'chapter'):
          bulletin.chapter = self._request.chapter

        setattr_safe(bulletin, 'title', self.cleaned_data['title'])
        setattr_safe(bulletin, 'content', self.cleaned_data['content'])
        setattr_safe(bulletin, 'related', self.cleaned_data['related'])
        setattr_safe(bulletin, 'is_global', self.cleaned_data['is_global'])
        setattr_safe(bulletin, 'is_official', self.cleaned_data['is_official'])

        if commit:
            if self.is_delete() and not permanent:
                bulletin.delete()
            else:
                bulletin.save()
                bulletin.follow(self._request.user)

        return bulletin
示例#2
0
    def save(self, instance=None, commit=True):
        # no editing and no deleting
        event = instance or Event()

        setattr_safe(event, "start", self.cleaned_data["start"])
        setattr_safe(event, "end", self.cleaned_data["end"])
        setattr_safe(event, "where", self.cleaned_data["where"])

        return super(EventForm, self).save(event, commit=commit)
示例#3
0
    def save(self, instance=None, commit=True):
        talk = instance or Talk()
        setattr_safe(talk, 'is_announcement', self.cleaned_data['is_announcement'])

        return super(TalkForm, self).save(talk, commit=commit)