core, counter: add preferences for counter notifications

Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
Skia
2017-09-02 12:42:07 +02:00
parent 914feffbd8
commit 9f259b35bd
6 changed files with 174 additions and 99 deletions

View File

@ -464,7 +464,8 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
model = User
pk_url_kwarg = "user_id"
template_name = "core/user_preferences.jinja"
form_class = modelform_factory(Preferences, fields=['receive_weekmail'])
form_class = modelform_factory(Preferences, fields=['receive_weekmail',
'notify_on_click', 'notify_on_refill'])
context_object_name = "profile"
current_tab = "prefs"
@ -474,11 +475,7 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
def get_form_kwargs(self):
kwargs = super(UserPreferencesView, self).get_form_kwargs()
try:
pref = self.object.preferences
except:
pref = Preferences(user=self.object)
pref.save()
pref = self.object.preferences
kwargs.update({'instance': pref})
return kwargs