From 04d0cece8a2b35683f8792de333e3ea76ff51139 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Thu, 24 May 2018 14:28:28 +0200 Subject: [PATCH] newsletter option for social signup --- src/wolnelektury/forms.py | 12 ++++++++++ .../templates/socialaccount/signup.html | 23 +++++++++++++++++++ src/wolnelektury/urls.py | 1 + src/wolnelektury/views.py | 9 ++++++-- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/wolnelektury/templates/socialaccount/signup.html diff --git a/src/wolnelektury/forms.py b/src/wolnelektury/forms.py index 053178aa1..b253cdfb9 100644 --- a/src/wolnelektury/forms.py +++ b/src/wolnelektury/forms.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from allauth.socialaccount.forms import SignupForm from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.models import User @@ -19,3 +20,14 @@ także w celu przesyłania newslettera Wolnych Lektur.''' def save(self, commit=True): super(RegistrationForm, self).save(commit=commit) NewsletterForm.save(self) + + +class SocialSignupForm(SignupForm, NewsletterForm): + data_processing_part2 = u'''\ +Dane są przetwarzane w zakresie niezbędnym do prowadzenia serwisu, a także w celach prowadzenia statystyk, \ +ewaluacji i sprawozdawczości. W przypadku wyrażenia dodatkowej zgody adres e-mail zostanie wykorzystany \ +także w celu przesyłania newslettera Wolnych Lektur.''' + + def save(self, request): + super(SocialSignupForm, self).save(request) + NewsletterForm.save(self) diff --git a/src/wolnelektury/templates/socialaccount/signup.html b/src/wolnelektury/templates/socialaccount/signup.html new file mode 100644 index 000000000..78df711bb --- /dev/null +++ b/src/wolnelektury/templates/socialaccount/signup.html @@ -0,0 +1,23 @@ +{% extends "socialaccount/base.html" %} + +{% load i18n %} + +{% block head_title %}{% trans "Signup" %}{% endblock %} + +{% block content %} +

{% trans "Sign Up" %}

+ +

{% blocktrans with provider_name=account.get_provider.name site_name=site.name %}You are about to use your {{provider_name}} account to login to +{{site_name}}. As a final step, please complete the following form:{% endblocktrans %}

+ +
+ {% csrf_token %} + {{ form.as_p }} + {% if redirect_field_value %} + + {% endif %} +

{{ form.data_processing }}

+ +
+ +{% endblock %} diff --git a/src/wolnelektury/urls.py b/src/wolnelektury/urls.py index fbc458d16..fa011086a 100644 --- a/src/wolnelektury/urls.py +++ b/src/wolnelektury/urls.py @@ -25,6 +25,7 @@ urlpatterns = [ url(r'^uzytkownik/signup/$', views.RegisterFormView(), name='register'), url(r'^uzytkownik/logout/$', views.logout_then_redirect, name='logout'), url(r'^uzytkownik/zaloguj-utworz/$', views.LoginRegisterFormView(), name='login_register'), + url(r'^uzytkownik/social/signup/$', views.SocialSignupView.as_view(), name='socialaccount_signup'), # Includes. url(r'^latests_blog_posts.html$', views.latest_blog_posts, name='latest_blog_posts'), diff --git a/src/wolnelektury/views.py b/src/wolnelektury/views.py index 6108122c7..28ce22374 100644 --- a/src/wolnelektury/views.py +++ b/src/wolnelektury/views.py @@ -4,11 +4,12 @@ # from datetime import date, datetime import feedparser +from allauth.socialaccount.views import SignupView from django.conf import settings from django.contrib import auth from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import UserCreationForm, AuthenticationForm +from django.contrib.auth.forms import AuthenticationForm from django.core.cache import cache from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import render @@ -22,7 +23,7 @@ from catalogue.models import Book, Collection, Tag, Fragment from ssify import ssi_included from social.utils import get_or_choose_cite -from wolnelektury.forms import RegistrationForm +from wolnelektury.forms import RegistrationForm, SocialSignupForm def main_page(request): @@ -186,6 +187,10 @@ def widget(request): return render(request, 'widget.html') +class SocialSignupView(SignupView): + form_class = SocialSignupForm + + def exception_test(request): msg = request.GET.get('msg') if msg: -- 2.20.1