team shift qol
This commit is contained in:
parent
c4e30c83a1
commit
90fe5cd481
|
@ -124,6 +124,26 @@
|
|||
document.getElementById(el.dataset.target).classList.toggle('is-active');
|
||||
}
|
||||
}));
|
||||
|
||||
function selectAndCopyText(element) {
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
var selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
navigator.clipboard.writeText(window.getSelection());
|
||||
}
|
||||
|
||||
document.querySelectorAll('.select_all').forEach( e =>{
|
||||
e.addEventListener('touchstart', function(event) {
|
||||
selectAndCopyText(event.target);
|
||||
}, false);
|
||||
e.addEventListener('click', function(event) {
|
||||
selectAndCopyText(event.target);
|
||||
}, false);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
from base64 import urlsafe_b64encode
|
||||
from django.contrib import admin
|
||||
from django.shortcuts import reverse
|
||||
from .models import *
|
||||
|
@ -38,13 +37,3 @@ class TeamMemberAdmin(admin.ModelAdmin):
|
|||
|
||||
def shift_count(self, object):
|
||||
return object.fallback_shifts.count()
|
||||
|
||||
def url(self, object):
|
||||
return "https://helfen.kntkt.de" + reverse(
|
||||
"my_fallback_shifts",
|
||||
kwargs={
|
||||
"team_member_id": urlsafe_b64encode(
|
||||
object.id.to_bytes(3, byteorder="big")
|
||||
).decode("utf-8")
|
||||
},
|
||||
)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
from django import forms
|
||||
|
||||
# placeholder form for simple submit button use cases so we get csrf protection
|
||||
class EmptyForm(forms.Form):
|
||||
pass
|
|
@ -3,6 +3,7 @@ from django.db.models import Max, Sum
|
|||
from django.db.models import Count, Exists, OuterRef, ExpressionWrapper
|
||||
from django.db.models.lookups import LessThan
|
||||
from django.db.models.fields import DateTimeField
|
||||
from base64 import urlsafe_b64encode
|
||||
import math
|
||||
import secrets
|
||||
|
||||
|
@ -18,6 +19,16 @@ class TeamMember(models.Model):
|
|||
name = models.CharField(max_length=100)
|
||||
fallback_shifts = models.ManyToManyField(Shift, through="FallbackAssignment")
|
||||
|
||||
def url(self):
|
||||
return "https://helfen.kntkt.de" + reverse(
|
||||
"my_fallback_shifts",
|
||||
kwargs={
|
||||
"team_member_id": urlsafe_b64encode(
|
||||
self.id.to_bytes(3, byteorder="big")
|
||||
).decode("utf-8")
|
||||
},
|
||||
)
|
||||
|
||||
def assign_random_shifts(self):
|
||||
if self.fallback_shifts.count() != 0:
|
||||
return
|
||||
|
|
|
@ -7,6 +7,25 @@
|
|||
<section class="section">
|
||||
<div class="container">
|
||||
<h3 class="title">Fallback-Schichten für {{ team_member.name }}</h3>
|
||||
<a href="{% url 'pages:view' 'team_faq' %}">Häufig gestellte Fragen zu Teamschichten</a>
|
||||
|
||||
{% if shifts %}
|
||||
<pre class="select_all">
|
||||
Hallo {{ team_member.name }} , hier deine Teamschichten fuer das Festival:
|
||||
|
||||
{{ team_member.url }}
|
||||
|
||||
Deine Schichten werden in den nächsten Tagen weniger werden, wenn wir alle schichten unter mehr Teammitgliedern verteilen.
|
||||
Du kannst unter dem Link immer nachschauen, welche Schichten du noch hast und welche schon von Helfer:innen belegt sind.
|
||||
Bei Schichten mit mehreren Personen, bei denen nicht alle von Helfer:innen belegt sind, koordiniere dich bitte mit den anderen Teammitgliedern, wer von euch die Schicht übernimmt.
|
||||
Natürlich kannst du auch mit anderen Menschen deine Schichten tauschen, dafür seid ihr aber selbst verantwortlich und ihr könnt den Tausch nicht im System abbilden.
|
||||
Wenn du eine deiner Schichten machst, komm bitte 15 Minuten vorher kurz an den Infopoint, damit wir wissen dass du da bist.
|
||||
Danke für deine Hilfe
|
||||
Diese Schichtzuteilung wurde maschinell erstellt und ist auch ohne Unterschrift gültig
|
||||
</pre>
|
||||
|
||||
{% if is_draw %}
|
||||
{% endif %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -33,6 +52,16 @@
|
|||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% else %}
|
||||
{% if user.is_authenticated %}
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
<button class="button is-success" type="submit">Schichten zulosen</button>
|
||||
</form>
|
||||
{% else %}
|
||||
Noch keine Schichten zugewiesen, bitte wende dich an den Infopoint
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from base64 import urlsafe_b64decode
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from shiftregister.fallback.models import TeamMember
|
||||
from .forms import EmptyForm
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
@ -14,8 +15,16 @@ def my_fallback_shifts(request, team_member_id):
|
|||
team_member_id = None
|
||||
|
||||
team_member = get_object_or_404(TeamMember, pk=team_member_id)
|
||||
|
||||
after_draw = False
|
||||
if request.method == "POST":
|
||||
form = EmptyForm(request.POST)
|
||||
if form.is_valid():
|
||||
team_member.assign_random_shifts()
|
||||
after_draw = True
|
||||
context = {
|
||||
"team_member": team_member,
|
||||
"shifts": team_member.fallback_shifts.order_by("start_at").all(),
|
||||
"after_draw": after_draw,
|
||||
}
|
||||
return render(request, "my_fallback_shifts.html", context)
|
||||
|
|
Loading…
Reference in New Issue