aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Lepori <alepori@student.ethz.ch>2020-06-19 15:05:59 +0200
committerAndrea Lepori <alepori@student.ethz.ch>2020-06-19 15:05:59 +0200
commit619e0e0f5263875b753334483d9b896194e9a61d (patch)
tree861b970de54b77ad715aa9d4177eaaad384c198a
parentinitial commit (diff)
downloadscout-subs-619e0e0f5263875b753334483d9b896194e9a61d.tar.gz
scout-subs-619e0e0f5263875b753334483d9b896194e9a61d.zip
More data for users
-rw-r--r--accounts/templates/accounts/index.html146
-rw-r--r--accounts/templates/accounts/signup.html23
-rw-r--r--accounts/urls.py1
-rw-r--r--accounts/views.py78
-rw-r--r--client/migrations/0003_auto_20200619_1044.py87
-rw-r--r--client/migrations/0004_auto_20200619_1045.py24
-rw-r--r--client/migrations/0005_auto_20200619_1047.py24
-rw-r--r--client/migrations/0006_auto_20200619_1049.py24
-rw-r--r--client/models.py31
-rw-r--r--client/templates/client/approve.html33
-rw-r--r--client/templates/client/index.html45
-rw-r--r--client/views.py21
-rw-r--r--server/templates/server/approve_user.html14
-rw-r--r--server/templates/server/index.html14
-rw-r--r--server/templates/server/user_list.html14
-rw-r--r--server/views.py50
-rw-r--r--templates/registration/base.html30
-rw-r--r--templates/registration/base_custom.html55
-rw-r--r--templates/registration/base_simple.html17
-rw-r--r--templates/registration/login.html22
20 files changed, 656 insertions, 97 deletions
diff --git a/accounts/templates/accounts/index.html b/accounts/templates/accounts/index.html
new file mode 100644
index 0000000..c01878c
--- /dev/null
+++ b/accounts/templates/accounts/index.html
@@ -0,0 +1,146 @@
+{% extends 'registration/base_custom.html' %}
+
+{% block title %}Home{% endblock %}
+
+{%block nav%}
+ <nav class="nav-extended">
+ <div class="nav-wrapper red lighten-1">
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Account</a>
+ <ul class="right">
+ {% if user.is_staff %}
+ <li><a href="{% url 'server' %}">Pannello Admin</a></li>
+ {% endif %}
+ {% if user.is_authenticated %}
+ <li><a href="{% url 'personal' %}">{{ user.username }}</a></li>
+ {% endif %}
+ {% if user.username != "" %}
+ <li>
+ <a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a>
+ </li>
+ {% else %}
+ <li><a href="{% url 'signup' %}">Registrazione</a></li>
+ <li><a href="{% url 'login' %}">Login</a></li>
+ {% endif %}
+ </ul>
+ </div>
+ <div class="nav-content red lighten-1">
+ <ul class="tabs tabs-transparent">
+ <li class="tab"><a class="active" href="#personal">Info Personali</a></li>
+ <li class="tab"><a href="#medic">Info Mediche</a></li>
+ </ul>
+ </div>
+ </nav>
+
+ <ul class="sidenav" id="mobile-demo">
+ {% if user.is_staff %}
+ <li><a href="{% url 'server' %}">Pannello Admin</a></li>
+ {% endif %}
+ {% if user.is_authenticated %}
+ <li><a href="{% url 'personal' %}">{{ user.username }}</a></li>
+ {% endif %}
+ {% if user.username != "" %}
+ <li>
+ <a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a>
+ </li>
+ {% else %}
+ <li><a href="{% url 'signup' %}">Registrazione</a></li>
+ <li><a href="{% url 'login' %}">Login</a></li>
+ {% endif %}
+ </ul>
+{% endblock%}
+
+{% block content %}
+<div id="personal" class="row">
+ <div class="col l8 offset-l2 s12">
+ <div class="card-panel">
+ <div class="row">
+ <form action="{% url 'personal'%}" method="post" id="personal_form" class="col s12">
+ {% csrf_token %}
+ <div class="row">
+ <div class="input-field col s4">
+ <input name="first_name" value="{{first_name}}" id="first_name" type="text" class="validate">
+ <label for="first_name">First Name</label>
+ </div>
+ <div class="input-field col s4">
+ <input name="last_name" value="{{last_name}}" id="last_name" type="text" class="validate">
+ <label for="last_name">Last Name</label>
+ </div>
+ <div class="input-field col s4">
+ <input name="birth_date" value="{{birth_date}}" id="birth_date" type="text" class="datepicker">
+ <label for="birth_date">Data di nascita</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s4">
+ <select name="branca">
+ <option value="" disabled {{branca_default}}>Scegli</option>
+ <option value="colonia" {{branca_castorini}}>Castorini</option>
+ <option value="muta" {{branca_lupetti}}>Lupetti</option>
+ <option value="reparto" {{branca_esploratori}}>Esploratori</option>
+ <option value="posto" {{branca_pionieri}}>Pionieri</option>
+ <option value="clan" {{branca_rover}}>Rover</option>
+ </select>
+ <label>Branca</label>
+ </div>
+ <div class="input-field col s8">
+ <input value="{{parent_name}}" name="parent_name" id="parent_name" type="text" class="validate">
+ <label for="parent_name">Nome dei genitori</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s12">
+ <input value="{{via}}" name="via" id="via" type="text" class="validate">
+ <label for="via">Via e numero</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s4">
+ <input value="{{cap}}" name="cap" id="cap" type="text" class="validate">
+ <label for="cap">CAP</label>
+ </div>
+ <div class="input-field col s4">
+ <input value="{{country}}" name="country" id="country" type="text" class="validate">
+ <label for="country">Paese</label>
+ </div>
+ <div class="input-field col s4">
+ <input value="{{nationality}}" name="nationality" id="nationality" type="text" class="validate">
+ <label for="nationality">Nazionalita`</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s4">
+ <input value="{{phone}}" name="phone" id="phone" type="text" class="validate">
+ <label for="phone">Cellulare</label>
+ </div>
+ <div class="input-field col s4">
+ <input value="{{home_phone}}" name="home_phone" id="home_phone" type="text" class="validate">
+ <label for="home_phone">Telefono di casa</label>
+ </div>
+ <div class="input-field col s4">
+ <input value="{{email}}" name="email" id="email" type="text" class="validate">
+ <label for="email">Email</label>
+ </div>
+ </div>
+ <div class="row">
+ <div class="input-field col s8">
+ <input value="{{school}}" name="school" id="school" type="text" class="validate">
+ <label for="school">Scuola frequentata</label>
+ </div>
+ <div class="input-field col s4">
+ <input value="{{year}}" name="year" id="year" type="text" class="validate">
+ <label for="year">Classe</label>
+ </div>
+ </div>
+ <div class="fixed-action-btn">
+ <a class="btn-floating btn-large red lighten-1" onclick="document.getElementById('personal_form').submit()">
+ <i class="large material-icons">save</i>
+ </a>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
+<div id="medic" class="col s12">Tabella medica</div>
+{% endblock %} \ No newline at end of file
diff --git a/accounts/templates/accounts/signup.html b/accounts/templates/accounts/signup.html
index e1591aa..a8a517c 100644
--- a/accounts/templates/accounts/signup.html
+++ b/accounts/templates/accounts/signup.html
@@ -1,12 +1,21 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_simple.html' %}
{% block title %}Iscriviti{% endblock %}
{% block content %}
- <h2>Iscriviti</h2>
- <form method="post">
- {% csrf_token %}
- {{ form.as_p }}
- <button class="btn waves-effect waves-light" type="submit">Invia</button>
- </form>
+ <div class="row">
+ <div class="col l6 offset-l3 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <h2>Iscriviti</h2>
+ <form method="post">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <br>
+ <button class="btn waves-effect waves-light" type="submit">Invia</button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
{% endblock %} \ No newline at end of file
diff --git a/accounts/urls.py b/accounts/urls.py
index d89128b..332a16b 100644
--- a/accounts/urls.py
+++ b/accounts/urls.py
@@ -4,4 +4,5 @@ from . import views
urlpatterns = [
path('signup/', views.SignUp.as_view(), name='signup'),
+ path('personal/', views.personal, name='personal'),
]
diff --git a/accounts/views.py b/accounts/views.py
index 0483fad..0723482 100644
--- a/accounts/views.py
+++ b/accounts/views.py
@@ -2,9 +2,87 @@ from django.shortcuts import render
from django.contrib.auth.forms import UserCreationForm
from django.urls import reverse_lazy
from django.views import generic
+from django.contrib.auth.models import Group
+
+from client.models import UserCode
+
+import dateparser
class SignUp(generic.CreateView):
form_class = UserCreationForm
success_url = reverse_lazy('login')
template_name = 'accounts/signup.html'
+
+
+def personal(request):
+ context = {}
+ if request.user.is_authenticated:
+ usercode = UserCode.objects.filter(user=request.user)[0]
+ debug = ""
+ branca_default = ""
+ branca_castorini = ""
+ branca_lupetti = ""
+ branca_esploratori = ""
+ branca_pionieri = ""
+ branca_rover = ""
+
+ if request.method == "POST":
+ request.user.first_name = request.POST["first_name"]
+ request.user.last_name = request.POST["last_name"]
+ request.user.email = request.POST["email"]
+ request.user.save()
+ usercode.parent_name = request.POST["parent_name"]
+ usercode.via = request.POST["via"]
+ usercode.cap = request.POST["cap"]
+ usercode.country = request.POST["country"]
+ usercode.nationality = request.POST["nationality"]
+ usercode.born_date = dateparser.parse(request.POST["birth_date"])
+ usercode.home_phone = request.POST["home_phone"]
+ usercode.phone = request.POST["phone"]
+ usercode.school = request.POST["school"]
+ usercode.year = request.POST["year"]
+ usercode.save()
+
+ if request.POST["branca"] != "":
+ request.user.groups.clear()
+ request.user.groups.add(
+ Group.objects.get(name=request.POST["branca"]))
+
+ if len(request.user.groups.values_list('name', flat=True)) == 0:
+ branca_default = "selected"
+ else:
+ parent_group = request.user.groups.values_list('name', flat=True)[
+ 0]
+ if parent_group == "muta":
+ branca_lupetti = "selected"
+ elif parent_group == "reparto":
+ branca_esploratori = "selected"
+ else:
+ branca_default = "selected"
+
+ context = {
+ 'first_name': request.user.first_name,
+ 'last_name': request.user.last_name,
+ 'email': request.user.email,
+ 'parent_name': usercode.parent_name,
+ 'via': usercode.via,
+ 'cap': usercode.cap,
+ 'country': usercode.country,
+ 'nationality': usercode.nationality,
+ 'birth_date': usercode.born_date,
+ 'home_phone': usercode.home_phone,
+ 'phone': usercode.phone,
+ 'school': usercode.school,
+ 'year': usercode.year,
+ 'branca_default': branca_default,
+ 'branca_castorini': branca_castorini,
+ 'branca_lupetti': branca_lupetti,
+ 'branca_esploratori': branca_esploratori,
+ 'branca_pionieri': branca_pionieri,
+ 'branca_rover': branca_rover,
+ }
+
+ return render(request, 'accounts/index.html', context)
+ else:
+ return render(request, 'client/index.html', context)
diff --git a/client/migrations/0003_auto_20200619_1044.py b/client/migrations/0003_auto_20200619_1044.py
new file mode 100644
index 0000000..29503c0
--- /dev/null
+++ b/client/migrations/0003_auto_20200619_1044.py
@@ -0,0 +1,87 @@
+# Generated by Django 3.0.7 on 2020-06-19 08:44
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ('client', '0002_usercode_user'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='usercode',
+ name='born_date',
+ field=models.DateField(default=None),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='cap',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='country',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='home_phone',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='nationality',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='parent_name',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='phone',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='school',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='via',
+ field=models.CharField(default='', max_length=250),
+ ),
+ migrations.AddField(
+ model_name='usercode',
+ name='year',
+ field=models.IntegerField(default=0),
+ ),
+ migrations.CreateModel(
+ name='YearSubscription',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('group', models.CharField(default='', max_length=50)),
+ ('compilation_date', models.DateTimeField(auto_now_add=True)),
+ ('status', models.CharField(default='', max_length=50)),
+ ('code', models.IntegerField(default=0)),
+ ('parent_name', models.CharField(default='', max_length=250)),
+ ('via', models.CharField(default='', max_length=250)),
+ ('cap', models.CharField(default='', max_length=250)),
+ ('country', models.CharField(default='', max_length=250)),
+ ('nationality', models.CharField(default='', max_length=250)),
+ ('born_date', models.DateField(default=None)),
+ ('home_phone', models.CharField(default='', max_length=250)),
+ ('phone', models.CharField(default='', max_length=250)),
+ ('school', models.CharField(default='', max_length=250)),
+ ('year', models.IntegerField(default=0)),
+ ('user', models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
+ ],
+ ),
+ ]
diff --git a/client/migrations/0004_auto_20200619_1045.py b/client/migrations/0004_auto_20200619_1045.py
new file mode 100644
index 0000000..d7ca433
--- /dev/null
+++ b/client/migrations/0004_auto_20200619_1045.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.0.7 on 2020-06-19 08:45
+
+import datetime
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0003_auto_20200619_1044'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='usercode',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(2020, 6, 19, 10, 45, 47, 43395)),
+ ),
+ migrations.AlterField(
+ model_name='yearsubscription',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(2020, 6, 19, 10, 45, 47, 42414)),
+ ),
+ ]
diff --git a/client/migrations/0005_auto_20200619_1047.py b/client/migrations/0005_auto_20200619_1047.py
new file mode 100644
index 0000000..64d88bb
--- /dev/null
+++ b/client/migrations/0005_auto_20200619_1047.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.0.7 on 2020-06-19 08:47
+
+import datetime
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0004_auto_20200619_1045'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='usercode',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(1970, 1, 1, 1, 0)),
+ ),
+ migrations.AlterField(
+ model_name='yearsubscription',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(1970, 1, 1, 1, 0)),
+ ),
+ ]
diff --git a/client/migrations/0006_auto_20200619_1049.py b/client/migrations/0006_auto_20200619_1049.py
new file mode 100644
index 0000000..833317f
--- /dev/null
+++ b/client/migrations/0006_auto_20200619_1049.py
@@ -0,0 +1,24 @@
+# Generated by Django 3.0.7 on 2020-06-19 08:49
+
+import datetime
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('client', '0005_auto_20200619_1047'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='usercode',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(1970, 1, 1, 1, 0), null=True),
+ ),
+ migrations.AlterField(
+ model_name='yearsubscription',
+ name='born_date',
+ field=models.DateField(default=datetime.datetime(1970, 1, 1, 1, 0), null=True),
+ ),
+ ]
diff --git a/client/models.py b/client/models.py
index 970c489..d6e8578 100644
--- a/client/models.py
+++ b/client/models.py
@@ -1,5 +1,6 @@
from django.db import models
from django.contrib.auth.models import User
+from datetime import datetime
# Create your models here.
@@ -13,6 +14,34 @@ class Document(models.Model):
]
-class UserCode(models.Model):
+class YearSubscription(models.Model):
+ user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
+ group = models.CharField(default="", max_length=50)
+ compilation_date = models.DateTimeField(auto_now_add=True)
+ status = models.CharField(default="", max_length=50)
code = models.IntegerField(default=0)
+ parent_name = models.CharField(default="", max_length=250)
+ via = models.CharField(default="", max_length=250)
+ cap = models.CharField(default="", max_length=250)
+ country = models.CharField(default="", max_length=250)
+ nationality = models.CharField(default="", max_length=250)
+ born_date = models.DateField(null=True, default=datetime.fromtimestamp(0))
+ home_phone = models.CharField(default="", max_length=250)
+ phone = models.CharField(default="", max_length=250)
+ school = models.CharField(default="", max_length=250)
+ year = models.IntegerField(default=0)
+
+
+class UserCode(models.Model):
user = models.ForeignKey(User, default=None, on_delete=models.CASCADE)
+ code = models.IntegerField(default=0)
+ parent_name = models.CharField(default="", max_length=250)
+ via = models.CharField(default="", max_length=250)
+ cap = models.CharField(default="", max_length=250)
+ country = models.CharField(default="", max_length=250)
+ nationality = models.CharField(default="", max_length=250)
+ born_date = models.DateField(null=True, default=datetime.fromtimestamp(0))
+ home_phone = models.CharField(default="", max_length=250)
+ phone = models.CharField(default="", max_length=250)
+ school = models.CharField(default="", max_length=250)
+ year = models.IntegerField(default=0)
diff --git a/client/templates/client/approve.html b/client/templates/client/approve.html
index 026a66d..e00aedc 100644
--- a/client/templates/client/approve.html
+++ b/client/templates/client/approve.html
@@ -3,16 +3,31 @@
{% block title %}Approva{% endblock %}
{% block nav %}
-<nav>
- <div class="nav-wrapper">
- <div class="col s12">
- <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <a href="#!" class="breadcrumb">Approva</a>
- </div>
- </div>
-</nav>
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
+ <a style="margin-left: 10px;" href="{% url 'approve' %}" class="breadcrumb hide-on-med-and-down">Approva</a>
{% endblock %}
{% block content %}
-{{ code }}
+{% if okay %}
+ <div class="row">
+ <div class="col l4 offset-l4 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <p>Per approvare l'utente invia il seguente codice al capo branca:</p>
+ <h3 class="center-align">{{code}}<h3>
+ </div>
+ </div>
+ </div>
+ </div>
+{% else %}
+ <div class="row">
+ <div class="col l4 offset-l4 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <p>Per approvare l'utente inserire prima i propri dati personali cliccando il proprio nome in alto a destra.</p>
+ </div>
+ </div>
+ </div>
+ </div>
+{% endif %}
{% endblock %} \ No newline at end of file
diff --git a/client/templates/client/index.html b/client/templates/client/index.html
index 2c55dbc..64b4d42 100644
--- a/client/templates/client/index.html
+++ b/client/templates/client/index.html
@@ -3,34 +3,35 @@
{% block title %}Home{% endblock %}
{%block nav%}
-<nav>
- <div class="nav-wrapper">
- <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <ul class="right hide-on-med-and-down">
- <li>{{ user.username}}</li>
- <li><a href="{% url 'logout' %}">Logout</a></li>
- </ul>
- </div>
-</nav>
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
{% endblock%}
{% block content %}
{% if user.is_authenticated %}
- {% if user.is_staff %}
- Ciao {{ user.username }}!
- <p><a class="waves-effect waves-light btn" href="{% url 'server' %}">admin</a>
- <a class="waves-effect waves-light btn" href="{% url 'logout' %}">logout</a></p>
- {% elif perms.client.approved %}
- Ciao {{ user.username }}!
- <p><a class="waves-effect waves-light btn" href="{% url 'logout' %}">logout</a></p>
+ {% if user.is_staff or perms.client.approved %}
{% else %}
- Il tuo utente non e` ancora stato approvato.
- <p><a class="waves-effect waves-light btn" href="{% url 'approve' %}">approva</a>
- <a class="waves-effect waves-light btn" href="{% url 'logout' %}">logout</a></p>
+ <div class="row">
+ <div class="col l4 offset-l4 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <p>Il tuo utente non e` ancora stato approvato.</p>
+ </div>
+ <div class="card-action">
+ <a href="{% url 'approve' %}">Come farsi approvare l'utente</a>
+ </div>
+ </div>
+ </div>
+ </div>
{% endif %}
{% else %}
- <p>Non hai fatto il login</p>
- <p><a class="waves-effect waves-light btn" href="{% url 'login' %}">login</a>
- <a class="waves-effect waves-light btn" href="{% url 'signup' %}">registrazione</a></p>
+ <div class="row">
+ <div class="col l4 offset-l4 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <p>Se hai gia` un account clicca login in alto a destra. Altrimenti clicca registrazione</p>
+ </div>
+ </div>
+ </div>
+ </div>
{% endif %}
{% endblock %} \ No newline at end of file
diff --git a/client/views.py b/client/views.py
index 5a8f808..96eb977 100644
--- a/client/views.py
+++ b/client/views.py
@@ -9,12 +9,7 @@ from .models import UserCode
def index(request):
context = {}
- return render(request, 'client/index.html', context)
-
-
-def approve(request):
- context = {}
- if not (request.user.is_staff or request.user.has_perm('approved')):
+ if (request.user.is_authenticated):
users = UserCode.objects.filter(user=request.user)
code = None
if (len(users) == 0):
@@ -24,9 +19,17 @@ def approve(request):
break
userCode = UserCode(user=request.user, code=code)
userCode.save()
- else:
- code = UserCode.objects.filter(user=request.user)[0].code
- context = {'code': 'U' + str(code), }
+ return render(request, 'client/index.html', context)
+
+
+def approve(request):
+ context = {}
+ if not (request.user.is_staff or request.user.has_perm('approved')):
+ usercode = UserCode.objects.filter(user=request.user)[0]
+ okay = False
+ if request.user.first_name != "" and request.user.last_name != "" and request.user.email != "" and len(request.user.groups.values_list('name', flat=True)) != 0:
+ okay = True
+ context = {'code': 'U' + str(usercode.code), 'okay': okay}
return render(request, 'client/approve.html', context)
else:
return render(request, 'client/index.html', context)
diff --git a/server/templates/server/approve_user.html b/server/templates/server/approve_user.html
index ae9dc8b..126c0b9 100644
--- a/server/templates/server/approve_user.html
+++ b/server/templates/server/approve_user.html
@@ -3,17 +3,9 @@
{% block title %}Admin - Approva Utente{% endblock %}
{% block nav %}
-<nav>
- <div class="nav-wrapper">
- <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <a href="{% url 'server'%}" class="breadcrumb">Admin</a>
- <a href="#!" class="breadcrumb">Approva Utente</a>
- <ul class="right hide-on-med-and-down">
- <li>{{ user.username}}</li>
- <li><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li>
- </ul>
- </div>
-</nav>
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
+ <a href="{% url 'server'%}" class="breadcrumb hide-on-med-and-down">Admin</a>
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Approva Utente</a>
{% endblock %}
{% block content %}
diff --git a/server/templates/server/index.html b/server/templates/server/index.html
index 4790a1d..37a553b 100644
--- a/server/templates/server/index.html
+++ b/server/templates/server/index.html
@@ -3,21 +3,13 @@
{% block title %}Admin{% endblock %}
{% block nav %}
-<nav>
- <div class="nav-wrapper">
<a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <a href="#!" class="breadcrumb">Admin</a>
- <ul class="right hide-on-med-and-down">
- <li>{{ user.username}}</li>
- <li><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li>
- </ul>
- </div>
-</nav>
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Admin</a>
{% endblock %}
{% block content %}
<div class="row">
- <div class="col s6">
+ <div class="col l6 s12">
<div class="card large">
<div class="card-content">
<p>
@@ -45,7 +37,7 @@
</div>
</div>
</div>
- <div class="col s6">
+ <div class="col l6 s12">
<div class="card large">
<div class="card-content">
<p>I am a very simple card. I am good at containing small bits of information.
diff --git a/server/templates/server/user_list.html b/server/templates/server/user_list.html
index daf7303..3837619 100644
--- a/server/templates/server/user_list.html
+++ b/server/templates/server/user_list.html
@@ -3,17 +3,9 @@
{% block title %}Admin - Lista Utenti{% endblock %}
{% block nav %}
-<nav>
- <div class="nav-wrapper">
- <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
- <a href="{% url 'server'%}" class="breadcrumb">Admin</a>
- <a href="#!" class="breadcrumb">Lista Utenti</a>
- <ul class="right hide-on-med-and-down">
- <li>{{ user.username}}</li>
- <li><a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a></li>
- </ul>
- </div>
-</nav>
+ <a style="margin-left: 10px;" href="{% url 'index' %}" class="breadcrumb">Home</a>
+ <a href="{% url 'server'%}" class="breadcrumb hide-on-med-and-down">Admin</a>
+ <a href="#!" class="breadcrumb hide-on-med-and-down">Lista Utenti</a>
{% endblock %}
{% block content %}
diff --git a/server/views.py b/server/views.py
index ab94fd6..aa2dc3a 100644
--- a/server/views.py
+++ b/server/views.py
@@ -18,7 +18,7 @@ def index(request):
code = 'U' + str(UserCode.objects.filter(user=user)[0].code)
status = ""
if user.is_staff:
- status = "Capo"
+ status = "Staff"
elif user.has_perm("client.approved"):
status = "Attivo"
else:
@@ -83,17 +83,55 @@ def ulist(request):
out = []
for user in users:
code = ""
- if len(UserCode.objects.filter(user=user)) > 0:
- code = 'U' + str(UserCode.objects.filter(user=user)[0].code)
+ parent_name = ""
+ via = ""
+ cap = ""
+ country = ""
+ nationality = ""
+ born_date = ""
+ home_phone = ""
+ phone = ""
+ school = ""
+ year = ""
status = ""
if user.is_staff:
- status = "Capo"
+ status = "Staff"
elif user.has_perm("approved"):
status = "Attivo"
else:
status = "In attesa"
- out.append([user.username, user.first_name,
- user.last_name, code, status])
+ if len(UserCode.objects.filter(user=user)) > 0:
+ usercode = UserCode.objects.filter(user=user)[0]
+ code = 'U' + str(usercode.code)
+ parent_name = usercode.parent_name
+ via = usercode.via
+ cap = usercode.cap
+ country = usercode.country
+ nationality = usercode.nationality
+ born_date = usercode.born_date
+ home_phone = usercode.home_phone
+ phone = usercode.phone
+ school = usercode.school
+ year = usercode.year
+ else:
+ status = "Non registrato"
+ out.append([
+ status,
+ user.username,
+ user.first_name,
+ user.last_name,
+ born_date,
+ parent_name,
+ user.email,
+ phone,
+ home_phone,
+ via,
+ cap,
+ country,
+ nationality,
+ school,
+ year,
+ code])
context = {'users': out}
return render(request, 'server/user_list.html', context)
else:
diff --git a/templates/registration/base.html b/templates/registration/base.html
index 51dad17..f5a8a80 100644
--- a/templates/registration/base.html
+++ b/templates/registration/base.html
@@ -8,12 +8,36 @@
<title>{% block title %}Scout Brega{% endblock %}</title>
</head>
<body>
- {% block nav %}
- {% endblock %}
+ <nav>
+ <div class="nav-wrapper red lighten-1">
+ {% block nav %}
+ {% endblock %}
+ <ul class="right">
+ {% if user.is_staff %}
+ <li><a href="{% url 'server' %}">Pannello Admin</a></li>
+ {% endif %}
+ {% if user.is_authenticated %}
+ <li><a href="{% url 'personal' %}">{{ user.username }}</a></li>
+ {% endif %}
+ {% if user.username != "" %}
+ <li>
+ <a href="{% url 'logout' %}"><i class="material-icons">exit_to_app</i></a>
+ </li>
+ {% else %}
+ <li><a href="{% url 'signup' %}">Registrazione</a></li>
+ <li><a href="{% url 'login' %}">Login</a></li>
+ {% endif %}
+ </ul>
+ </div>
+ </nav>
<main style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
{% block content %}
{% endblock %}
</main>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+ <script
+ src="https://code.jquery.com/jquery-3.5.1.min.js"
+ integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
+ crossorigin="anonymous"></script>
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
</body>
</html> \ No newline at end of file
diff --git a/templates/registration/base_custom.html b/templates/registration/base_custom.html
new file mode 100644
index 0000000..d38be7a
--- /dev/null
+++ b/templates/registration/base_custom.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <meta charset="utf-8">
+ <title>{% block title %}Scout Brega{% endblock %}</title>
+</head>
+<body>
+ {% block nav %}
+ {% endblock %}
+ <main style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
+ {% block content %}
+ {% endblock %}
+ </main>
+ <script
+ src="https://code.jquery.com/jquery-3.5.1.min.js"
+ integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
+ crossorigin="anonymous"></script>
+ <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+ <script type="text/javascript">
+ var elem = $('.tabs')
+ var options = {
+ yearRange:100,
+ format:'dd.mm.yyyy',
+ i18n: {
+ months: [ 'gennaio', 'febbraio', 'marzo', 'aprile', 'maggio', 'giugno', 'luglio', 'agosto', 'settembre', 'ottobre', 'novembre', 'dicembre' ],
+ monthsShort: [ 'gen', 'feb', 'mar', 'apr', 'mag', 'giu', 'lug', 'ago', 'set', 'ott', 'nov', 'dic' ],
+ weekdays: [ 'domenica', 'lunedì', 'martedì', 'mercoledì', 'giovedì', 'venerdì', 'sabato' ],
+ weekdaysShort: [ 'dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab' ],
+ weekdaysAbbrev: [ 'D', 'L', 'M', 'M', 'G', 'V', 'S' ],
+ today: 'Oggi',
+ clear: 'Cancella',
+ close: 'Chiudi',
+ firstDay: 1,
+ format: 'dddd d mmmm yyyy',
+ formatSubmit: 'yyyy/mm/dd',
+ labelMonthNext: 'Mese successivo',
+ labelMonthPrev: 'Mese precedente',
+ labelMonthSelect: 'Seleziona un mese',
+ labelYearSelect: 'Seleziona un anno'
+ }}
+ var instance = M.Tabs.init(elem, options);
+ document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('.datepicker');
+ var instances = M.Datepicker.init(elems, options);
+ });
+ document.addEventListener('DOMContentLoaded', function() {
+ var elems = document.querySelectorAll('select');
+ var instances = M.FormSelect.init(elems, options);
+ });
+ </script>
+</body>
+</html> \ No newline at end of file
diff --git a/templates/registration/base_simple.html b/templates/registration/base_simple.html
new file mode 100644
index 0000000..82087bc
--- /dev/null
+++ b/templates/registration/base_simple.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+ <meta charset="utf-8">
+ <title>{% block title %}Scout Brega{% endblock %}</title>
+</head>
+<body>
+ <main style="margin-left: 10px;margin-right: 10px;margin-top: 10px;">
+ {% block content %}
+ {% endblock %}
+ </main>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
+</body>
+</html> \ No newline at end of file
diff --git a/templates/registration/login.html b/templates/registration/login.html
index 71880b3..9459f93 100644
--- a/templates/registration/login.html
+++ b/templates/registration/login.html
@@ -1,12 +1,20 @@
-{% extends 'registration/base.html' %}
+{% extends 'registration/base_simple.html' %}
{% block title %}Login{% endblock %}
{% block content %}
-<h2>Login</h2>
-<form method="post">
- {% csrf_token %}
- {{ form.as_p }}
- <button class="btn waves-effect waves-light" type="submit">Login</button>
-</form>
+ <div class="row">
+ <div class="col l4 offset-l4 m8 offset-m2 s12">
+ <div class="card">
+ <div class="card-content">
+ <form method="post">
+ {% csrf_token %}
+ {{ form.as_p }}
+ <br>
+ <button class="btn waves-effect waves-light" type="submit">Login</button>
+ </form>
+ </div>
+ </div>
+ </div>
+ </div>
{% endblock %} \ No newline at end of file