2
0
Fork 0

Compare commits

..

No commits in common. "216969a1e124cb7b2406b7a06418b96aaa49f070" and "e01e04fe8704f9d5f581be78fa2e1766086ce7d0" have entirely different histories.

6 changed files with 8 additions and 83 deletions

View File

@ -1,41 +0,0 @@
---
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

View File

@ -1,23 +0,0 @@
# 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),
),
]

View File

@ -26,13 +26,13 @@ class Room(models.Model):
class Shift(models.Model):
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
start_at = models.DateTimeField(db_index=True)
start_at = models.DateTimeField()
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, db_index=True)
deleted = models.BooleanField(default=False)
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}"

View File

@ -2,7 +2,6 @@ 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
@ -22,13 +21,8 @@ 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": days,
"days": Shift.objects.filter(deleted=False).datetimes("start_at", "day"),
"enable_asta": global_preferences["helper__enable_asta"],
}
@ -64,7 +58,7 @@ def index(request):
deleted=False,
)
.order_by("start_at")
for day in days
for day in Shift.objects.datetimes("start_at", "day")
)
if request.helper:
free_shifts = (
@ -181,7 +175,7 @@ def register(request):
@event_state
def shift(request, shiftid):
shift = get_object_or_404(Shift.with_reg_count(), pk=shiftid)
shift = get_object_or_404(Shift, pk=shiftid)
helper = request.helper
context = {
"enable_asta": global_preferences["helper__enable_asta"],

View File

@ -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">

View File

@ -43,7 +43,6 @@ def shift_overview(request):
context = {}
context["running_shifts"] = (
Shift.with_reg_count()
.prefetch_related("event__calendar")
.annotate(
checkin_count=Count(
Case(
@ -64,7 +63,6 @@ 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(),
@ -79,7 +77,6 @@ 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()
@ -96,9 +93,7 @@ def add_helper_shift(self):
@login_required
def shift_detail(request, pk):
shift = get_object_or_404(
Shift.with_reg_count().prefetch_related("shiftregistration_set__helper"), pk=pk
)
shift = get_object_or_404(Shift, pk=pk)
form = HelperShift()
if request.method == "POST":
form = HelperShift(request.POST)