Compare commits
7 Commits
e01e04fe87
...
216969a1e1
Author | SHA1 | Date |
---|---|---|
Luca | 216969a1e1 | |
Luca | 079e6a9f06 | |
Andreas (@xAndy) Zimmermann | 0d2415aef2 | |
Andreas (@xAndy) Zimmermann | 7aa5da28fe | |
Andreas (@xAndy) Zimmermann | 4f4b5c3009 | |
Andreas (@xAndy) Zimmermann | 1f53998eb0 | |
Andreas (@xAndy) Zimmermann | a3ac897055 |
|
@ -0,0 +1,41 @@
|
|||
---
|
||||
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
clone:
|
||||
disable: yes
|
||||
|
||||
steps:
|
||||
- name: deploy staging
|
||||
image: ghcr.io/appleboy/drone-ssh
|
||||
environment:
|
||||
INSTANCE: staging
|
||||
settings: &settings
|
||||
host:
|
||||
from_secret: ssh_host
|
||||
username:
|
||||
from_secret: ssh_username
|
||||
key:
|
||||
from_secret: ssh_key
|
||||
envs:
|
||||
- INSTANCE
|
||||
script:
|
||||
- sudo deploy-shiftregister.sh "$$INSTANCE"
|
||||
when:
|
||||
branch:
|
||||
- main
|
||||
|
||||
- name: deploy production
|
||||
image: ghcr.io/appleboy/drone-ssh
|
||||
environment:
|
||||
INSTANCE: production
|
||||
settings: *settings
|
||||
when:
|
||||
branch:
|
||||
- live
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- push
|
|
@ -0,0 +1,23 @@
|
|||
# Generated by Django 4.0.4 on 2023-05-28 10:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("app", "0011_room_description"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="shift",
|
||||
name="deleted",
|
||||
field=models.BooleanField(db_index=True, default=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="shift",
|
||||
name="start_at",
|
||||
field=models.DateTimeField(db_index=True),
|
||||
),
|
||||
]
|
|
@ -26,13 +26,13 @@ class Room(models.Model):
|
|||
|
||||
class Shift(models.Model):
|
||||
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
|
||||
start_at = models.DateTimeField()
|
||||
start_at = models.DateTimeField(db_index=True)
|
||||
duration = models.DurationField()
|
||||
required_helpers = models.IntegerField(
|
||||
default=0, help_text="When this is set to zero, the room value is used instead."
|
||||
)
|
||||
description = models.TextField(blank=True, default="")
|
||||
deleted = models.BooleanField(default=False)
|
||||
deleted = models.BooleanField(default=False, db_index=True)
|
||||
|
||||
def with_reg_count():
|
||||
return Shift.objects.annotate(
|
||||
|
@ -46,7 +46,7 @@ class Shift(models.Model):
|
|||
)
|
||||
),
|
||||
)
|
||||
)
|
||||
).select_related("room")
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.room.name}: {self.start_at}"
|
||||
|
|
|
@ -2,6 +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 django.core.cache import cache
|
||||
from .forms import RegisterForm, EmptyForm, AstaForm
|
||||
from django.db.models.fields import DateTimeField
|
||||
from datetime import timedelta
|
||||
|
@ -21,8 +22,13 @@ def index(request):
|
|||
if request.session.get("last_seen_shift"):
|
||||
del request.session["last_seen_shift"]
|
||||
|
||||
days = cache.get("event_days")
|
||||
if not days:
|
||||
days = Shift.objects.filter(deleted=False).datetimes("start_at", "day").all()
|
||||
cache.set("event_days", days)
|
||||
|
||||
context = {
|
||||
"days": Shift.objects.filter(deleted=False).datetimes("start_at", "day"),
|
||||
"days": days,
|
||||
"enable_asta": global_preferences["helper__enable_asta"],
|
||||
}
|
||||
|
||||
|
@ -58,7 +64,7 @@ def index(request):
|
|||
deleted=False,
|
||||
)
|
||||
.order_by("start_at")
|
||||
for day in Shift.objects.datetimes("start_at", "day")
|
||||
for day in days
|
||||
)
|
||||
if request.helper:
|
||||
free_shifts = (
|
||||
|
@ -175,7 +181,7 @@ def register(request):
|
|||
|
||||
@event_state
|
||||
def shift(request, shiftid):
|
||||
shift = get_object_or_404(Shift, pk=shiftid)
|
||||
shift = get_object_or_404(Shift.with_reg_count(), pk=shiftid)
|
||||
helper = request.helper
|
||||
context = {
|
||||
"enable_asta": global_preferences["helper__enable_asta"],
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
{% if shift.checkin_count is not None %}
|
||||
<br>
|
||||
<strong>Checkin-Status:</strong> {% if shift.checkin_count == shift.required_helpers|default:shift.room.required_helpers %}<span class="tag is-rounded is-success">vollständig</span>{% elif shift.checkin_count > 0 %}<span class="tag is-rounded is-warning">teilweise</span>{% else %}<span class="tag is-rounded is-danger">kein Checkin</span>{% endif %}
|
||||
<strong>Checkin-Status:</strong> {% if shift.checkin_count >= shift.required_helpers|default:shift.room.required_helpers %}<span class="tag is-rounded is-success">vollständig</span>{% elif shift.checkin_count > 0 %}<span class="tag is-rounded is-warning">teilweise</span>{% else %}<span class="tag is-rounded is-danger">kein Checkin</span>{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="buttons is-right mt-3">
|
||||
|
|
|
@ -43,6 +43,7 @@ def shift_overview(request):
|
|||
context = {}
|
||||
context["running_shifts"] = (
|
||||
Shift.with_reg_count()
|
||||
.prefetch_related("event__calendar")
|
||||
.annotate(
|
||||
checkin_count=Count(
|
||||
Case(
|
||||
|
@ -63,6 +64,7 @@ def shift_overview(request):
|
|||
|
||||
context["next_shifts"] = (
|
||||
Shift.with_reg_count()
|
||||
.prefetch_related("event__calendar")
|
||||
.annotate(checkin_count=checkin_count)
|
||||
.filter(
|
||||
start_at__gt=timezone.now(),
|
||||
|
@ -77,6 +79,7 @@ def shift_overview(request):
|
|||
lambda x: x is not None,
|
||||
(
|
||||
Shift.with_reg_count()
|
||||
.prefetch_related("event__calendar")
|
||||
.filter(room=room, start_at__gt=timezone.now(), deleted=False)
|
||||
.order_by("start_at")
|
||||
.first()
|
||||
|
@ -93,7 +96,9 @@ def add_helper_shift(self):
|
|||
|
||||
@login_required
|
||||
def shift_detail(request, pk):
|
||||
shift = get_object_or_404(Shift, pk=pk)
|
||||
shift = get_object_or_404(
|
||||
Shift.with_reg_count().prefetch_related("shiftregistration_set__helper"), pk=pk
|
||||
)
|
||||
form = HelperShift()
|
||||
if request.method == "POST":
|
||||
form = HelperShift(request.POST)
|
||||
|
|
Loading…
Reference in New Issue