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,41 +1,40 @@
|
||||
<div class="column is-one-quarter">
|
||||
<div class="box {%if not shift.teambackup_set.all%} has-background-warning{%endif%}">
|
||||
<div class="content">
|
||||
<strong>Ort:</strong> {{ shift.room.name }}<br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}<br>
|
||||
<strong>Dauer:</strong> {{ shift.duration }}<br>
|
||||
<strong>Belegung:</strong> {{ shift.shiftregistration_set.count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
<hr>
|
||||
<ul>
|
||||
{% for item in shift.teambackup_set.all%}
|
||||
<li>{{item.name}}</li>
|
||||
{%endfor%}
|
||||
</ul>
|
||||
<form action="{%url 'signage:work_add' shift.pk%}" 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 class="box{% if not shift.teambackup_set.all %} has-background-warning{% endif %}">
|
||||
<div class="content">
|
||||
<strong>Ort:</strong> {{ shift.room.name }}<br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}<br>
|
||||
<strong>Dauer:</strong> {{ shift.duration }}<br>
|
||||
<strong>Belegung:</strong> {{ shift.shiftregistration_set.count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
<hr>
|
||||
<ul>
|
||||
{% for item in shift.teambackup_set.all %}
|
||||
<li>{{ item.name }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<form action="{% url 'signage:work_add' shift.pk %}" 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>
|
||||
{% 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">Team hinzufuegen</button>
|
||||
</form>
|
||||
{% endfor %}
|
||||
<button class="button is-link" type="submit">Team hinzufügen</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -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,90 +1,63 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>{% block title %}Help!{% endblock %} – Helfer*innen</title>
|
||||
<link rel="icon" href="{% static 'tonkakt.svg' %}" sizes="any" type="image/svg+xml">
|
||||
<link rel="stylesheet" href="{% static 'bulma.min.css' %}">
|
||||
<link rel="stylesheet" href="{% static 'bulma-prefers-dark.min.css' %}">
|
||||
<style>
|
||||
@font-face {
|
||||
font-family: "Maven Pro";
|
||||
src: url("{% static 'MavenPro-VariableFont:wght.ttf' %}");
|
||||
}
|
||||
|
||||
* {
|
||||
font-family: "Maven Pro", sans-serif !important;
|
||||
}
|
||||
|
||||
:root {
|
||||
--background: #fff;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--background: #17181c;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
const max = document.body.scrollHeight - window.innerHeight;
|
||||
let current = 0;
|
||||
let interval;
|
||||
let interacted = false;
|
||||
|
||||
window.addEventListener('click', () => interacted = true);
|
||||
window.addEventListener('touchstart', () => interacted = true);
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block head %}
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
const max = document.body.scrollHeight - window.innerHeight;
|
||||
let current = 0;
|
||||
let interval;
|
||||
let interacted = false;
|
||||
|
||||
window.addEventListener('click', () => interacted = true);
|
||||
window.addEventListener('touchstart', () => interacted = true);
|
||||
|
||||
setTimeout(() => {
|
||||
window.scrollTo({top: 0});
|
||||
}, 10);
|
||||
|
||||
if (max > 0) {
|
||||
setTimeout(() => {
|
||||
if (interacted) return;
|
||||
interval = setInterval(() => {
|
||||
if (interacted) return;
|
||||
current += 1;
|
||||
|
||||
setTimeout(() => {
|
||||
window.scrollTo({top: 0});
|
||||
}, 10);
|
||||
window.scrollTo({top: current});
|
||||
|
||||
if (max > 0) {
|
||||
setTimeout(() => {
|
||||
if (window.scrollY >= max) {
|
||||
if (interacted) return;
|
||||
interval = setInterval(() => {
|
||||
if (interacted) return;
|
||||
current += 1;
|
||||
|
||||
window.scrollTo({top: current});
|
||||
|
||||
if (window.scrollY >= max) {
|
||||
if (interacted) return;
|
||||
clearInterval(interval);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 5000)
|
||||
}
|
||||
}, 20);
|
||||
}, 5000)
|
||||
}
|
||||
clearInterval(interval);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 5000)
|
||||
}
|
||||
}, 20);
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (interacted) return;
|
||||
window.location.reload();
|
||||
}, 120 * 1000)
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
{% for shift in shifts %}
|
||||
<tr>
|
||||
<td>{{shift.start_at}}</td>
|
||||
<td>{{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}</td>
|
||||
<td>{{shift.room.name}} </td>
|
||||
<td><b>{%for item in shift.teambackup_set.all%}{{item.name}}{% if not forloop.last %}, {% endif %}{%empty%}</b> <div class="has-text-danger">unbesetzt</div> <b>{%endfor%}</b></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
setTimeout(() => {
|
||||
if (interacted) return;
|
||||
window.location.reload();
|
||||
}, 120 * 1000)
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
{% for shift in shifts %}
|
||||
<tr>
|
||||
<td>{{shift.start_at}}</td>
|
||||
<td>{{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}</td>
|
||||
<td>{{shift.room.name}} </td>
|
||||
<td><b>{%for item in shift.teambackup_set.all%}{{item.name}}{% if not forloop.last %}, {% endif %}{%empty%}</b> <div class="has-text-danger">unbesetzt</div> <b>{%endfor%}</b></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</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 %}
|
||||
{% 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