Fixes in event handling

This commit is contained in:
2026-04-09 14:50:28 +02:00
parent 4fe0b41335
commit 377e73a491
5 changed files with 17 additions and 23 deletions

View File

@@ -9,8 +9,8 @@ class ParticipationSerializer(serializers.Serializer):
event = serializers.PrimaryKeyRelatedField(queryset=Event.objects.all())
user = serializers.CharField()
status = serializers.CharField(required=False, default="-")
comment = serializers.CharField(required=False, allow_blank=True, default="")
status = serializers.CharField(required=False)
comment = serializers.CharField(required=False, allow_blank=True)
def to_representation(self, instance):
"""Serialize an EventParticipation instance."""
@@ -32,14 +32,19 @@ class ParticipationSerializer(serializers.Serializer):
"""Create or update EventParticipation based on event and user."""
event = validated_data.get("event")
user = validated_data.get("user")
status = validated_data.get("status", "-")
comment = validated_data.get("comment", "")
# Use update_or_create to handle both new and existing participations
# Only include fields that were actually present in the request,
# so a status-only update doesn't wipe the comment (and vice versa).
defaults = {}
if "status" in validated_data:
defaults["status"] = validated_data["status"]
if "comment" in validated_data:
defaults["comment"] = validated_data["comment"]
participation, created = EventParticipation.objects.update_or_create(
event=event,
user=user,
defaults={"status": status, "comment": comment},
defaults=defaults,
)
return participation

View File

@@ -1,4 +1,7 @@
{% extends "website/base.html" %} {% load sekizai_tags static %} {% load crispy_forms_tags %} {% block content %} {{ form.media }}
{% extends "website/base.html" %} {% load sekizai_tags static %} {% load crispy_forms_tags %}
{% block content %}
{% addtoblock "css" %}{% for item in form.media.render_css %}{{ item }}{% endfor %}{% endaddtoblock %}
{% addtoblock "js" %}{% for item in form.media.render_js %}{{ item }}{% endfor %}{% endaddtoblock %}
<div class="container">
<div class="row">

View File

@@ -116,7 +116,7 @@
$( ".deleteButton" ).click(function() {
if (confirm('Termin wirklich löschen?')) {
pk = $(this).data( "pk" )
window.location = pk + "/delete"
window.location = "/events/delete/" + pk + "/"
}
});

View File

@@ -118,7 +118,7 @@ def deleteEvent(request, pk):
if not EventParticipation.isAdmin(request.user):
raise PermissionDenied
Event.objects.get(pk=pk).delete()
return redirect(events_grid)
return redirect("eventplanner:events_grid")
# ------------------------------------ Detail Views ----------------------------------------------------

View File

@@ -88,20 +88,6 @@ planning {% endcomment %} {% addtoblock "css" %}
</div>
</article>
<article
class="slide"
id="slide_messages"
style="background: url('{{STATIC_URL}}img/backgrounds/silver.jpg') repeat-x top center;"
>
<img
class="asset left-30 sp600 t120 z1"
src="{{STATIC_URL}}img/slides/gruppe.png"
/>
<div class="info">
<a href="/messages">Forum</a>
<div class="subtitle">Nachricht an alle schreiben...</div>
</div>
</article>
<article
class="slide"