Ejemplo n.º 1
0
def mix_of_login_register(request, slug):
    """
        Template contains 2 forms, the login and the registration
        """
    if slug == 'doer':
        is_doer = True
        is_poster = False
    elif slug == 'poster':
        is_poster = True
        is_doer = False
    if request.user.is_authenticated():
        return HttpResponseRedirect('/dashboard/')
    if 'login' in request.POST:
        return LoginRequest(request)
    elif 'register' in request.POST:
        return PersonRegistration(request, slug)
    else:
        form = LoginForm()
        form2 = RegistrationForm()
        context = {
            'form': form,
            'form2': form2,
            'is_doer': is_doer,
            'is_poster': is_poster,
        }
        return render_to_response('mixlogin.html',
                                  context,
                                  context_instance=RequestContext(request))
Ejemplo n.º 2
0
	def get(self,request,*args,**kwargs):
		form=RegistrationForm()
		context={
		"title":"testing",
		"form":form
		}
		return render(request,"offlinereg.html",context)
Ejemplo n.º 3
0
	def post(self,request,*args,**kwargs):
		form=RegistrationForm(request.POST)
		context={
		"title":"testing",
		"form":form
		}

		if form.is_valid():
			mail=form.cleaned_data.get('email')
			name=form.cleaned_data.get('name')
			phone=form.cleaned_data.get('phone')
			college=form.cleaned_data.get('college')
			stay=form.cleaned_data.get('stay')
			code=uniqueid('6')
			u=userinfo(excelid=code,name=name,college=college,email=mail,phone=phone,stay=stay,present=True)
			u.save()
			#flag for offlinereg or paidreg
			flag=0

			context = {
				"excelid":code,
				"flag" : flag
			}
			return render(request,"excelid.html",context)
		return render(request,"offlinereg.html",context)
Ejemplo n.º 4
0
def accept(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            return render(request, 'done.html')
    return render(request, 'signup.html')
Ejemplo n.º 5
0
    def get(self, request, *args, **kwargs):

        context_dict = {
            'too_many_registrations_error': TOO_MANY_REGISTRATIONS_ERROR,
            'choices': UserRegistration.BICYCLE_CHOICES,
            'show_steps': True,
            'step_2': 'class="active"',
            'form': RegistrationForm()
        }
        return render(request, self.template_name, context_dict)
Ejemplo n.º 6
0
def signup(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            print("signup posted valid form")
            client = boto3.client('ses', region_name='us-east-1')
            user = form.save(commit=False)
            user.is_active = False
            user.save()
            current_site = get_current_site(request)
            subject = 'Activate Your WorkTracker Account'
            message = render_to_string(
                'account_activation_email.html', {
                    'user': user,
                    'domain': current_site.domain,
                    'uid': urlsafe_base64_encode(force_bytes(
                        user.pk)).decode(),
                    'token': account_activation_token.make_token(user),
                })
            response = client.send_email(Source='*****@*****.**',
                                         Destination={
                                             'ToAddresses': [
                                                 form.cleaned_data['username'],
                                             ],
                                         },
                                         Message={
                                             'Subject': {
                                                 'Data': subject,
                                             },
                                             'Body': {
                                                 'Html': {
                                                     'Data': message,
                                                 }
                                             }
                                         },
                                         ReplyToAddresses=[
                                             '*****@*****.**',
                                         ])
            print(response)
            return redirect('login')
    else:
        form = RegistrationForm()
    return render(request, 'register.html', {'form': form})
Ejemplo n.º 7
0
 def test_registration_form_valid_data(self):
     form = RegistrationForm(
         data={
             'first_name': 'John',
             'last_name': 'Smith',
             'username': '******',
             'email': '*****@*****.**',
             'password1': 'openplease123',
             'password2': 'openplease123'
         })
     self.assertTrue(form.is_valid())
Ejemplo n.º 8
0
    def post(self, request):
        form = RegistrationForm(request.POST)
        if form.is_valid():
            userObj = form.cleaned_data
            email = userObj['Email']
            password = userObj['Password']
            text = ''
            if not (USER.objects.filter(Email=email).exists()
                    or USER.objects.filter(Password=password)):
                form.save()
            else:
                return HttpResponse(
                    'Looks like a username with that email or password already exists'
                )

        else:
            form = RegistrationForm()

        args = {'form': form, 'text': text}
        return render(request, 'html/register.html', args)
Ejemplo n.º 9
0
 def test_registration_form_invalid_data(self):
     form = RegistrationForm(
         data={
             'first_name': 'John',
             'last_name': 'Smith',
             'username': '******',
             'email': '*****@*****.**',
             'password1': 'openplease1234',
             'password2': 'openplease123'
         })
     self.assertFalse(form.is_valid())
     self.assertEquals(len(form.errors), 1)
Ejemplo n.º 10
0
def register(request):
    form = RegistrationForm(request.POST or None)
    if form.is_valid():
        user = Register()
        user.name = form.cleaned_data['username']
        user.mobileNo = form.cleaned_data['mobileNo']
        user.password = form.cleaned_data['password1']
        user.email = form.cleaned_data['email']
        user.save()
        request.session['username'] = user.name

        return HttpResponseRedirect('/restaurant/')
    return render(request, 'register/signUp.html', {'form': form})
Ejemplo n.º 11
0
	def post(self,request,*args,**kwargs):
		form = RegistrationForm()
		context = {
		"title": "testing",
		"form": form
		}
		if form.is_valid():
			mail = form.cleaned_data.get('email')
			name = form.cleaned_data.get('name')
			phone = form.cleaned_data.get('phone')
			college = form.cleaned_data.get('college')
			stay1 = form.cleaned_data.get('stay')
			code = uniqueid('6')
			u = userinfo(excelid=code, name=name, college=college, email=mail, phone=phone, stay=stay1)
			u.save()
			# obj=userinfo.objects.get(email=mail)
			# im=pyqrcode.create(obj.excelid)
			# im.svg('static/qrcodes/%s.svg'%(obj.excelid),scale=20)
			return render(request,"success.html",{"name":name})

		return render(request,"home.html",context)
Ejemplo n.º 12
0
    def post(self, request, *args, **kwargs):
        form = RegistrationForm(request.POST)
        context = {"title": "testing", "form": form}
        print(form)
        if form.is_valid():
            mail = form.cleaned_data.get('email')
            name = form.cleaned_data.get('name')
            phone = form.cleaned_data.get('phone')
            college = form.cleaned_data.get('college')
            code = 'EX' + uniqueid(7)
            u = userinfo(excelid=code,
                         name=name,
                         college=college,
                         email=mail,
                         phone=phone,
                         outsider=True)
            u.save()
            # obj=userinfo.objects.get(email=mail)
            # im=pyqrcode.create(obj.excelid)
            # im.svg('static/qrcodes/%s.svg'%(obj.excelid),scale=20)
            context = {"excelid": code, "flag": 2}
            return render(request, "excelid.html", context)

        return render(request, "home.html", context)
Ejemplo n.º 13
0
def PersonRegistration(request, slug):

    if slug == 'doer':
        is_doer = True
        is_poster = False
    elif slug == 'poster':
        is_poster = True
        is_doer = False

    if request.user.is_authenticated():
        return HttpResponseRedirect('/profile/')
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
                username=form.cleaned_data['email'],
                email=form.cleaned_data['email'],
                password=form.cleaned_data['password'],
            )
            firstname = form.cleaned_data['firstname']
            lastname = form.cleaned_data['lastname']
            user.first_name = firstname
            user.last_name = lastname
            name = '%s %s' % (user.first_name, user.last_name)
            p = PersonClassification.objects.get(slug=slug)
            a = slug
            slug = str(user.id) + str(datetime.now().day) + str(
                datetime.now().year)
            skills = form.cleaned_data['skills']
            person = Person(
                person=user,
                person_class=p,
                is_verified=False,
                is_active=False,
                address=form.cleaned_data['address'],
                birthday=form.cleaned_data['birthday'],
                firstname=form.cleaned_data['firstname'],
                lastname=form.cleaned_data['lastname'],
                created_at=datetime.now(),
                contactno=form.cleaned_data['contactno'],
                #classification = a,
            )

            user.save()
            person.save()
            person.skills = skills
            if person.person_class.__str__() == 'poster':
                template = 'register_poster.html'
            else:
                template = 'register_doer.html'
            '''
                        send verification instructions to user
                        '''
            subject = 'Welcome to Tulong.ph'
            message = 'Hi %s we from tulong.ph, gladly welcomes you. Please reply to this email if you have any questions.' % person.firstname
            to = person.person.email
            #send_mail(subject,message,'*****@*****.**',[to],fail_silently=False)

            name = "%s %s" % (person.firstname, person.lastname)
            context = {'full_name': name, 'person': person}
            text_content = render_to_string('email/register.html', context)
            html_content = render_to_string('email/register_html.html',
                                            context)
            msg = EmailMultiAlternatives(subject, text_content,
                                         settings.EMAIL_HOST_USER, [to])
            msg.attach_alternative(html_content, "text/html")
            msg.send()
            #send_mail(subject, email_content,
            #        settings.EMAIL_HOST_USER, [to],fail_silently=False)
            '''
                        send the new user to the admin 
                        '''
            person_classification = person.person_class.__str__()
            subject = 'New User as %s' % (person_classification)
            message = 'User %s Registered as %s ' % (person.person.email,
                                                     person_classification)
            to = '*****@*****.**'
            send_mail(subject,
                      message,
                      '*****@*****.**', [to],
                      fail_silently=False)

            return render_to_response(template, {
                'status': person,
                'is_doer': is_doer,
                'is_poster': is_poster,
            },
                                      context_instance=RequestContext(request))
            #return HttpResponseRedirect('/login/')
        else:
            return render_to_response('register.html', {
                'form': form,
                'is_doer': is_doer,
                'is_poster': is_poster,
            },
                                      context_instance=RequestContext(request))

    else:
        ''' user is not submitting the form, show them a blank registration form '''
        form = RegistrationForm()
        context = {
            'form': form,
            'is_doer': is_doer,
            'is_poster': is_poster,
        }
        return render_to_response('register.html',
                                  context,
                                  context_instance=RequestContext(request))
Ejemplo n.º 14
0
def registration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/profile/')
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
                username=form.cleaned_data['email'],
                email=form.cleaned_data['email'],
                password=form.cleaned_data['password'],
            )
            firstname = form.cleaned_data['firstname']
            lastname = form.cleaned_data['lastname']
            user.first_name = firstname
            user.last_name = lastname
            name = '%s %s' % (user.first_name, user.last_name)

            a = request.session['classification']
            p = PersonClassification.objects.get(slug=a)
            slug = str(user.id) + str(datetime.now().day) + str(
                datetime.now().year)
            skills = form.cleaned_data['skills'],
            person = Person(
                person=user,
                person_class=p,
                is_verified=False,
                is_active=False,
                address=form.cleaned_data['address'],
                birthday=form.cleaned_data['birthday'],
                firstname=form.cleaned_data['firstname'],
                lastname=form.cleaned_data['lastname'],
                created_at=datetime.now(),
                contactno=form.cleaned_data['contactno'],
                classification=a,
            )

            user.save()
            person.save()
            person.skills = skills
            if a == 'poster':
                template = 'register_poster.html'
            else:
                template = 'register_doer.html'
            '''
                        send verification instructions to user
                        '''
            subject = 'Welcome to Tulong.ph'
            message = 'Hi %s we from tulong.ph, gladly welcomes you. Please reply to this email if you have any questions.' % person.firstname
            to = person.person.email
            email_from = '*****@*****.**'
            send_mail(subject, message, email_from, [to], fail_silently=False)
            '''
                        send the new user to the admin 
                        '''
            subject = 'new user'
            message = 'user %s registered' % person.firstname
            to = email_from
            send_mail(subject, message, email_from, [to], fail_silently=False)

            return render_to_response(template, {'status': person},
                                      context_instance=RequestContext(request))

        else:
            return render_to_response(
                'register.html', {
                    'form': form,
                    'test': request.session['classification'],
                },
                context_instance=RequestContext(request))

    else:
        ''' user is not submitting the form, show them a blank registration form '''
        form = RegistrationForm()
        context = {
            'form': form,
            'test': request.session['classification'],
        }
        return render_to_response('register.html',
                                  context,
                                  context_instance=RequestContext(request))
Ejemplo n.º 15
0
 def test_registration_form_no_data(self):
     form = RegistrationForm(data={})
     self.assertFalse(form.is_valid())
     self.assertEquals(len(form.errors), 6)
Ejemplo n.º 16
0
 def get(self, request):
     form = RegistrationForm()
     return render(request, 'html/register.html', {'form': form})