Populate nav with signal/context processor
parent
441c1434e3
commit
77bbca4d37
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "shiftregister.core"
|
@ -0,0 +1,14 @@
|
||||
from .signals import populate_nav
|
||||
|
||||
|
||||
def nav(request):
|
||||
nav_items = [
|
||||
item
|
||||
for _, items in populate_nav.send(sender=request)
|
||||
if isinstance(items, list)
|
||||
for item in items
|
||||
]
|
||||
|
||||
return {
|
||||
"nav_items": nav_items,
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
@ -0,0 +1,3 @@
|
||||
from django.dispatch import Signal
|
||||
|
||||
populate_nav = Signal()
|
@ -0,0 +1 @@
|
||||
{% extends "error.html" %}
|
@ -0,0 +1,5 @@
|
||||
{% extends "error.html" %}
|
||||
|
||||
{% block error_message %}Seite nicht gefunden{% endblock %}
|
||||
|
||||
{% block error_text %}{% endblock %}
|
@ -0,0 +1,5 @@
|
||||
{% extends "error.html" %}
|
||||
|
||||
{% block error_message %}Es ist ein Fehler aufgetreten{% endblock %}
|
||||
|
||||
{% block error_text %}Wir arbeiten dran. Bei dringenden Problemen wende dich bitte an den Infopoint.{% endblock %}
|
@ -0,0 +1,20 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Fehler{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div class="content">
|
||||
<h1 class="title">{% block error_message %}Fehler{% endblock %}</h1>
|
||||
{% block error_text %}
|
||||
<p class="is-family-monospace">¯\_(ツ)_/¯</p>
|
||||
{% endblock %}
|
||||
</div>
|
||||
<a class="button" href="{% url 'index' %}">Zurück zur Schichtübersicht</a>
|
||||
{% if user.is_authenticated %}
|
||||
<a class="button" href="{% url 'team:index' %}">Zurück zur Teamansicht</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
@ -1,23 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Team{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="{% url 'team:shift_overview' %}">Schichtübersicht</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_free' %}">Freie Schichten</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_all' %}">Alle Schichten</a>
|
||||
<a class="navbar-item" href="{% url 'team:bulk_message' %}">Massen-Nachricht</a>
|
||||
</div>
|
||||
<div class="navbar-end"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{% include 'notifications.html' %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
@ -1,10 +1,13 @@
|
||||
{% extends "signage_base.html" %}
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Team{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="columns is-multiline">
|
||||
{% for shift in shifts %}
|
||||
{%include 'partials/worklist_shift.html'%}
|
||||
{% endfor %}
|
||||
{% for shift in shifts %}
|
||||
{% include 'partials/worklist_shift.html' %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
@ -0,0 +1,23 @@
|
||||
from django.dispatch import receiver
|
||||
from django.shortcuts import reverse
|
||||
from shiftregister.core.signals import populate_nav
|
||||
|
||||
|
||||
@receiver(populate_nav, dispatch_uid="populate_team_nav")
|
||||
def populate_team_nav(sender, **kwargs):
|
||||
request = sender
|
||||
nav_items = []
|
||||
|
||||
if request.user.is_authenticated:
|
||||
nav_items.append(
|
||||
{"link": reverse("team:shift_overview"), "text": "Schichtübersicht"}
|
||||
)
|
||||
nav_items.append(
|
||||
{"link": reverse("team:shift_free"), "text": "Freie Schichten"}
|
||||
)
|
||||
nav_items.append({"link": reverse("team:shift_all"), "text": "Alle Schichten"})
|
||||
nav_items.append(
|
||||
{"link": reverse("team:bulk_message"), "text": "Massen-Nachricht"}
|
||||
)
|
||||
|
||||
return nav_items
|
@ -1,22 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Team{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<div class="navbar-start">
|
||||
<a class="navbar-item" href="{% url 'team:shift_overview' %}">Schichtübersicht</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_free' %}">Freie Schichten</a>
|
||||
<a class="navbar-item" href="{% url 'team:shift_all' %}">Alle Schichten</a>
|
||||
<a class="navbar-item" href="{% url 'team:bulk_message' %}">Massen-Nachricht</a>
|
||||
</div>
|
||||
<div class="navbar-end"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
{% include 'notifications.html' %}
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
@ -1 +0,0 @@
|
||||
{% extends "error_base.html" %}
|
@ -1,3 +0,0 @@
|
||||
{% extends "error_base.html" %}
|
||||
<h3 class="title">{% block error_message%}Seite nicht gefunden{% endblock %}</h3>
|
||||
{% block error_text%}{% endblock %}
|
@ -1,3 +0,0 @@
|
||||
{% extends "error_base.html" %}
|
||||
<h3 class="title">{% block error_message%}Es ist ein Fehler aufgetreten{% endblock %}</h3>
|
||||
{% block error_text%}Wir arbeiten dran. Bei dringenden Problemen kannst du dich an den Infopoint wenden.{% endblock %}
|
@ -1,32 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Fehler{% endblock %}
|
||||
|
||||
{% block navbar %}
|
||||
<div class="navbar-start">
|
||||
{% if not helper%}
|
||||
<a class="navbar-item" href="{% url 'register' %}">Anmelden</a>
|
||||
{% else %}
|
||||
{% if not helper.number_validated %}
|
||||
<p class="navbar-item has-text-danger">Bestätige deine Telefonnummer über den Link in der SMS</p>
|
||||
{% endif %}
|
||||
{% if helper.important_shift %}
|
||||
<a class="navbar-item" href="{% url 'shift' helper.important_shift.pk %}">{%if helper.important_shift.is_running%}Laufende{% else %}Nächste{% endif %} Schicht ({{ helper.important_shift.start_at|date:"H:i" }})</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="navbar-end"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h3 class="title">{% block error_message%}Fehler{% endblock %}</h3>
|
||||
{% block error_text%}<pre>¯\_(ツ)_/¯</pre>{% endblock %}<br>
|
||||
<a href="{% url 'index' %}" class="button">Zurück zur Schichtübersicht</a>
|
||||
{% if user.is_authenticated %}
|
||||
<a href="{% url 'team:index' %}" class="button">Zurück zur Teamansicht</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue