add first asta functionality
This commit is contained in:
parent
75d71f082d
commit
efe0d392db
|
@ -39,6 +39,14 @@ class RegisterForm(forms.Form):
|
|||
okf = forms.BooleanField(label="Ich bin damit einverstanden, SMS zu erhalten.")
|
||||
|
||||
|
||||
class AstaForm(forms.Form):
|
||||
confirm = forms.BooleanField(
|
||||
required=True,
|
||||
label="Ich habe mich beim AStA als reguläres Mitglied angemeldet",
|
||||
help_text="Aus Versicherungsgründen müssen Helfer*innen AStA Mitglieder sein. Die Mitgliedschaft ist kostenlos.",
|
||||
)
|
||||
|
||||
|
||||
# placeholder form for simple submit button use cases so we get csrf protection
|
||||
class EmptyForm(forms.Form):
|
||||
pass
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Generated by Django 4.0.4 on 2022-05-17 13:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("app", "0008_alter_message_sent_at"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="helper",
|
||||
name="asta_confirmed",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
]
|
|
@ -67,6 +67,7 @@ class Helper(models.Model):
|
|||
name = models.CharField(max_length=200)
|
||||
# change this to a generic state variable to allow for number blocking/account deactivation?
|
||||
number_validated = models.BooleanField(default=False)
|
||||
asta_confirmed = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
{% extends "helper_base.html" %}
|
||||
|
||||
{% block title %}Registrierung{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<a href="https://asta-bamberg.de/mitglied-werden" target="_blank" class="button is-primary">AStA Formular</a>
|
||||
<form action="" method="post">
|
||||
{% csrf_token %}
|
||||
{% for field in form %}
|
||||
<div class="field">
|
||||
{% if field.widget_type == 'checkbox' %}
|
||||
<div class="control">
|
||||
<label class="checkbox" for="{{ field.id_for_label }}">{{ field }} {{ field.label }}</label>
|
||||
</div>
|
||||
{% else %}
|
||||
<label class="label" for="{{ field.id_for_label }}">{{ field.label }}</label>
|
||||
<div class="control">
|
||||
{{ field }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% for error in field.errors %}
|
||||
<p class="help is-danger">{{ error }}</p>
|
||||
{% endfor %}
|
||||
{% if field.help_text %}
|
||||
<p class="help">{{ field.help_text }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
<button class="button is-link" type="submit">Speichern</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
{% block title %}Help!{% endblock %}
|
||||
|
||||
{% block custom_notifications %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<div class="navbar-start">
|
||||
{% if not helper%}
|
||||
|
@ -19,6 +23,15 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% if helper and not helper.asta_confirmed %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div class="notification is-danger">
|
||||
<a href="{% url 'asta' %}">Bitte Bestätige deine AStA Mitgliedschaft</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endif %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{% include 'notifications.html' %}
|
||||
|
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
|||
path("l/<slug:token>", views.login, name="token_login"),
|
||||
path("logout", views.logout, name="token_logout"),
|
||||
path("register", views.register, name="register"),
|
||||
path("asta", views.asta, name="asta"),
|
||||
path("shift/<int:shiftid>", views.shift, name="shift"),
|
||||
path("shift/<int:shiftid>/cancel", views.cancel, name="cancel"),
|
||||
]
|
||||
|
|
|
@ -2,7 +2,7 @@ from django.shortcuts import render, redirect, get_object_or_404
|
|||
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
||||
from django.db import transaction
|
||||
from django.db.models import F, Count, Q, ExpressionWrapper
|
||||
from .forms import RegisterForm, EmptyForm
|
||||
from .forms import RegisterForm, EmptyForm, AstaForm
|
||||
from django.db.models.fields import DateTimeField
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
|
@ -249,3 +249,22 @@ def cancel(request, shiftid):
|
|||
)
|
||||
|
||||
return redirect("shift", shiftid=shiftid)
|
||||
|
||||
|
||||
def asta(request):
|
||||
if not request.helper:
|
||||
return redirect("index")
|
||||
form = AstaForm()
|
||||
if request.method == "POST":
|
||||
form = AstaForm(request.POST)
|
||||
if AstaForm(request.POST).is_valid():
|
||||
request.helper.asta_confirmed = True
|
||||
request.helper.save()
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.SUCCESS,
|
||||
"Deine AStA-Mitgliedschaft wurde gespeichert",
|
||||
)
|
||||
return redirect("index")
|
||||
|
||||
return render(request, "asta.html", {"form": form})
|
||||
|
|
Loading…
Reference in New Issue