コード例 #1
0
 def test_form_email_exists(self):
     form = SignUpForm(self.user_email_exists)
     form.has_error(
         "email",
         "This Email is already registered. "
         "Please use a different email address.",
     )
コード例 #2
0
    def get_form(self, request):
        """
        Return the SignUp form.

        If incoming request is POST then load form with POST data.

        :param: request: incoming Http request
        :type request: django.http.HttpRequest
        :return: the SignUpForm
        :rtype: register.forms.signup.SignUpForm
        """
        if request.method.upper() == 'POST':
            return SignUpForm(data=request.POST)

        return SignUpForm()
コード例 #3
0
ファイル: views.py プロジェクト: AlexeyLeuhin/spadaroznik_git
def show_profile(request, pk):
    if not request.user.is_authenticated:
        form = SignUpForm()
        return render(request, 'login/login.html', context={'form': form})
    curr_us = get_object_or_404(User, id=pk)
    profile = get_object_or_404(Profile, user=curr_us)
    if request.user == curr_us:
        return render(request, 'profile/ur_profile.html', context={'profile': profile})
    else:
        return render(request, 'profile/not_ur_profile.html', context={'profile': profile, 'pk': pk})
コード例 #4
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, 'register/signup.html', {'form': form})
コード例 #5
0
ファイル: views.py プロジェクト: arif1407013/Esecure
def register(request):
	if request.method == "POST":
		form = SignUpForm(request.POST)
		if form.is_valid():
			form.save()
			username = form.cleaned_data.get('username')
			password = form.cleaned_data.get('password1')
			user = authenticate(request, username = username, password = password)
			login(request, user)
			return redirect('/home')
	else:
		form = SignUpForm()
		context = {
			"form": form
		}
		return render(request, 'register/signin.html', context)
コード例 #6
0
def signup_view(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')
            messages.success(request, f'account created for {username}')
            user = authenticate(username=username, password=raw_password)
            login(request,
                  user,
                  backend='django.contrib.auth.backends.ModelBackend')
            return redirect('reg-profile')
    else:
        form = SignUpForm()
    context = {'form': form, 'title': 'Sign up', "terms": "terms"}
    return render(request, 'signup.html', context)
コード例 #7
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if form.is_valid():
            user = form.save(commit=False)
            user.is_active = False
            user.save()
            current_site = get_current_site(request)
            subject = 'Activate Your MySite Account'
            message = render_to_string('account_activation_email.html', {
                'user': user,
                'domain': current_site.domain,
                'uid': urlsafe_base64_encode(force_bytes(user.pk)),
                'token': account_activation_token.make_token(user),
            })
            user.email_user(subject, message)
            return redirect('account_activation_sent')
    else:
        form = SignUpForm()
    return render(request, 'signup.html', {'form': form})
コード例 #8
0
ファイル: views.py プロジェクト: AlexeyLeuhin/spadaroznik_git
 def get(self, request):
     if not request.user.is_authenticated:
         form = SignUpForm()
         return render(request, 'login/login.html', context={'form': form})
     form = PostForm()
     return render(request, 'posts/create.html', context={'form': form})
コード例 #9
0
ファイル: views.py プロジェクト: AlexeyLeuhin/spadaroznik_git
 def get(self, request):
     if not request.user.is_authenticated:
         form = SignUpForm()
         return render(request, 'login/login.html', context={'form': form})
     form = ProfileRedactForm()
     return render(request, 'profile/ur_profile_redact.html', context={'form': form})
コード例 #10
0
 def test_form_dob_valid(self):
     form = SignUpForm(self.user)
     self.assertTrue(form.is_valid())
コード例 #11
0
 def test_form_dob_invalid_future(self):
     form = SignUpForm(self.user_invalid_dob_future)
     form.has_error(
         "dob",
         "Invalid Date of Birth",
     )
コード例 #12
0
 def test_form_username_exists(self):
     form = SignUpForm(self.user_name_exists)
     form.has_error("username", "A user with that username already exists.")
コード例 #13
0
 def test_form_not_valid(self):
     form = SignUpForm(self.user_no_username)
     self.assertFalse(form.is_valid())