X-Git-Url: https://git.mdrn.pl/cas.git/blobdiff_plain/37e278e43ece42375352c07d9f04991ef58d992c..173b54164d936c83eb9a28a26b46bb3b19955b82:/src/accounts/models.py?ds=sidebyside diff --git a/src/accounts/models.py b/src/accounts/models.py index 71a8362..0197eba 100644 --- a/src/accounts/models.py +++ b/src/accounts/models.py @@ -1,3 +1,25 @@ from django.db import models +from django.utils.translation import gettext_lazy as _ +from cas_provider.signals import cas_collect_custom_attributes -# Create your models here. + +class OnboardingEmail(models.Model): + subject = models.CharField(_("subject"), max_length=255) + body = models.TextField( + _("body"), + help_text=_("Available placeholders: {username}, {password}, {first_name}, {last_name}") + ) + + class Meta: + verbose_name = _("onboarding email template") + verbose_name_plural = _("onboarding email templates") + + +def user_attributes(sender, user, **kwargs): + return { + 'firstname': user.first_name, + 'lastname': user.last_name, + 'cn': ' '.join((user.first_name, user.last_name)), + 'email': user.email, + } +cas_collect_custom_attributes.connect(user_attributes)