diff options
-rw-r--r-- | accounts/templates/accounts/signup.html | 14 | ||||
-rw-r--r-- | accounts/templates/accounts/terms.html | 27 | ||||
-rw-r--r-- | accounts/urls.py | 3 | ||||
-rw-r--r-- | accounts/views.py | 39 | ||||
-rw-r--r-- | client/templates/client/about.html | 2 | ||||
-rw-r--r-- | templates/registration/base_simple.html | 4 |
6 files changed, 81 insertions, 8 deletions
diff --git a/accounts/templates/accounts/signup.html b/accounts/templates/accounts/signup.html index a8a517c..56b5a4c 100644 --- a/accounts/templates/accounts/signup.html +++ b/accounts/templates/accounts/signup.html @@ -12,10 +12,24 @@ {% csrf_token %} {{ form.as_p }} <br> + <label> + <input name="terms_accept" type="checkbox" class="filled-in"/> + <span style="color:black">Accetto i <a href="{% url 'terms' %}">Termini e condizioni generali</a></span> + </label> + <br> + <br> <button class="btn waves-effect waves-light" type="submit">Invia</button> </form> </div> </div> </div> </div> +{% endblock %} + +{% block script %} +{% if error %} +document.addEventListener('DOMContentLoaded', function() { + M.toast({html: '{{ error_text }}', classes: 'orange'}) +}); +{% endif %} {% endblock %}
\ No newline at end of file diff --git a/accounts/templates/accounts/terms.html b/accounts/templates/accounts/terms.html new file mode 100644 index 0000000..c72e006 --- /dev/null +++ b/accounts/templates/accounts/terms.html @@ -0,0 +1,27 @@ +{% extends 'registration/base_client.html' %} + +{% block title %}About{% endblock %} + +{%block nav%} + <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a> + <a href="!#" class="breadcrumb hide-on-med-and-down">Termini e condizioni</a> +{% endblock%} + +{% block content %} + <div class="row"> + <div class="col l4 offset-l4 m8 offset-m2 s12"> + <div class="card"> + <div class="card-content"> + <h5>Termini e condizioni</h5> + <blockquote> + Termine 1 ecc...... + Cose + </blockquote> + </div> + </div> + </div> + </div> +{% endblock %} + +{% block script %} +{% endblock %}
\ No newline at end of file diff --git a/accounts/urls.py b/accounts/urls.py index a2d8541..6a44457 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -3,6 +3,7 @@ from django.urls import path, include from . import views urlpatterns = [ - path('signup/', views.SignUp.as_view(), name='signup'), + path('signup/', views.signup, name='signup'), path('personal/', views.personal, name='personal'), + path('terms/', views.terms, name='terms'), ] diff --git a/accounts/views.py b/accounts/views.py index 23f4212..31786b1 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -1,11 +1,13 @@ from django.shortcuts import render from django.contrib.auth.forms import UserCreationForm -from django.urls import reverse_lazy +from django.contrib.auth import login, authenticate from django.views import generic from django.contrib.auth.models import Group from django.core.files.storage import FileSystemStorage from django.http import FileResponse from django.contrib.auth.decorators import login_required +from django.views.decorators.debug import sensitive_variables +from django.http import HttpResponseRedirect from client.models import UserCode @@ -14,10 +16,31 @@ from io import BytesIO from PIL import Image, UnidentifiedImageError -class SignUp(generic.CreateView): - form_class = UserCreationForm - success_url = reverse_lazy('login') - template_name = 'accounts/signup.html' +@sensitive_variables("raw_passsword") +def signup(request): + if request.method == 'POST': + if "terms_accept" not in request.POST: + form = UserCreationForm() + context = { + "form": form, + "error": True, + "error_text": "Accettare i termini e condizioni prego" + } + return render(request, 'accounts/signup.html', context) + form = UserCreationForm(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 HttpResponseRedirect('/') + else: + form = UserCreationForm() + context = { + "form": form, + } + return render(request, 'accounts/signup.html', context) @login_required @@ -218,4 +241,8 @@ def personal(request): 'error_text': error_text, } - return render(request, 'accounts/index.html', context)
\ No newline at end of file + return render(request, 'accounts/index.html', context) + +def terms(request): + context = {} + return render(request, 'accounts/terms.html', context)
\ No newline at end of file diff --git a/client/templates/client/about.html b/client/templates/client/about.html index 5f7e27f..64db725 100644 --- a/client/templates/client/about.html +++ b/client/templates/client/about.html @@ -34,7 +34,7 @@ </blockquote> <h5>Codice sorgente</h5> <blockquote> - <a href=git.thearcway.org>git.thearcway.org</a> + <a href="https://git.thearcway.org/mafaldo/scout-subs/">https://git.thearcway.org/mafaldo/scout-subs/</a> </blockquote> </div> </div> diff --git a/templates/registration/base_simple.html b/templates/registration/base_simple.html index ecafd0c..6876e83 100644 --- a/templates/registration/base_simple.html +++ b/templates/registration/base_simple.html @@ -14,5 +14,9 @@ {% endblock %} </main> <script type="text/javascript" src="{% static 'materialize.min.js' %}"></script> + <script type="text/javascript"> + {% block script %} + {% endblock %} + </script> </body> </html>
\ No newline at end of file |