diff --git a/alexia/apps/general/templatetags/get_item.py b/alexia/apps/general/templatetags/get_item.py new file mode 100644 index 0000000..ccfac04 --- /dev/null +++ b/alexia/apps/general/templatetags/get_item.py @@ -0,0 +1,7 @@ +from django import template + +register = template.Library() + +@register.filter +def get_item(key, dictionary): + return dictionary.get(key) diff --git a/alexia/apps/scheduling/views.py b/alexia/apps/scheduling/views.py index fa6d026..ffcace2 100644 --- a/alexia/apps/scheduling/views.py +++ b/alexia/apps/scheduling/views.py @@ -109,6 +109,8 @@ def event_list_view(request): # Net als onze BartenderAvailabilities bartender_availabilities = BartenderAvailability.objects.filter( user_id=request.user.pk).values('event_id', 'availability_id', 'comment') + + bartender_availabilities = {ba['event_id']: ba for ba in bartender_availabilities} return render(request, 'scheduling/event_list.html', locals()) @@ -340,7 +342,7 @@ def set_bartender_availability_comment(request): return HttpResponseBadRequest("NOTOK") comment = request.POST.get('comment') - if len(comment) > BartenderAvailability.comment.max_length: + if len(comment) > 100: return HttpResponseBadRequest("TOOLONG") availability = get_object_or_404(BartenderAvailability, event=event, user=request.user) availability.comment = comment diff --git a/assets/js/application.js b/assets/js/application.js index 77beafd..893f7b3 100644 --- a/assets/js/application.js +++ b/assets/js/application.js @@ -78,7 +78,8 @@ $(function () { event_id: event_id, availability_id: $(this).val() }, function (data) { - $('#assigned_bartenders_' + event_id).html(data).effect("highlight"); + $('#assigned_bartenders_' + event_id).html(data); + $('#bartender_availability_comment_' + event_id).css('visibility', 'visible'); }, "text"); }); diff --git a/templates/scheduling/event_list.html b/templates/scheduling/event_list.html index d253dbc..a1fd4f3 100644 --- a/templates/scheduling/event_list.html +++ b/templates/scheduling/event_list.html @@ -1,4 +1,5 @@ {% extends 'base_app.html' %} +{% load get_item %} {% block title %}{% trans 'Planning' %}{% endblock title %} @@ -105,30 +106,17 @@