Compare commits
No commits in common. "216969a1e124cb7b2406b7a06418b96aaa49f070" and "e01e04fe8704f9d5f581be78fa2e1766086ce7d0" have entirely different histories.
216969a1e1
...
e01e04fe87
41
.drone.yml
41
.drone.yml
|
@ -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
|
|
|
@ -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),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -26,13 +26,13 @@ class Room(models.Model):
|
||||||
|
|
||||||
class Shift(models.Model):
|
class Shift(models.Model):
|
||||||
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
|
room = models.ForeignKey(Room, on_delete=models.RESTRICT)
|
||||||
start_at = models.DateTimeField(db_index=True)
|
start_at = models.DateTimeField()
|
||||||
duration = models.DurationField()
|
duration = models.DurationField()
|
||||||
required_helpers = models.IntegerField(
|
required_helpers = models.IntegerField(
|
||||||
default=0, help_text="When this is set to zero, the room value is used instead."
|
default=0, help_text="When this is set to zero, the room value is used instead."
|
||||||
)
|
)
|
||||||
description = models.TextField(blank=True, default="")
|
description = models.TextField(blank=True, default="")
|
||||||
deleted = models.BooleanField(default=False, db_index=True)
|
deleted = models.BooleanField(default=False)
|
||||||
|
|
||||||
def with_reg_count():
|
def with_reg_count():
|
||||||
return Shift.objects.annotate(
|
return Shift.objects.annotate(
|
||||||
|
@ -46,7 +46,7 @@ class Shift(models.Model):
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
).select_related("room")
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.room.name}: {self.start_at}"
|
return f"{self.room.name}: {self.start_at}"
|
||||||
|
|
|
@ -2,7 +2,6 @@ from django.shortcuts import render, redirect, get_object_or_404
|
||||||
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import F, Count, Q, ExpressionWrapper
|
from django.db.models import F, Count, Q, ExpressionWrapper
|
||||||
from django.core.cache import cache
|
|
||||||
from .forms import RegisterForm, EmptyForm, AstaForm
|
from .forms import RegisterForm, EmptyForm, AstaForm
|
||||||
from django.db.models.fields import DateTimeField
|
from django.db.models.fields import DateTimeField
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
@ -22,13 +21,8 @@ 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"]
|
||||||
|
|
||||||
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 = {
|
context = {
|
||||||
"days": days,
|
"days": Shift.objects.filter(deleted=False).datetimes("start_at", "day"),
|
||||||
"enable_asta": global_preferences["helper__enable_asta"],
|
"enable_asta": global_preferences["helper__enable_asta"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +58,7 @@ def index(request):
|
||||||
deleted=False,
|
deleted=False,
|
||||||
)
|
)
|
||||||
.order_by("start_at")
|
.order_by("start_at")
|
||||||
for day in days
|
for day in Shift.objects.datetimes("start_at", "day")
|
||||||
)
|
)
|
||||||
if request.helper:
|
if request.helper:
|
||||||
free_shifts = (
|
free_shifts = (
|
||||||
|
@ -181,7 +175,7 @@ def register(request):
|
||||||
|
|
||||||
@event_state
|
@event_state
|
||||||
def shift(request, shiftid):
|
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
|
helper = request.helper
|
||||||
context = {
|
context = {
|
||||||
"enable_asta": global_preferences["helper__enable_asta"],
|
"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 }}
|
<strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||||
{% if shift.checkin_count is not None %}
|
{% if shift.checkin_count is not None %}
|
||||||
<br>
|
<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 %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons is-right mt-3">
|
<div class="buttons is-right mt-3">
|
||||||
|
|
|
@ -43,7 +43,6 @@ def shift_overview(request):
|
||||||
context = {}
|
context = {}
|
||||||
context["running_shifts"] = (
|
context["running_shifts"] = (
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
.prefetch_related("event__calendar")
|
|
||||||
.annotate(
|
.annotate(
|
||||||
checkin_count=Count(
|
checkin_count=Count(
|
||||||
Case(
|
Case(
|
||||||
|
@ -64,7 +63,6 @@ def shift_overview(request):
|
||||||
|
|
||||||
context["next_shifts"] = (
|
context["next_shifts"] = (
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
.prefetch_related("event__calendar")
|
|
||||||
.annotate(checkin_count=checkin_count)
|
.annotate(checkin_count=checkin_count)
|
||||||
.filter(
|
.filter(
|
||||||
start_at__gt=timezone.now(),
|
start_at__gt=timezone.now(),
|
||||||
|
@ -79,7 +77,6 @@ def shift_overview(request):
|
||||||
lambda x: x is not None,
|
lambda x: x is not None,
|
||||||
(
|
(
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
.prefetch_related("event__calendar")
|
|
||||||
.filter(room=room, start_at__gt=timezone.now(), deleted=False)
|
.filter(room=room, start_at__gt=timezone.now(), deleted=False)
|
||||||
.order_by("start_at")
|
.order_by("start_at")
|
||||||
.first()
|
.first()
|
||||||
|
@ -96,9 +93,7 @@ def add_helper_shift(self):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def shift_detail(request, pk):
|
def shift_detail(request, pk):
|
||||||
shift = get_object_or_404(
|
shift = get_object_or_404(Shift, pk=pk)
|
||||||
Shift.with_reg_count().prefetch_related("shiftregistration_set__helper"), pk=pk
|
|
||||||
)
|
|
||||||
form = HelperShift()
|
form = HelperShift()
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
form = HelperShift(request.POST)
|
form = HelperShift(request.POST)
|
||||||
|
|
Loading…
Reference in New Issue