Пример #1
0
def registration(request):
    if request.POST:
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_user = User.objects.create_user(form.cleaned_data['username'],
                                                form.cleaned_data['email'],
                                                form.cleaned_data['password'])
            new_user.is_active = True
            new_user.save()
            user = authenticate(username=form.cleaned_data['username'],
                                password=form.cleaned_data['password'])
            auth.login(request, user)

            profile = Profile(user=new_user,
                              nick=form.cleaned_data['username'])
            profile.save()

            send_registration_letter(profile)

            Subscription.add(email=form.cleaned_data['email'], auto_confirm=True)

            return HttpResponseRedirect('/')
    else:
        form = RegistrationForm(initial={})

    return render_to_response(request, 'registration.html', {'form': form})
Пример #2
0
    def forwards(self, orm):
        "Write your forwards methods here."

        for user in User.objects.all():
            s = Subscription(email=user.email)
            s.fill_codes()
            s.confirm(s.confirmation_code)
Пример #3
0
    def forwards(self, orm):
        "Write your forwards methods here."

        for email in open(os.path.join(os.path.dirname(__file__), 'emails.txt')).read().split(';'):
            s = Subscription(email=email.strip())
            s.fill_codes()
            s.confirm(s.confirmation_code)
Пример #4
0
def registration(request):
    if request.POST:
        form = RegistrationForm(request.POST)
        if form.is_valid():
            new_user = User.objects.create_user(
                form.cleaned_data["name"], form.cleaned_data["email"], form.cleaned_data["password"]
            )
            new_user.is_active = True
            new_user.save()
            user = authenticate(username=form.cleaned_data["name"], password=form.cleaned_data["password"])
            auth.login(request, user)

            profile = Profile(user=new_user, nick=form.cleaned_data["name"])
            profile.save()

            send_registration_letter(profile)

            Subscription.add(email=form.cleaned_data["email"])

            return HttpResponseRedirect("/")
    else:
        form = RegistrationForm(initial={})

    return render_to_response(request, "registration.html", {"form": form})