SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 18198e8d authored by George Katsikas's avatar George Katsikas :goat:
Browse files

prefix htmx refactored views with _hx_

change prod user assignment forms to filter groups
parent 2cad5174
No related branches found
No related tags found
1 merge request!43Polish up new production page
Showing with 42 additions and 28 deletions
...@@ -82,12 +82,26 @@ class AssignOfficerForm(forms.ModelForm): ...@@ -82,12 +82,26 @@ class AssignOfficerForm(forms.ModelForm):
stream.save() stream.save()
return stream 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 AssignInvitationsOfficerForm(forms.ModelForm):
class Meta: class Meta:
model = ProductionStream model = ProductionStream
fields = ("invitations_officer",) 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 AssignSupervisorForm(forms.ModelForm):
class Meta: class Meta:
...@@ -96,7 +110,7 @@ class AssignSupervisorForm(forms.ModelForm): ...@@ -96,7 +110,7 @@ class AssignSupervisorForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*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" user__groups__name="Production Supervisor"
) )
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% csrf_token %} {% csrf_token %}
<div class="col">{{ form|bootstrap_purely_inline }}</div> <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" <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-swap="innerHTML"
hx-trigger="change from:select#productionstream_{{ stream.id }}_id_invitations_officer" hx-trigger="change from:select#productionstream_{{ stream.id }}_id_invitations_officer"
hx-target="this"></div> hx-target="this"></div>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% csrf_token %} {% csrf_token %}
<div class="col">{{ form|bootstrap_purely_inline }}</div> <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" <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-swap="innerHTML"
hx-trigger="change from:select#productionstream_{{ stream.id }}_id_officer" hx-trigger="change from:select#productionstream_{{ stream.id }}_id_officer"
hx-target="this"></div> hx-target="this"></div>
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<div class="row"> <div class="row">
<div class="col">{{ form|bootstrap_purely_inline }}</div> <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" <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-swap="innerHTML"
hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_status" hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_status"
hx-target="this"></div> hx-target="this"></div>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
{% csrf_token %} {% csrf_token %}
<div class="col">{{ form|bootstrap_purely_inline }}</div> <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" <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-swap="innerHTML"
hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_supervisor" hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_supervisor"
hx-target="this"></div> hx-target="this"></div>
......
...@@ -208,7 +208,7 @@ ...@@ -208,7 +208,7 @@
<div id="productionstream-{{ productionstream.id }}-event-list" <div id="productionstream-{{ productionstream.id }}-event-list"
class="overflow-scroll mb-4" class="overflow-scroll mb-4"
style="max-height: max(50vh, 40em)" 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"> 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 %} {% comment %} Placeholder before HTMX content loads {% endcomment %}
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<div id="productionstream-{{ productionstream.id }}-summary-assignees" <div id="productionstream-{{ productionstream.id }}-summary-assignees"
class="col-md-6" 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"> 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 %} {% comment %} Placeholder while HTMX is loading {% endcomment %}
......
...@@ -71,6 +71,16 @@ urlpatterns = [ ...@@ -71,6 +71,16 @@ urlpatterns = [
production_views._hx_productionstream_actions_work_log, production_views._hx_productionstream_actions_work_log,
name="_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( path(
"events/", "events/",
include( include(
...@@ -80,6 +90,11 @@ urlpatterns = [ ...@@ -80,6 +90,11 @@ urlpatterns = [
production_views._hx_event_form, production_views._hx_event_form,
name="_hx_event_form", name="_hx_event_form",
), ),
path(
"list",
production_views._hx_event_list,
name="_hx_event_list",
),
path( path(
"<int:event_id>/", "<int:event_id>/",
include( include(
...@@ -249,21 +264,6 @@ urlpatterns = [ ...@@ -249,21 +264,6 @@ urlpatterns = [
production_views.mark_as_completed, production_views.mark_as_completed,
name="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",
),
] ]
), ),
), ),
......
...@@ -1443,8 +1443,8 @@ def _hx_send_proofs(request, stream_id, version): ...@@ -1443,8 +1443,8 @@ def _hx_send_proofs(request, stream_id, version):
) )
def render_action_buttons(request, stream_id, key): def _hx_productionstream_change_action_buttons(request, productionstream_id, key):
productionstream = get_object_or_404(ProductionStream, pk=stream_id) 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 # Get either the id, or the id of the object and convert it to a string
# If this fails, set to "None" # If this fails, set to "None"
...@@ -1467,8 +1467,8 @@ def render_action_buttons(request, stream_id, key): ...@@ -1467,8 +1467,8 @@ def render_action_buttons(request, stream_id, key):
) )
def render_stream_assignees_status(request, stream_id): def _hx_productionstream_summary_assignees_status(request, productionstream_id):
productionstream = get_object_or_404(ProductionStream, pk=stream_id) productionstream = get_object_or_404(ProductionStream, pk=productionstream_id)
context = { context = {
"productionstream": productionstream, "productionstream": productionstream,
...@@ -1481,8 +1481,8 @@ def render_stream_assignees_status(request, stream_id): ...@@ -1481,8 +1481,8 @@ def render_stream_assignees_status(request, stream_id):
) )
def render_stream_events(request, stream_id): def _hx_event_list(request, productionstream_id):
productionstream = get_object_or_404(ProductionStream, pk=stream_id) productionstream = get_object_or_404(ProductionStream, pk=productionstream_id)
context = { context = {
"productionstream": productionstream, "productionstream": productionstream,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment