add generate user automaticaly from excel
This commit is contained in:
parent
acbe778197
commit
b79df7333f
|
@ -66,6 +66,7 @@ class ImportForm(forms.Form):
|
|||
self._eidas1 = None
|
||||
self.rows = {}
|
||||
self.properties = {}
|
||||
self.users = []
|
||||
self.user = kwargs.pop('user', None)
|
||||
super().__init__(*args, **kwargs)
|
||||
dids = DID.objects.filter(user=self.user)
|
||||
|
@ -178,13 +179,11 @@ class ImportForm(forms.Form):
|
|||
msg = "line {}: {}".format(line+1, e)
|
||||
self.exception(msg)
|
||||
|
||||
user = User.objects.filter(email=row.get('email'))
|
||||
if not user:
|
||||
txt = _('The user does not exist!')
|
||||
msg = "line {}: {}".format(line+1, txt)
|
||||
self.exception(msg)
|
||||
user, new = User.objects.get_or_create(email=row.get('email'))
|
||||
if new:
|
||||
self.users.append(user)
|
||||
|
||||
return user.first()
|
||||
return user
|
||||
|
||||
def create_credential(self, user, row):
|
||||
return VerificableCredential(
|
||||
|
|
|
@ -936,7 +936,7 @@ class ImportStep2View(ImportExport, TemplateView):
|
|||
return context
|
||||
|
||||
|
||||
class ImportAddView(ImportExport, FormView):
|
||||
class ImportAddView(NotifyActivateUserByEmail, ImportExport, FormView):
|
||||
template_name = "idhub/admin/import_add.html"
|
||||
subtitle = _('Import')
|
||||
icon = ''
|
||||
|
@ -957,5 +957,12 @@ class ImportAddView(ImportExport, FormView):
|
|||
Event.set_EV_CREDENTIAL_CAN_BE_REQUESTED(cred)
|
||||
else:
|
||||
messages.error(self.request, _("Error importing the file!"))
|
||||
|
||||
for user in form.users:
|
||||
try:
|
||||
self.send_email(user)
|
||||
except SMTPException as e:
|
||||
messages.error(self.request, e)
|
||||
|
||||
return super().form_valid(form)
|
||||
|
||||
|
|
Loading…
Reference in New Issue