Commit c7334016 authored by Noe Nieto's avatar Noe Nieto 💬

Register form with redirection to woocommerce (Not tested yet. Ref liberty/internal#111)

parent 1a1dccf4
......@@ -2,11 +2,11 @@ from django.db import models
from django.contrib.auth import get_user_model
# User = get_user_model()
User = get_user_model()
# Create your models here.
class ChosenReward(models.Model):
# user = models.OneToOneField(User)
user = models.OneToOneField(User)
reward = models.IntegerField()
from django import forms
from django.conf import settings
from registration.backends.simple.views import RegistrationView
from ldapregister.forms import RegistrationForm
from captcha.fields import CaptchaField
......@@ -15,15 +15,18 @@ class CrowdFundRegistrationView(RegistrationView):
# success_url = None
template_name = 'crowdfund/registration_form.html'
def get(self, *args, **kwargs):
self.reward = kwargs.pop('reward')
return super().get(*args, **kwargs)
def post(self, *args, **kwargs):
self.reward = kwargs.get('reward', None)
return super().post(*args, **kwargs)
def get_success_url(self, user):
return 'http://shop.liberty.one/'
return '{}/{}'.format(
getattr(settings, 'WOO_URL'),
str(self.reward)
)
def register(self, form):
usr = super(CrowdFundRegistrationView).register(form)
usr = super().register(form)
reward = ChosenReward(user=usr, reward=self.reward)
reward.save()
return usr
......@@ -193,3 +193,14 @@ LOGGING = {
},
},
}
#
# Captcha
#
CAPTCHA_FONT_SIZE=40
CAPTCHA_TIMEOUT = 15
CAPTCHA_LENGTH = 4
CAPTCHA_TEST_MODE = True
CAPTCHA_CHALLENGE_FUNCT = 'captcha.helpers.math_challenge'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment