def user_new(request): """ Quick form for making a new user and inviting them to login. """ if request.method == "POST": form = AddUserForm(request.POST or None) if form.is_valid(): user = form.save(commit=False) user.organization = request.user.organization user.save() mail_subject = "New Facet User Details" message = "You've been added to Facet. Your login is your email and your password is please." print message recipient = [user.email] sender_email = request.user.email send_mail(mail_subject, message, settings.EMAIL_HOST_USER, recipient, fail_silently=False) return redirect('team_list') else: form=AddUserForm() return render(request, 'editorial/usernew.html', {'form': form})
def user_new(request): """ Quick form for making a new user and inviting them to login. """ if request.method == "POST": form = AddUserForm(request.POST or None) if form.is_valid(): user = form.save(commit=False) user.organization = request.user.organization user.save() # notify new user of of account creation mail_subject = "New Facet User Details" message = "You've been added to Facet. Your login is your email and your password is please." recipient = [user.email] sender_email = request.user.email send_mail(mail_subject, message, settings.EMAIL_HOST_USER, recipient, fail_silently=True) # record action for activity stream new_user = get_object_or_404(User, pk=user.pk) action.send(request.user, verb="added", action_object=new_user) return redirect('team_list') else: form=AddUserForm() return render(request, 'editorial/usernew.html', {'form': form})
def get_context_data(self): """Retrieve team of org and partner orgs.""" # the user's organization organization = self.request.user.organization networks = organization.get_org_networks() partners = organization.get_org_collaborators_vocab() # form for adding a new user to the team adduserform = AddUserForm() # only visible for admin users return { 'organization': organization, 'networks': networks, 'partners': partners, 'adduserform': adduserform, }