コード例 #1
0
ファイル: views.py プロジェクト: hpkv/creative_spaces
 def post(self, request):
     self.form = RoleDetailForm(request.POST)
     if self.form.is_valid():
         if request.FILES:
             filename = request.FILES['image']
             fs = FileSystemStorage()
             my_file = fs.save(filename.name, filename)
             image = fs.url(my_file)
             image = filename.name
         f = self.form.save(commit=False)
         f.role_id = UserRole.objects.get(role_name='admin').role_id
         f.first_name = request.POST['first_name']
         f.last_name = request.POST['last_name']
         f.username = request.POST['first_name'] + "_" + request.POST[
             'last_name']
         f.email = request.POST['email']
         f.image = image
         f.mobile = request.POST['mobile']
         f.password = make_password(request.POST['password'])
         f.address = request.POST['address']
         token = make_password(generate_string()).replace("+", "")
         verify_link = '127.0.0.1:8000/verify/?token={}'.format(token)
         f.verify_link = token
         f.is_staff = False
         f.is_superuser = False
         f.is_active = False
         f.save()
         try:
             send_verify_link(request.POST['email'], f.username,
                              verify_link)
         except:
             print("!!!!!  Failed to send email  !!!!!")
         return redirect('/')
     else:
         return HttpResponse(status=400)
コード例 #2
0
ファイル: views.py プロジェクト: hpkv/creative_spaces
 def post(self, request):
     try:
         detail = RoleDetails.objects.get(email=request.POST['email'])
     except:
         return self.get(request, 'email_not_registered')
     else:
         token = make_password(request.POST['email']).replace("+", "")
         verify_link = '127.0.0.1:8000/forgot_password_verify/?token={}'.format(
             token)
         try:
             send_verify_link(request.POST['email'], 'User', verify_link)
             request.session['email'] = detail.email
         except:
             print("!!!!!  Failed to send email  !!!!!")
         return redirect('/')