Esempio n. 1
0
def agree_to_terms(request):

    # Agree to Terms
    # Register for account

    application_title = settings.APPLICATION_TITLE
    DEBUG = settings.DEBUG_SETTINGS

    if DEBUG:
        print(application_title, "in accounts.views.agree_to_terms")

    if request.method == 'POST':
        form = UserCreationForm(data=request.POST)
        if form.is_valid():
            user = form.save()
            return redirect(reverse_lazy('home'))
    else:
        form = UserCreationForm()

    context = {
        "APPLICATION_TITLE": application_title,
        'form': form,
    }
    #   return render_to_response('developer/agree_to_terms.html', RequestContext(request, context,))
    return render_to_response(reverse_lazy('accounts:register'),
                              RequestContext(
                                  request,
                                  context,
                              ))
Esempio n. 2
0
def registration(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect(reverse('home'))
        else:
        	return render(request, "signup.html", {"form": form})
    else:
        form = UserCreationForm()
        context = {"form": form}
        return render(request, "signup.html", context)
Esempio n. 3
0
def registration(request):
    years = [y for y in range(date.today().year-80,date.today().year-10)]
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            new_user = authenticate(email=form.cleaned_data['email'], password=form.cleaned_data['password1'])
            login(request, new_user)
            current_question = Question.objects.all().order_by('?')[:1].get()
            return redirect(current_question)
    else:
        form = UserCreationForm()
    return render(request, "registration.html", {'form': form, 'years':years})
def user_register(request):
    if request.method == 'POST':
        # 如果有post提交的动作,就将post中的数据赋值给uf,供该函数使用
        uf = UserCreationForm(request.POST)
        if uf.is_valid():
            # 读取表单值
            username = uf.cleaned_data['a_username']
            tel = request.POST["tel"]
            a_password = request.POST["a_password"]

            right = None
            try:
                right = request.POST["type"]
            except Exception as e:
                pass

            if right is None:
                right = 'customer'

            # 注册用户表
            user = MyBaseUser.objects.create_user(username=username,
                                                  password=a_password,
                                                  right=right)
            # userID = MyBaseUser.objects.get(username=username)
            if right == 'customer':
                Customer.objects.create(CID=user, name=username, tel=tel)
            else:
                Staff.objects.create(StaNO=user,
                                     StaName=username,
                                     tel=tel,
                                     Position=right)
            auth.login(request, user)
            request.__setattr__('user', user)
            return HttpResponseRedirect('/home')

        else:
            return render(request, 'register.html', {
                'form': uf,
                'error': uf.errors,
                'user': None
            })

    else:
        form = UserCreationForm()
        return render(request, 'register.html', {'form': form, 'user': None})
Esempio n. 5
0
def agree_to_terms(request):
    # Agree to Terms
    # Register for account

    if settings.DEBUG:
        print(settings.APPLICATION_TITLE,
              "in accounts.views.agree_to_terms")

    if request.method == 'POST':
        form = UserCreationForm(data=request.POST)
        if form.is_valid():
            user = form.save()
            return redirect(reverse_lazy('home'))
    else:
        form = UserCreationForm()

    context = {'form': form, }
    #   return render_to_response('developer/agree_to_terms.html', RequestContext(request, context,))
    return render_to_response(reverse_lazy('accounts:register'),
                              RequestContext(request, context, ))
Esempio n. 6
0
    def post(self, request, *args):
        form = UserCreationForm(request.POST)
        profile = ProfileForm(request.POST, request.FILES)
        context = {
            "form": form,
            "profile": profile,
        }
        if form.is_valid() and profile.is_valid():
            user = form.save()
            pro = profile.save(commit=False)

            pro.user = user
            if pro.status != 'ST':
                requests.objects.create(user=user)
            pro.slug = slugify(pro.name)

            pro.save()
            if pro is not None:
                login(request, user)
                return redirect('/home/')

        return render(request, self.template_name, context)