Commit a2cac501a9681177af2e8b625df94b1ee96ed6ca

Authored by ALEXIS-PC\alexis
1 parent a01cb74b
Exists in dev

adding admin users emails list in order to send email to admins when a new user signup

Showing 1 changed file with 11 additions and 5 deletions   Show diff stats
src/core/pyros_django/user_manager/forms.py
... ... @@ -63,22 +63,28 @@ class PyrosUserCreationForm(forms.ModelForm):
63 63 pyros_user.first_name = self.cleaned_data['first_name']
64 64 pyros_user.last_name = self.cleaned_data['last_name']
65 65 pyros_user.save()
  66 +
  67 + # get list of admin users
  68 + admin_users = PyrosUser.objects.filter(user_level__priority=7).values_list("email",flat=True)
  69 +
66 70 # sending mail to new user
67 71 send_mail(
68   - '[COLIBRI CC] Registration',
69   - 'Hi,\n\nThanks for your registration. The PI will examinate your account as soon as possible.\n\nCordialy,\n\nColibri Control Center',
  72 + '[PyROS CC] Registration',
  73 + 'Hi,\n\nThanks for your registration. The PI will examinate your account as soon as possible.\n\nCordially,\n\nPyROS Control Center',
70 74 '',
71 75 [self.cleaned_data['email']],
72 76 fail_silently=False,
73 77 )
74   - # sending mail to admin (TODO: change mail adress)
  78 +
75 79 domain = settings.DEFAULT_DOMAIN
76 80 url = f"{domain}{reverse('user-detail',args=(pyros_user.pk,))}"
  81 +
  82 + # sending mail to admin
77 83 send_mail(
78 84 '[PyROS CC] New registration',
79   - f"Hi,\n\nA new user : {self.cleaned_data['email']}, need a validation for his registration.\nConnect to your account and click on the following link to verify this user profile : {url}",
  85 + f"Hi,\n\nA new user : {self.cleaned_data['email']}, need a validation for his registration.\nClick on the following link to verify this user profile : {url} \n\nCordially,\n\nPyROS Control Center",
80 86 '',
81   - ["akoralewski@irap.omp.eu"],
  87 + admin_users,
82 88 fail_silently=False,
83 89 )
84 90 return pyros_user
... ...