diff --git a/scipost_django/production/forms.py b/scipost_django/production/forms.py index 979c19f2bca2b3bef697d70b3ba8d28573d4fc32..44af1bec6e71cdcafa5fb6ef831d8e76ab60ed64 100644 --- a/scipost_django/production/forms.py +++ b/scipost_django/production/forms.py @@ -82,12 +82,26 @@ class AssignOfficerForm(forms.ModelForm): stream.save() return stream + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["officer"].queryset = ProductionUser.objects.active().filter( + user__groups__name="Production Officers" + ) + class AssignInvitationsOfficerForm(forms.ModelForm): class Meta: model = ProductionStream fields = ("invitations_officer",) + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields[ + "invitations_officer" + ].queryset = ProductionUser.objects.active().filter( + user__groups__name="Production Officers" + ) + class AssignSupervisorForm(forms.ModelForm): class Meta: @@ -96,7 +110,7 @@ class AssignSupervisorForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.fields["supervisor"].queryset = self.fields["supervisor"].queryset.filter( + self.fields["supervisor"].queryset = ProductionUser.objects.active().filter( user__groups__name="Production Supervisor" ) diff --git a/scipost_django/production/templates/production/_hx_productionstream_change_invitations_officer.html b/scipost_django/production/templates/production/_hx_productionstream_change_invitations_officer.html index f4c7284ffe7816cf4acfa94e7844d9552826e87f..ac9e3efc8ba0ad5ddb719dbb080aa0fda5cb936f 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_change_invitations_officer.html +++ b/scipost_django/production/templates/production/_hx_productionstream_change_invitations_officer.html @@ -9,7 +9,7 @@ {% csrf_token %} <div class="col">{{ form|bootstrap_purely_inline }}</div> <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty" - hx-post="{% url 'production:render_action_buttons' stream.id 'invitations_officer' %}" + hx-post="{% url 'production:_hx_productionstream_change_action_buttons' stream.id 'invitations_officer' %}" hx-swap="innerHTML" hx-trigger="change from:select#productionstream_{{ stream.id }}_id_invitations_officer" hx-target="this"></div> diff --git a/scipost_django/production/templates/production/_hx_productionstream_change_officer.html b/scipost_django/production/templates/production/_hx_productionstream_change_officer.html index 8a1c7d8dfe12422142021ca431f2d248b7cf3c08..2efbd7f2ebb9f75e1f2e64f85e11ed8f0248086d 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_change_officer.html +++ b/scipost_django/production/templates/production/_hx_productionstream_change_officer.html @@ -9,7 +9,7 @@ {% csrf_token %} <div class="col">{{ form|bootstrap_purely_inline }}</div> <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty" - hx-post="{% url 'production:render_action_buttons' stream.id 'officer' %}" + hx-post="{% url 'production:_hx_productionstream_change_action_buttons' stream.id 'officer' %}" hx-swap="innerHTML" hx-trigger="change from:select#productionstream_{{ stream.id }}_id_officer" hx-target="this"></div> diff --git a/scipost_django/production/templates/production/_hx_productionstream_change_status.html b/scipost_django/production/templates/production/_hx_productionstream_change_status.html index 59fd5c29d2c7a27f82a300429e8282b575b61801..874111480ad50645cf1518a02f55608d585e0069 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_change_status.html +++ b/scipost_django/production/templates/production/_hx_productionstream_change_status.html @@ -11,7 +11,7 @@ <div class="row"> <div class="col">{{ form|bootstrap_purely_inline }}</div> <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty" - hx-post="{% url 'production:render_action_buttons' stream.id 'status' %}" + hx-post="{% url 'production:_hx_productionstream_change_action_buttons' stream.id 'status' %}" hx-swap="innerHTML" hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_status" hx-target="this"></div> diff --git a/scipost_django/production/templates/production/_hx_productionstream_change_supervisor.html b/scipost_django/production/templates/production/_hx_productionstream_change_supervisor.html index aa86793c1e8dff0a2436e7e39d729e30824761aa..4ce3afd863abb8ac1a9ece6f79340083938592c1 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_change_supervisor.html +++ b/scipost_django/production/templates/production/_hx_productionstream_change_supervisor.html @@ -9,7 +9,7 @@ {% csrf_token %} <div class="col">{{ form|bootstrap_purely_inline }}</div> <div class="col-12 col-sm-auto col-md-12 col-lg-auto h-100 d-none-empty" - hx-post="{% url 'production:render_action_buttons' stream.id 'supervisor' %}" + hx-post="{% url 'production:_hx_productionstream_change_action_buttons' stream.id 'supervisor' %}" hx-swap="innerHTML" hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_supervisor" hx-target="this"></div> diff --git a/scipost_django/production/templates/production/_hx_productionstream_details_contents.html b/scipost_django/production/templates/production/_hx_productionstream_details_contents.html index 5b98feb1da047f656503b0feef8bacd1f3be67a0..2fdf85f4ffcb53b7ad0a3267ed5329cd068435e0 100644 --- a/scipost_django/production/templates/production/_hx_productionstream_details_contents.html +++ b/scipost_django/production/templates/production/_hx_productionstream_details_contents.html @@ -208,7 +208,7 @@ <div id="productionstream-{{ productionstream.id }}-event-list" class="overflow-scroll mb-4" style="max-height: max(50vh, 40em)" - hx-get="{% url 'production:render_stream_events' productionstream.id %}" + hx-get="{% url 'production:_hx_event_list' productionstream.id %}" hx-trigger="intersect once, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500, click from:#productionstream-{{ productionstream.id }}-details target:.proof-action-button delay:500"> {% comment %} Placeholder before HTMX content loads {% endcomment %} diff --git a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html index 402f4392241c9060d2f726b5ee77cd75f6482c51..6fb15371a18c733794117ae31a8497750b3aab03 100644 --- a/scipost_django/production/templates/production/_productionstream_details_summary_contents.html +++ b/scipost_django/production/templates/production/_productionstream_details_summary_contents.html @@ -93,7 +93,7 @@ <div id="productionstream-{{ productionstream.id }}-summary-assignees" class="col-md-6" - hx-get="{% url 'production:render_stream_assignees_status' productionstream.id %}" + hx-get="{% url 'production:_hx_productionstream_summary_assignees_status' productionstream.id %}" hx-trigger="intersect once, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500, click from:#productionstream-{{ productionstream.id }}-details target:.proof-action-button delay:500, submit from:#productionstreams-filter-details target:#productionstreams-bulk-action-form delay:500"> {% comment %} Placeholder while HTMX is loading {% endcomment %} diff --git a/scipost_django/production/urls.py b/scipost_django/production/urls.py index 23963b08ec18829e0d6949a3acffbe0ddc8d6a25..81e04bc2e833da0da4b1dbdd2c9a1ce49bba0bd0 100644 --- a/scipost_django/production/urls.py +++ b/scipost_django/production/urls.py @@ -71,6 +71,16 @@ urlpatterns = [ production_views._hx_productionstream_actions_work_log, name="_hx_productionstream_actions_work_log", ), + path( + "_hx_productionstream_change_action_buttons/<str:key>", + production_views._hx_productionstream_change_action_buttons, + name="_hx_productionstream_change_action_buttons", + ), + path( + "_hx_productionstream_summary_assignees_status", + production_views._hx_productionstream_summary_assignees_status, + name="_hx_productionstream_summary_assignees_status", + ), path( "events/", include( @@ -80,6 +90,11 @@ urlpatterns = [ production_views._hx_event_form, name="_hx_event_form", ), + path( + "list", + production_views._hx_event_list, + name="_hx_event_list", + ), path( "<int:event_id>/", include( @@ -249,21 +264,6 @@ urlpatterns = [ production_views.mark_as_completed, name="mark_as_completed", ), - path( - "render_action_buttons/<str:key>", - production_views.render_action_buttons, - name="render_action_buttons", - ), - path( - "render_stream_assignees_status", - production_views.render_stream_assignees_status, - name="render_stream_assignees_status", - ), - path( - "render_stream_events", - production_views.render_stream_events, - name="render_stream_events", - ), ] ), ), diff --git a/scipost_django/production/views.py b/scipost_django/production/views.py index bbb973b9aa7496dc785f488ce345a52c252ae465..679b5770823d319f0b638c455cf677a6eed8fa03 100644 --- a/scipost_django/production/views.py +++ b/scipost_django/production/views.py @@ -1443,8 +1443,8 @@ def _hx_send_proofs(request, stream_id, version): ) -def render_action_buttons(request, stream_id, key): - productionstream = get_object_or_404(ProductionStream, pk=stream_id) +def _hx_productionstream_change_action_buttons(request, productionstream_id, key): + productionstream = get_object_or_404(ProductionStream, pk=productionstream_id) # Get either the id, or the id of the object and convert it to a string # If this fails, set to "None" @@ -1467,8 +1467,8 @@ def render_action_buttons(request, stream_id, key): ) -def render_stream_assignees_status(request, stream_id): - productionstream = get_object_or_404(ProductionStream, pk=stream_id) +def _hx_productionstream_summary_assignees_status(request, productionstream_id): + productionstream = get_object_or_404(ProductionStream, pk=productionstream_id) context = { "productionstream": productionstream, @@ -1481,8 +1481,8 @@ def render_stream_assignees_status(request, stream_id): ) -def render_stream_events(request, stream_id): - productionstream = get_object_or_404(ProductionStream, pk=stream_id) +def _hx_event_list(request, productionstream_id): + productionstream = get_object_or_404(ProductionStream, pk=productionstream_id) context = { "productionstream": productionstream,