Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Commit

Permalink
Don't allow inboxes to be pinned & disabled
Browse files Browse the repository at this point in the history
touch #129
  • Loading branch information
moggers87 committed Mar 31, 2016
1 parent 1246853 commit 9eab535
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions inboxen/forms/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 98,18 @@ def __init__(self, request, initial=None, instance=None, *args, **kwargs):
self.fields["pinned"].initial = bool(self.instance.flags.pinned)
self.subform = InboxSecondaryEditForm(instance=self.instance, **kwargs)

def save(self):
data = self.cleaned_data.copy()
def clean(self):
if self.subform.is_valid():
data.update(self.subform.cleaned_data.copy())
self.cleaned_data.update(self.subform.cleaned_data)

disabled = self.cleaned_data.get("disable_inbox", False)
pinned = self.cleaned_data.get("pinned", False)

if disabled and pinned:
raise forms.ValidationError(_("Inbox cannot be disabled and pinned at the same time"))

def save(self):
data = self.cleaned_data.copy()
self.instance.flags.exclude_from_unified = data.pop("exclude_from_unified", False)
self.instance.flags.pinned = data.pop("pinned", False)
self.instance.flags.disabled = data.pop("disable_inbox", False)
Expand Down

0 comments on commit 9eab535

Please sign in to comment.