add event state dependent messages and screens
This commit is contained in:
parent
0863b8c45a
commit
cad8945e25
|
@ -0,0 +1,16 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from dynamic_preferences.registries import global_preferences_registry
|
||||||
|
|
||||||
|
|
||||||
|
def event_state(view):
|
||||||
|
global_preferences = global_preferences_registry.manager()
|
||||||
|
|
||||||
|
def wrapped(request, *args, **kwargs):
|
||||||
|
state = global_preferences["helper__event_state"]
|
||||||
|
if state == "RUNNING":
|
||||||
|
return view(request, *args, **kwargs)
|
||||||
|
if state == "BEFORE":
|
||||||
|
return render(request, "event_before.html", {})
|
||||||
|
return render(request, "event_after.html", {})
|
||||||
|
|
||||||
|
return wrapped
|
|
@ -24,6 +24,18 @@ class SendSMS(types.BooleanPreference):
|
||||||
default = True
|
default = True
|
||||||
|
|
||||||
|
|
||||||
|
@global_preferences_registry.register
|
||||||
|
class EventState(types.ChoicePreference):
|
||||||
|
section = helper
|
||||||
|
name = "event_state"
|
||||||
|
choices = [
|
||||||
|
("BEFORE", "before event"),
|
||||||
|
("RUNNING", "event is running"),
|
||||||
|
("AFTER", "event is over"),
|
||||||
|
]
|
||||||
|
default = "BEFORE"
|
||||||
|
|
||||||
|
|
||||||
@global_preferences_registry.register
|
@global_preferences_registry.register
|
||||||
class ShiftReminder(types.DurationPreference):
|
class ShiftReminder(types.DurationPreference):
|
||||||
section = helper
|
section = helper
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "helper_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Danke!{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
Das wars!<br/>
|
||||||
|
Danke für Deine Hilfe, bis zum nächsten Event.
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "helper_base.html" %}
|
||||||
|
|
||||||
|
{% block title %}Stay Tuned!{% endblock %}
|
||||||
|
{% block content %}
|
||||||
|
Bald gehts los!<br/>
|
||||||
|
Wir schicken Dir eine SMS wenn wir freie Schichten haben.
|
||||||
|
{% endblock %}
|
|
@ -8,8 +8,10 @@ from django.utils import timezone
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
import datetime
|
import datetime
|
||||||
|
from .decorators import event_state
|
||||||
|
|
||||||
|
|
||||||
|
@event_state
|
||||||
def index(request):
|
def index(request):
|
||||||
if request.session.get("last_seen_shift"):
|
if request.session.get("last_seen_shift"):
|
||||||
del request.session["last_seen_shift"]
|
del request.session["last_seen_shift"]
|
||||||
|
@ -26,7 +28,6 @@ def index(request):
|
||||||
)
|
)
|
||||||
|
|
||||||
imp_shift = request.helper.important_shift()
|
imp_shift = request.helper.important_shift()
|
||||||
print(imp_shift)
|
|
||||||
if imp_shift and imp_shift.is_running():
|
if imp_shift and imp_shift.is_running():
|
||||||
context["current_shift"] = imp_shift
|
context["current_shift"] = imp_shift
|
||||||
|
|
||||||
|
@ -137,6 +138,7 @@ def register(request):
|
||||||
return render(request, "register.html", context)
|
return render(request, "register.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
@event_state
|
||||||
def shift(request, shiftid):
|
def shift(request, shiftid):
|
||||||
shift = get_object_or_404(Shift, pk=shiftid)
|
shift = get_object_or_404(Shift, pk=shiftid)
|
||||||
helper = request.helper
|
helper = request.helper
|
||||||
|
|
Loading…
Reference in New Issue