Esempio n. 1
0
def existeUsuario(request):
    #registra los valores Users
    usuarios=User.objects.all()
    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
            username1 = form.cleaned_data["username"]

            existe=0
            for u in usuarios:
                if u.username == username1:
                    existe=1
                    break

            response = render_to_response(
                'json/validar.json',
                {'existe':existe},
                context_instance=RequestContext(request)
                )
            response['Content-Type'] = 'application/json; charset=utf-8'
            response['Cache-Control'] = 'no-cache'
            return response
Esempio n. 2
0
def signup_view(request):
    form = SignUpForm(request.POST)
    if form.is_valid():
        form.save()
        username = form.cleaned_data.get('username')
        password = form.cleaned_data.get('password1')
        email = form.cleaned_data.get('email')
        user = authenticate(username=username, password=password)
        login(request, user)
        html_message = render_to_string('mail/mail.html', {'Head': 'Hi. Please confirm your email!',
                                                           'Body': 'You are registered on the spark portal. Confirm your mail!',
                                                           'button': 'Confirm',
                                                           'href': 'pumpskills.com'
                                                           })
        plain_message = strip_tags(html_message)
        send_mail(
            _('registration on the site'),
            plain_message,
            '*****@*****.**',
            [email],
            html_message = html_message,
            fail_silently=False,
        )
        return HttpResponseRedirect(reverse('cabinet'))
    else:
        form = SignUpForm()
    return render(request, 'login/signup.html', {'form': form})
Esempio n. 3
0
def handle_signup(request, pk):
  if not request.method == 'POST':
    response = HttpResponse('Method not allowed')
    response.status_code = 405
    return response

  event = Event.objects.get(pk=pk)
  if not event:
    return HttpResponseServerError

  if event.booked:
    response = HttpResponse('Tapahtuma on täynnä.')
    response.status_code = 400
    return response

  if event.signup_open and event.signup_open > timezone.now():
    response = HttpResponse('Ilmoittautuminen suljettu.')
    response.status_code = 400
    return response

  form = SignUpForm(data=request.POST)
  if form.is_valid():
    signup = SignUp.objects.create(event=event, **form.cleaned_data)
    try:
      send_signup_confirmation(signup.email, signup.guardian, event.title, event.organizer)
    except:
      for exc in sys.exc_info():
        print(exc)

    return HttpResponse('Kiitos ilmoittautumisesta!')
  else:
    return HttpResponseServerError
Esempio n. 4
0
def sign_up(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            user.is_active = True
            user.save()
            return redirect("login")
    else:
        form = SignUpForm()

    return render(request, 'signup.html', {'signupForm': form})
Esempio n. 5
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)
            return redirect('/home/')
    else:
        form = SignUpForm()
    return render(request, 'web/signup.html', {'form': form})
Esempio n. 6
0
def signup(request):
    if request.method != 'POST':
        return render(request, 'web/signup.html', {'form': SignUpForm()})

    form = SignUpForm(request.POST)

    if not form.is_valid():
        return render(request, 'web/signup.html', {'form': form})

    username = form.cleaned_data.get('username')
    email = form.cleaned_data.get('email')
    password = form.cleaned_data.get('password')

    User.objects.create_user(username=username, password=password, email=email)

    user = authenticate(username=username, password=password)
    login(request, user)

    return redirect('/')
Esempio n. 7
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save()
            user.refresh_from_db(
            )  # load the profile instance created by the signal
            user.profile.run = form.cleaned_data.get('run')
            user.profile.fecha_nacimiento = form.cleaned_data.get(
                'fecha_nacimiento')
            user.profile.region = form.cleaned_data.get('region')
            user.profile.ciudad = form.cleaned_data.get('ciudad')
            user.profile.tipo_vivienda = form.cleaned_data.get('tipo_vivienda')
            user.save()
            messages.success(request, 'Usuario Agregado')

            return redirect('login')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})