Fixes in event handling
This commit is contained in:
@@ -9,8 +9,8 @@ class ParticipationSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
event = serializers.PrimaryKeyRelatedField(queryset=Event.objects.all())
|
event = serializers.PrimaryKeyRelatedField(queryset=Event.objects.all())
|
||||||
user = serializers.CharField()
|
user = serializers.CharField()
|
||||||
status = serializers.CharField(required=False, default="-")
|
status = serializers.CharField(required=False)
|
||||||
comment = serializers.CharField(required=False, allow_blank=True, default="")
|
comment = serializers.CharField(required=False, allow_blank=True)
|
||||||
|
|
||||||
def to_representation(self, instance):
|
def to_representation(self, instance):
|
||||||
"""Serialize an EventParticipation instance."""
|
"""Serialize an EventParticipation instance."""
|
||||||
@@ -32,14 +32,19 @@ class ParticipationSerializer(serializers.Serializer):
|
|||||||
"""Create or update EventParticipation based on event and user."""
|
"""Create or update EventParticipation based on event and user."""
|
||||||
event = validated_data.get("event")
|
event = validated_data.get("event")
|
||||||
user = validated_data.get("user")
|
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(
|
participation, created = EventParticipation.objects.update_or_create(
|
||||||
event=event,
|
event=event,
|
||||||
user=user,
|
user=user,
|
||||||
defaults={"status": status, "comment": comment},
|
defaults=defaults,
|
||||||
)
|
)
|
||||||
|
|
||||||
return participation
|
return participation
|
||||||
|
|||||||
@@ -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="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -116,7 +116,7 @@
|
|||||||
$( ".deleteButton" ).click(function() {
|
$( ".deleteButton" ).click(function() {
|
||||||
if (confirm('Termin wirklich löschen?')) {
|
if (confirm('Termin wirklich löschen?')) {
|
||||||
pk = $(this).data( "pk" )
|
pk = $(this).data( "pk" )
|
||||||
window.location = pk + "/delete"
|
window.location = "/events/delete/" + pk + "/"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ def deleteEvent(request, pk):
|
|||||||
if not EventParticipation.isAdmin(request.user):
|
if not EventParticipation.isAdmin(request.user):
|
||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
Event.objects.get(pk=pk).delete()
|
Event.objects.get(pk=pk).delete()
|
||||||
return redirect(events_grid)
|
return redirect("eventplanner:events_grid")
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------ Detail Views ----------------------------------------------------
|
# ------------------------------------ Detail Views ----------------------------------------------------
|
||||||
|
|||||||
@@ -88,20 +88,6 @@ planning {% endcomment %} {% addtoblock "css" %}
|
|||||||
</div>
|
</div>
|
||||||
</article>
|
</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
|
<article
|
||||||
class="slide"
|
class="slide"
|
||||||
|
|||||||
Reference in New Issue
Block a user