User menu
* adds user notifications and management
This commit is contained in:
@@ -11,8 +11,10 @@ from django.contrib.auth.models import User, Group
|
||||
from django.core.management import BaseCommand
|
||||
from django.db import transaction
|
||||
|
||||
from konova.management.commands.setup_data import TEST_ORGANISATION_DATA, GROUPS_DATA
|
||||
from konova.management.commands.setup_data import TEST_ORGANISATION_DATA, GROUPS_DATA, USER_NOTIFICATIONS_NAMES
|
||||
from organisation.models import Organisation
|
||||
from user.enums import UserNotificationEnum
|
||||
from user.models import UserNotification
|
||||
|
||||
CREATED_TEMPLATE = "{} created"
|
||||
|
||||
@@ -26,6 +28,7 @@ class Command(BaseCommand):
|
||||
self._init_superuser()
|
||||
self._init_test_organisation()
|
||||
self._init_default_groups()
|
||||
self._init_user_notifications()
|
||||
except KeyboardInterrupt:
|
||||
self._break_line()
|
||||
exit(-1)
|
||||
@@ -38,9 +41,11 @@ class Command(BaseCommand):
|
||||
"""
|
||||
self._write_warning("--- Superuser ---")
|
||||
username = input("Superuser name: ")
|
||||
|
||||
if User.objects.filter(username=username).exists():
|
||||
self._write_error("Name already taken!")
|
||||
exit(-1)
|
||||
self._write_error("Superuser {} exists! Skip.".format(username))
|
||||
return
|
||||
|
||||
pw = getpass("Password: ")
|
||||
pw_confirm = getpass("Confirm password : ")
|
||||
if pw != pw_confirm:
|
||||
@@ -90,6 +95,23 @@ class Command(BaseCommand):
|
||||
|
||||
self._break_line()
|
||||
|
||||
def _init_user_notifications(self):
|
||||
""" Creates the default user notification triggers
|
||||
|
||||
Returns:
|
||||
|
||||
"""
|
||||
self._write_warning("--- User Notifications ---")
|
||||
choices = UserNotificationEnum.as_choices(drop_empty_choice=True)
|
||||
for choice in choices:
|
||||
UserNotification.objects.get_or_create(
|
||||
id=choice[0],
|
||||
name=USER_NOTIFICATIONS_NAMES.get(choice[0], None),
|
||||
)
|
||||
self._write_success(CREATED_TEMPLATE.format(choice[0]))
|
||||
|
||||
self._break_line()
|
||||
|
||||
def _break_line(self):
|
||||
""" Simply prints a line break
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ Created on: 15.12.20
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||
from user.enums import UserNotificationEnum
|
||||
|
||||
TEST_ORGANISATION_DATA = [
|
||||
{
|
||||
@@ -34,4 +35,14 @@ GROUPS_DATA = [
|
||||
{
|
||||
"name": ETS_GROUP,
|
||||
},
|
||||
]
|
||||
]
|
||||
|
||||
# Must match with UserNotificationEnum
|
||||
USER_NOTIFICATIONS_NAMES = {
|
||||
"NOTIFY_ON_NEW_RELATED_DATA": _("On new related data"),
|
||||
"NOTIFY_ON_SHARE_LINK_DISABLED": _("On disabled share link"),
|
||||
"NOTIFY_ON_SHARED_ACCESS_REMOVED": _("On shared access removed"),
|
||||
"NOTIFY_ON_SHARED_DATA_REGISTERED": _("On shared data registered"),
|
||||
"NOTIFY_ON_SHARED_DATA_DELETED": _("On shared data deleted"),
|
||||
"NOTIFY_ON_REGISTERED_DATA_EDITED": _("On registered data edited"),
|
||||
}
|
||||
@@ -127,5 +127,11 @@ nav{
|
||||
border-radius: 0;
|
||||
}
|
||||
.btn-default:hover{
|
||||
/*
|
||||
color: var(--rlp-gray-light);
|
||||
color: var(--rlp-red);;
|
||||
background-color: unset;
|
||||
border: 1px solid var(--rlp-red);
|
||||
*/
|
||||
box-shadow: 1px 1px 3px var(--rlp-gray-dark);
|
||||
}
|
||||
Reference in New Issue
Block a user