# 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:
2022-01-12 12:56:22 +01:00
parent 31b3428146
commit ef65869c7c
32 changed files with 174 additions and 136 deletions

View File

@@ -8,6 +8,8 @@ Created on: 09.11.20
import logging
from django.core.mail import send_mail
from django.template.loader import render_to_string
from django.utils.translation import gettext_lazy as _
from konova.sub_settings.django_settings import DEFAULT_FROM_EMAIL
@@ -26,18 +28,13 @@ class Mailer:
auth_user = None
auth_password = None
def __init__(self, to_mail: list, from_mail: str = DEFAULT_FROM_EMAIL, auth_user: str = None, auth_password: str = None, fail_silently: bool = False):
# Make sure given to_mail parameter is a list
if isinstance(to_mail, str):
to_mail = [to_mail]
def __init__(self, from_mail: str = DEFAULT_FROM_EMAIL, auth_user: str = None, auth_password: str = None, fail_silently: bool = False):
self.from_mail = from_mail
self.to_mail = to_mail
self.fail_silently = fail_silently
self.auth_user = auth_user
self.auth_password = auth_password
def send(self, subject: str, msg: str):
def send(self, recipient_list: list, subject: str, msg: str):
"""
Sends a mail with subject and message
"""
@@ -45,8 +42,30 @@ class Mailer:
subject=subject,
message=msg,
from_email=self.from_mail,
recipient_list=self.to_mail,
recipient_list=recipient_list,
fail_silently=self.fail_silently,
auth_user=self.auth_user,
auth_password=self.auth_password
)
)
def send_mail_shared_access_removed(self, obj, user):
""" Send a mail if user has no access to the object anymore
Args:
obj ():
Returns:
"""
context = {
"user": user,
"obj": obj,
}
msg = render_to_string("email/sharing/shared_access_removed.html", context)
user_mail_address = [user.email]
self.send(
user_mail_address,
_("{} - Shared access removed").format(obj.identifier),
msg
)

View File

@@ -8,7 +8,7 @@ Created on: 17.08.21
from collections import Iterable
import requests
from django.contrib.auth.models import User
from user.models import User
from django.utils.translation import gettext_lazy as _
from konova.settings import SSO_SERVER_BASE, SSO_PUBLIC_KEY, PROXIES

View File

@@ -5,7 +5,7 @@ Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 02.07.21
"""
from django.contrib.auth.models import User
from user.models import User
from konova.settings import ETS_GROUP, ZB_GROUP