# 63 Refactoring
* refactors django User model to custom User model to provide further attributes and methods directly on the user model
This commit is contained in:
+4
-8
@@ -8,10 +8,10 @@ Created on: 08.07.21
|
||||
from django import forms
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.contrib.auth.models import User
|
||||
from user.models import User
|
||||
|
||||
from konova.forms import BaseForm, BaseModalForm
|
||||
from user.models import UserNotification, KonovaUserExtension
|
||||
from user.models import UserNotification
|
||||
|
||||
|
||||
class UserNotificationForm(BaseForm):
|
||||
@@ -50,11 +50,7 @@ class UserNotificationForm(BaseForm):
|
||||
)
|
||||
self.fields["notifications"].choices = choices
|
||||
|
||||
# Set currently selected notifications as initial
|
||||
self.konova_extension = KonovaUserExtension.objects.get_or_create(
|
||||
user=user
|
||||
)[0]
|
||||
users_current_notifications = self.konova_extension.notifications.all()
|
||||
users_current_notifications = self.user.notifications.all()
|
||||
users_current_notifications = [str(n.id) for n in users_current_notifications]
|
||||
self.fields["notifications"].initial = users_current_notifications
|
||||
|
||||
@@ -68,7 +64,7 @@ class UserNotificationForm(BaseForm):
|
||||
notifications = UserNotification.objects.filter(
|
||||
id__in=selected_notification_ids,
|
||||
)
|
||||
self.konova_extension.notifications.set(notifications)
|
||||
self.user.notifications.set(notifications)
|
||||
|
||||
|
||||
class UserContactForm(BaseModalForm):
|
||||
|
||||
Reference in New Issue
Block a user