Beispiel #1
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data["username"]
            name = form.cleaned_data["name"]
            email = form.cleaned_data["email"]
            password = form.cleaned_data["password"]
            user = UserModel(name=name,
                             password=make_password(password),
                             email=email,
                             username=username)
            user.save()
            subject = "Weclome to InsaClone"
            message = "Hello " + name + "\nWelcome to InstaClone" + " Instaclone allows users to upload images of a certain brand or product to win points."
            send_email(email, subject, message)
            return render(request, "index.html", {
                "form": form,
                "error": "Id Created"
            })
        else:
            return render(request, "index.html", {
                "form": form,
                "error": "Invalid data"
            })
    elif request.method == "GET":
        form = SignUpForm()
        return render(request, "index.html", {"form": form})
Beispiel #2
0
def signup_view(request):
    date = datetime.now()
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            username = form.cleaned_data['username']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            # saving data to DB
            user = SignUpModel(name=name,
                               username=username,
                               email=email,
                               password=make_password(password))
            user.save()

            # using sendgrid
            subject = "Successfully Signed Up!"
            body = "Thank you for Signing Up"
            send_mail(email, subject, body)
            ctypes.windll.user32.MessageBoxW(0, u"Successfully signed up",
                                             u"Success", 0)
            # returning user ro success page that you have successfully signup to the app
            return render(request, 'success.html')
        else:
            print("Error: Invalid form")
    else:
        form = SignUpForm()
    # returning to signup page if method is not post or there is no data in form or payload is empty
    return render(request, 'index.html', {'form': form}, {'Date': date})
Beispiel #3
0
def signup(request):
    """
    Sign Up Page, uses built in Sign-Up
    """
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            name = form.cleaned_data.get('name')
            category = form.cleaned_data.get('category')
            user = authenticate(username=username, password=raw_password)
            if category == "doctor":
                doctor = Doctor(user=user, name=name)
                doctor.save()
            if category == "pharmacist":
                pharmacist = Pharmacist(user=user, name=name)
                pharmacist.save()
            if category == "patient":
                patient = Patient(user=user, name=name)
                patient.save()
            login(request, user)
            return redirect('/pharm/profile')
    else:
        form = SignUpForm()
    return render(request, 'pharmeasyflow/signup.html', {'form': form})
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            name = form.cleaned_data['name']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            # saving data to DB
            user = UserModel(name=name,
                             password=make_password(password),
                             email=email,
                             username=username)
            user.is_active = False
            user.save()
            send_mail(
                'E-Mail Verification',
                ' HEY...Welcome To Instagram.'
                '.click on the link below to get your account activated \n\n '
                'https://instaapplication.herokuapp.com/email_activate/?user_email='
                + email,
                '*****@*****.**', [email],
                fail_silently=False)

            return render(request, 'success.html')
        else:
            return HttpResponse("Invalid form data.")
    else:
        form = SignUpForm()
        return render(request, 'index.html', {'form': form})
Beispiel #5
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data["username"]
            name = form.cleaned_data["name"]
            email = form.cleaned_data["email"]
            password = form.cleaned_data["password"]
            user = UserModel(name=name,
                             password=make_password(password),
                             email=email,
                             username=username)
            user.save()

            return render(request, "index.html", {
                "form": form,
                "error": "Id Created"
            })
        else:
            return render(request, "index.html", {
                "form": form,
                "error": "Invalid data"
            })
    elif request.method == "GET":
        form = SignUpForm()
        return render(request, "index.html", {"form": form})
Beispiel #6
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)
        print request.body
        if form.is_valid():
            username = form.cleaned_data['username']
            name = form.cleaned_data['full_name']
            email = form.cleaned_data['email']
            password = form.cleaned_data['password']
            print 'Here'
            #saving data to DB
            empty = len(username) == 0 and len(password) == 0
            if len(username) >= 4 and len(password) >= 3:
                user = UserModel(full_name=name,
                                 password=make_password(password),
                                 email=email,
                                 username=username)
                user.save()
                return render(request, 'success.html')
            else:
                text = {}
                text = "Username or password is not long enough"
                return render(request, 'index.html', {'text': text})
            #return redirect('login/')

        else:
            form = SignUpForm()
    elif request.method == "GET":
        form = SignUpForm()
        today = datetime.now()
    return render(request, 'index.html', {'today': today, 'form': form})
Beispiel #7
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            user = User.objects.get(username=username)
            if form.cleaned_data.get('tipo') == 'Tec':
                tec = Tecnico(nome=form.cleaned_data.get('username'),
                              email=form.cleaned_data.get('email'),
                              cpf=form.cleaned_data.get('cpf'),
                              crf=form.cleaned_data.get('registro'))
                tec.save()
                group = Group.objects.get(name='Técnico')
                user.groups.add(group)
            else:
                vet = Veterinario(nome=form.cleaned_data.get('username'),
                                  email=form.cleaned_data.get('email'),
                                  cpf=form.cleaned_data.get('cpf'),
                                  crmv=form.cleaned_data.get('registro'))
                vet.save()
                group = Group.objects.get(name='Veterinário')
                user.groups.add(group)
            return redirect('main')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if not form.is_valid():
            return render(request, 'signup.html', {'form': form})
        else:
            # fetch data from inputs of form
            email = form.cleaned_data.get('email')
            password = form.cleaned_data.get('password')
            first_name = form.cleaned_data.get('first_name')
            last_name = form.cleaned_data.get('last_name')
            telephone = form.cleaned_data.get('telephone')
            address = form.cleaned_data.get('address')
            User.objects.create_user(username=email,
                                     password=password,
                                     email=email,
                                     first_name=first_name,
                                     last_name=last_name)
            user = authenticate(email=email, password=password)
            login(request, user)
            customer = Customer(user=user, tel=telephone, address=address)
            customer.save()
            return redirect('/')

    else:
        return render(request, 'signup.html', {'form': SignUpForm()})
Beispiel #9
0
def signup_view(request):
    date = datetime.datetime.now()
    if request.method == 'POST':
        signup_form = SignUpForm(request.POST)
        if signup_form.is_valid():
            username = signup_form.cleaned_data['username']
            name = signup_form.cleaned_data['name']
            password = signup_form.cleaned_data['password']
            email = signup_form.cleaned_data['email']
            if len(username) > 4 and len(password) > 5:
                user = UserProfile(name=name, password=make_password(password), username=username, email=email)
                user.save()
                sg = sendgrid.SendGridAPIClient(apikey=sendgrid_api_key)
                from_email = Email("*****@*****.**")
                to_email = Email(email)
                subject = "Thanks for signing up"
                content = Content("text/plain", "Continue to login and create posts....have fun")
                mail = Mail(from_email, subject, to_email, content)
                response = sg.client.mail.send.post(request_body=mail.get())
                if response.status_code == 202:
                    message = "Account has been created successfully.Mail has been sent to your email-id"
                else:
                    message = "There is some problem in sending a mail"
                return render(request, 'success.html', {'response': message})
            else:
                ctypes.windll.user32.MessageBoxW(0, u"invalid username/password. please try again", u"Error", 0)
                signup_form = SignUpForm()
        else:
                ctypes.windll.user32.MessageBoxW(0, u"invalid entries. please try again", u"Error", 0)
                signup_form = SignUpForm()
    elif request.method == 'GET':
        signup_form = SignUpForm()
    return render(request, 'index.html', {"Today_date": date, 'form': signup_form})
Beispiel #10
0
def register(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = SignUpForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            # Process the data in form.cleaned_data
            username = form.cleaned_data["username"]
            password = form.cleaned_data["password"]
            email = form.cleaned_data["email"]
            first_name = form.cleaned_data["first_name"]
            last_name = form.cleaned_data["last_name"]
            # At this point, user is a User object that has already been saved
            # to the database. You can continue to change its attributes
            # if you want to change other fields.
            user = User.objects.create_user(username, email, password)
            user.first_name = first_name
            user.last_name = last_name

            # Save new user attributes
            user.save()
            return HttpResponseRedirect(
                reverse('login'))  # Redirect after POST
    else:
        form = SignUpForm()

    data = {
        'form': form,
        'user': request.user,
    }
    return render_to_response('register.html',
                              data,
                              context_instance=RequestContext(request))
Beispiel #11
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():

            username = form.cleaned_data["username"]
            password = form.cleaned_data["password"]
            email = form.cleaned_data["email"]
            first_name = form.cleaned_data["first_name"]
            last_name = form.cleaned_data["last_name"]

            user = User.objects.create_user(username, email, password)
            user.first_name = first_name
            user.last_name = last_name

            user.save()

            return HttpResponseRedirect(reverse('usuariosAdmin'))
    else:
        form = SignUpForm()

    data = {
        'form': form,
    }
    return render_to_response('signup.html',
                              data,
                              context_instance=RequestContext(request))
Beispiel #12
0
def signup_view(request):
    #check if request is post
    if request.method == "POST":
        #define form
        form = SignUpForm(request.POST)
        print request.body
        #check form is valid
        if form.is_valid():
            #retrieve username
            username = form.cleaned_data['username']
            #retrieve email
            email = form.cleaned_data['email']
            #retrieve  password
            password = form.cleaned_data['password']

            # saving data to DB
            user = UserModel(username=username,
                             password=make_password(password),
                             email=email)
            user.save()

        return render(request, 'success.html')
    elif request.method == "GET":
        form = SignUpForm()
        today = datetime.now()


#load index page
    return render(request, 'index.html', {'today': today, 'form': form})
Beispiel #13
0
def signup_view(request):
    if request.method == "POST":
        form = SignUpForm(request.POST)

        if form.is_valid():
            if(len(form.cleaned_data['username'])<5 or set('[~!#$%^&*()_+{}":;\']+$ " "').intersection(form.cleaned_data['username'])):
                return render(request,'invalid.html')
            else:
                if (len(form.cleaned_data["password"])>5):
                    username = form.cleaned_data['username']
                    name = form.cleaned_data['name']
                    email = form.cleaned_data['email']
                    password = form.cleaned_data['password']
                    # saving data to the database
                    user = UserModel(name=name, password=make_password(password), email=email, username=username)
                    user.save()
                    sg = sendgrid.SendGridAPIClient(apikey=(sendgrid_key))
                    from_email = Email("*****@*****.**")
                    to_email = Email(form.cleaned_data['email'])
                    subject = "Welcome to SwacchBharat"
                    content = Content("text/plain", "Swacch Bharat team welcomes you!\n We hope you like sharing the images of your surroundings to help us build a cleaner india /n")
                    mail = Mail(from_email, subject, to_email, content)
                    response = sg.client.mail.send.post(request_body=mail.get())
                    print(response.status_code)
                    print(response.body)
                    print(response.headers)
                    return render(request, 'success.html')
                else:
                    return render(request, 'invalid.html')
                    # return redirect('login/')
    else:
        form = SignUpForm()

    return render(request, 'index.html' , {'form': form})
Beispiel #14
0
def signup_view(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            username = form.cleaned_data['username']
            if len(username) > 6:
                # extra parameters for signup
                name = form.cleaned_data['name']
                email = form.cleaned_data['email']
                password = form.cleaned_data['password']
                if len(password) >= 8:
                    # password must be at least 8 characters long
                    user = UserModel(name=name, password=make_password(password), email=email, username=username)
                    user.save()
                    # sending a welcome mail to new user
                    sg = sendgrid.SendGridAPIClient(apikey=apikey)
                    from_email = Email(my_email)
                    to_email = Email(email)
                    subject = "Swacch Bharat"
                    content = Content("text/plain", "you are successfully signed up for Swacch Bharat")
                    mail = Mail(from_email, subject, to_email, content)
                    sg.client.mail.send.post(request_body=mail.get())

            return render(request, 'success.html')
    else:
        form = SignUpForm()
    return render(request, 'index.html', {'form': form})
Beispiel #15
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        # Does not work on my computer for some reason, not sure why
        # client = EmailHunterClient('24f4629448d166981339d832608fe358124519ce')
        # if not client.exist('form.cleaned_data.get('email')'):
        #       form = SignUpForm()
        #       return render(request, 'accounts/signup.html', {'form': form})

        if form.is_valid():
            clearbit.key = 'sk_48d5da34d0bf087c83400aa13c0f317a'
            response = clearbit.Enrichment.find(email=form.cleaned_data.get('email'),
                                                stream=True)
            if response['person']['bio'] is not None:
                instance = form.save(commit=False)
                instance.bio = response['person']['bio']
                instance.save()
            else:
                form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('home')
    else:
        form = SignUpForm()
    return render(request, 'accounts/signup.html', {'form': form})
Beispiel #16
0
def signup(request):
    if request.user.is_authenticated():
        return redirect('/')
    if request.method == 'POST':
        fname = request.POST.get('first_name')
        lname = request.POST.get('last_name')
        email = request.POST.get('email')
        password1 = request.POST.get('password1')
        password2 = request.POST.get('password2')
        data = {
            'first_name': fname,
            'last_name': lname,
            'email': email,
            'password2': password2,
            'password1': password1
        }
        form = SignUpForm(data=data)
        if form.is_valid():
            user = form.save(commit=False)
            user.is_active = True
            user.save()
            return HttpResponse(json.dumps({"message": "Success"}),
                                content_type="application/json")
        else:
            return HttpResponse(json.dumps({"message": form.errors}),
                                content_type="application/json")
    else:
        form = SignUpForm()
    return HttpResponse(json.dumps({"message": "Denied"}),
                        content_type="application/json")
    # return render(request, 'registration/signup.html', {'form':form})
Beispiel #17
0
def sign_up(request, username=None, password=None):
    def submit_form(form, close):
        c = Context({'form': form, 'close': close})
        return render_to_response('signon.html',
                                  c,
                                  context_instance=RequestContext(request))

    # If this was a GET, its the first time the form is called
    if request.method == 'GET':
        data = {'username': username, 'password': password}
        form = SignUpForm(data)
        return submit_form(form, False)

    # POST the form was submitted
    form = SignUpForm(request.POST)
    if not form.is_valid():
        return submit_form(form, False)

    username = form.cleaned_data['username']
    password = form.cleaned_data['password']
    confirm = form.cleaned_data['confirm']
    if password != confirm:
        form._errors['confirm'] = ErrorList(["Passwords are not the same"])
        return submit_form(form, False)

    # Create the user
    if '@' in username:
        email = username
        username = username.replace('.', '_')
    else:
        email = username + "@wenzit.net"

    try:
        user = User.objects.create_user(username=username,
                                        email=email,
                                        password=password)
    except:
        form._errors['username'] = ErrorList(
            ['This name has already been used'])
        return submit_form(form, False)

    if email != None:
        user.email = email

    user.save()

    # Create profile
    profile = ProfileModel(user=user)
    profile.save()

    user = auth.authenticate(username=user.username, password=password)
    if user is not None and user.is_active:
        auth.login(request, user)
        return submit_form(form, True)
    else:
        form._errors['username'] = ErrorList(["User could not be created"])
        return submit_form(form, False)
Beispiel #18
0
def signup(request):
    if request.method =='POST':
        form =  SignUpForm(request.POST)
        if form.is_valid():
            form.save(commit=True)
            return render(request,'SignUpFinish.html',{'form': form, 'isUserSigningInUpOrOut': 'true'})
    else:
        form =  SignUpForm()
    return render(request, 'SignUp.html', {'form': form, 'isUserSigningInUpOrOut': 'true'})
Beispiel #19
0
def sign_up(request):
    form = SignUpForm()
    if request.method == 'POST':
        form = SignUpForm(data=request.POST)
        if form.is_valid():
            form.save()
            return redirect(reverse('example:log_in'))
        else:
            print(form.errors)
    return render(request, 'example/sign_up.html', {'form': form})
Beispiel #20
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            auth_login(request, user)
            return redirect('home')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
Beispiel #21
0
def signup(request):
    sing_up_form = SignUpForm()
    if request.method == 'POST':
        sing_up_form = SignUpForm(request.POST)
        if sing_up_form.is_valid():
            user = sing_up_form.save()
            login(request, user)
            return redirect('home')
    return render(request, 'home.html', {
        'sing_up_form': sing_up_form,
        'sign_in_form': SignInModelForm()
    })
Beispiel #22
0
def index(request):
    if not request.user.is_authenticated():
        if request.method == 'POST':

            if request.POST.get('nomeMsg', '') != "":
                novaMsg = FaleConosco()
                novaMsg.nome = request.POST.get('nomeMsg', '')
                novaMsg.assunto = request.POST.get('assuntoMsg', '')
                novaMsg.email = request.POST.get('emailMsg', '')
                novaMsg.mensagem = request.POST.get('conteudoMsg', '')
                novaMsg.save()
                return redirect('index')

            form = SignUpForm(request.POST)
            form2 = LoginForm(request.POST)
            if form.is_valid():
                user = form.save()
                user.refresh_from_db(
                )  # load the profile instance created by the signal
                #user.profile.data_nascimento = form.cleaned_data.get('data_nascimento')
                user.save()
                username = form.cleaned_data.get('username')
                raw_password = form.cleaned_data.get('password1')
                user = authenticate(username=username, password=raw_password)
                login(request, user)
                return redirect('principal')
            else:
                if form2.is_valid():
                    username = request.POST.get("username")
                    raw_password = request.POST.get("password")
                    user = authenticate(username=username,
                                        password=raw_password)
                    if user is not None:
                        login(request, user)
                        return redirect('principal')
                    else:
                        return render(request, 'erro_login.html', {
                            'form': form,
                            'form2': form2
                        })
                else:
                    return render(request, 'erro_cadastro.html', {
                        'form': form,
                        'form2': form2
                    })

        else:
            form = SignUpForm()
            form2 = LoginForm()
        return render(request, 'index.html', {'form': form, 'form2': form2})
    else:
        return redirect('principal')
Beispiel #23
0
def vistaRegistroIn(request):
	if request.method=='POST':
		form=SignUpForm(request.POST)
		if form.is_valid():
			user=form.save()
			user.set_password(user.password)
			user.save()
			return HttpResponseRedirect('/')
	else:
		form=SignUpForm()

	context={'form':form}
	return render(request,'registro.html',context)
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('home')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})