Instead of throwing an error, display an empty form is there are not event types to display.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-04-01 01:51:25 -04:00
parent 93dbf789d0
commit 93cba698e4
2 changed files with 12 additions and 10 deletions

View File

@@ -75,6 +75,7 @@ Other
libraries.
- Automatically capture license information from installed Python
packages.
- Unify all **RelationshipForms into a common class.
Permissions
~~~~~~~~~~~

View File

@@ -29,18 +29,19 @@ class EventTypeUserRelationshipForm(forms.Form):
*args, **kwargs
)
self.fields['namespace'].initial = self.initial['stored_event_type'].namespace
self.fields['label'].initial = self.initial['stored_event_type'].label
if 'stored_event_type' in self.initial:
self.fields['namespace'].initial = self.initial['stored_event_type'].namespace
self.fields['label'].initial = self.initial['stored_event_type'].label
subscription = EventSubscription.objects.get_for(
stored_event_type=self.initial['stored_event_type'],
user=self.initial['user'],
)
subscription = EventSubscription.objects.get_for(
stored_event_type=self.initial['stored_event_type'],
user=self.initial['user'],
)
if subscription.exists():
self.fields['subscription'].initial = 'subscribed'
else:
self.fields['subscription'].initial = 'none'
if subscription.exists():
self.fields['subscription'].initial = 'subscribed'
else:
self.fields['subscription'].initial = 'none'
def save(self):
subscription = EventSubscription.objects.get_for(