newsletter option for social signup
authorJan Szejko <janek37@gmail.com>
Thu, 24 May 2018 12:28:28 +0000 (14:28 +0200)
committerJan Szejko <janek37@gmail.com>
Thu, 24 May 2018 12:28:28 +0000 (14:28 +0200)
src/wolnelektury/forms.py
src/wolnelektury/templates/socialaccount/signup.html [new file with mode: 0644]
src/wolnelektury/urls.py
src/wolnelektury/views.py

index 053178a..b253cdf 100644 (file)
@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
 # -*- coding: utf-8 -*-
+from allauth.socialaccount.forms import SignupForm
 from django.contrib.auth.forms import UserCreationForm
 from django.contrib.auth.models import User
 
 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)
     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 (file)
index 0000000..78df711
--- /dev/null
@@ -0,0 +1,23 @@
+{% extends "socialaccount/base.html" %}
+
+{% load i18n %}
+
+{% block head_title %}{% trans "Signup" %}{% endblock %}
+
+{% block content %}
+    <h1>{% trans "Sign Up" %}</h1>
+
+<p>{% 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 %}</p>
+
+<form class="signup" id="signup_form" method="post" action="{% url 'socialaccount_signup' %}">
+  {% csrf_token %}
+  {{ form.as_p }}
+  {% if redirect_field_value %}
+  <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
+  {% endif %}
+  <p><span class="helptext">{{ form.data_processing }}</span></p>
+  <button type="submit">{% trans "Sign Up" %} &raquo;</button>
+</form>
+
+{% endblock %}
index fbc458d..fa01108 100644 (file)
@@ -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/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'),
 
     # Includes.
     url(r'^latests_blog_posts.html$', views.latest_blog_posts, name='latest_blog_posts'),
index 6108122..28ce223 100644 (file)
@@ -4,11 +4,12 @@
 #
 from datetime import date, datetime
 import feedparser
 #
 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.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
 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 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):
 
 
 def main_page(request):
@@ -186,6 +187,10 @@ def widget(request):
     return render(request, 'widget.html')
 
 
     return render(request, 'widget.html')
 
 
+class SocialSignupView(SignupView):
+    form_class = SocialSignupForm
+
+
 def exception_test(request):
     msg = request.GET.get('msg')
     if msg:
 def exception_test(request):
     msg = request.GET.get('msg')
     if msg: