SciPost Code Repository

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

differentiate form ids on production page

update assignee status on form submission
format html structure automatically
parent d12c8a54
No related branches found
No related tags found
1 merge request!43Polish up new production page
{% load bootstrap %} {% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.invitations_officer.choices|length > 0 %} {% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.invitations_officer.choices|length > 0 %}
<div id="productionstream-update-invitations_officer"> <div id="productionstream-update-invitations_officer">
<form hx-post="{% url 'production:update_invitations_officer' stream.id %}" hx-target="#productionstream-update-invitations_officer" hx-swap="outerHTML" class="row"> <form hx-post="{% url 'production:update_invitations_officer' stream.id %}"
{% csrf_token %} hx-target="#productionstream-update-invitations_officer"
<div class="col"> hx-swap="outerHTML"
{{form|bootstrap_purely_inline}} class="row">
</div> {% csrf_token %}
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'invitations_officer' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="change from:select#id_invitations_officer" hx-target="this"> <div class="col">{{ form|bootstrap_purely_inline }}</div>
</div> <div class="col-auto h-100"
<div class="text-primary">{{message}}</div> hx-post="{% url 'production:render_action_buttons' stream.id 'invitations_officer' %}"
</form> hx-swap="innerHTML"
</div> class="col-auto"
{% endif %} hx-trigger="change from:select#productionstream_{{ stream.id }}_id_invitations_officer"
\ No newline at end of file hx-target="this"></div>
<div class="text-primary">{{ message }}</div>
</form>
</div>
{% endif %}
{% load bootstrap %} {% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.officer.choices|length > 0 %} {% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.officer.choices|length > 0 %}
<div id="productionstream-update-officer"> <div id="productionstream-update-officer">
<form hx-post="{% url 'production:update_officer' stream.id %}" hx-target="#productionstream-update-officer" hx-swap="outerHTML" class="row"> <form hx-post="{% url 'production:update_officer' stream.id %}"
{% csrf_token %} hx-target="#productionstream-update-officer"
<div class="col"> hx-swap="outerHTML"
{{form|bootstrap_purely_inline}} class="row">
</div> {% csrf_token %}
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'officer' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="change from:select#id_officer" hx-target="this"> <div class="col">{{ form|bootstrap_purely_inline }}</div>
</div> <div class="col-auto h-100"
<div class="text-primary">{{message}}</div> hx-post="{% url 'production:render_action_buttons' stream.id 'officer' %}"
</form> hx-swap="innerHTML"
</div> class="col-auto"
{% endif %} hx-trigger="change from:select#productionstream_{{ stream.id }}_id_officer"
\ No newline at end of file hx-target="this"></div>
<div class="text-primary">{{ message }}</div>
</form>
</div>
{% endif %}
{% load bootstrap %} {% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.status.choices|length > 0 %} {% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.status.choices|length > 0 %}
<div id="productionstream-update-status">
<form hx-post="{% url 'production:update_status' stream.id %}" hx-target="#productionstream-update-status" hx-swap="outerHTML" class="row"> <form id="productionstream-update-status"
hx-post="{% url 'production:update_status' stream.id %}"
hx-target="this"
hx-swap="outerHTML"
class="row">
{% csrf_token %} {% csrf_token %}
<div class="col"> <div class="col">{{ form|bootstrap_purely_inline }}</div>
{{form|bootstrap_purely_inline}} <div class="col-auto h-100"
</div> hx-post="{% url 'production:render_action_buttons' stream.id 'status' %}"
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'status' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="load, change from:select#id_status" hx-target="this"> hx-swap="innerHTML"
</div> class="col-auto"
<div class="text-primary">{{message}}</div> hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_status"
hx-target="this"></div>
<div class="text-primary">{{ message }}</div>
</form> </form>
</div>
{% endif %} {% endif %}
\ No newline at end of file
{% load bootstrap %} {% load bootstrap %}
{% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.supervisor.choices|length > 0 %} {% if perms.scipost.can_take_decisions_related_to_proofs and form.fields.supervisor.choices|length > 0 %}
<div id="productionstream-update-supervisor"> <div id="productionstream-update-supervisor">
<form hx-post="{% url 'production:update_supervisor' stream.id %}" hx-target="#productionstream-update-supervisor" hx-swap="outerHTML" class="row"> <form hx-post="{% url 'production:update_supervisor' stream.id %}"
{% csrf_token %} hx-target="#productionstream-update-supervisor"
<div class="col"> hx-swap="outerHTML"
{{form|bootstrap_purely_inline}} class="row">
</div> {% csrf_token %}
<div class="col-auto h-100" hx-post="{% url 'production:render_action_buttons' stream.id 'supervisor' %}" hx-swap="innerHTML" class="col-auto" hx-trigger="load, change from:select#id_supervisor" hx-target="this"> <div class="col">{{ form|bootstrap_purely_inline }}</div>
</div> <div class="col-auto h-100"
<div class="text-primary">{{message}}</div> hx-post="{% url 'production:render_action_buttons' stream.id 'supervisor' %}"
</form> hx-swap="innerHTML"
</div> class="col-auto"
{% endif %} hx-trigger="load, change from:select#productionstream_{{ stream.id }}_id_supervisor"
\ No newline at end of file hx-target="this"></div>
<div class="text-primary">{{ message }}</div>
</form>
</div>
{% endif %}
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</p> </p>
<div class="row overflow-hidden" style="height: min(50vh, 40em)"> <div class="row overflow-hidden" style="height: min(50vh, 40em)">
<div class="col-lg-6"> <div class="col-lg-6 h-100 overflow-scroll">
<h3>Actions</h3> <h3>Actions</h3>
{% if "can_perform_supervisory_actions" in sub_perms %} {% if "can_perform_supervisory_actions" in sub_perms %}
<div class="container"> <div class="container">
......
{% for productionstream in page_obj %} {% for productionstream in page_obj %}
<div class="ms-3 mt-3"><strong>{{ forloop.counter0|add:start_index }} of {{ count }}</strong></div> <div class="ms-3 mt-3">
<strong>{{ forloop.counter0|add:start_index }} of {{ count }}</strong>
</div>
{% include 'production/_hx_productionstream_details.html' with productionstream=productionstream %} {% include 'production/_hx_productionstream_details.html' with productionstream=productionstream %}
{% empty %} {% empty %}
<strong>No Production Stream could be found</strong> <strong>No Production Stream could be found</strong>
...@@ -9,12 +11,15 @@ ...@@ -9,12 +11,15 @@
hx-include="#search-productionstreams-form" hx-include="#search-productionstreams-form"
hx-trigger="revealed" hx-trigger="revealed"
hx-swap="afterend" hx-swap="afterend"
hx-indicator="#indicator-search-page-{{ page_obj.number }}" hx-indicator="#indicator-search-page-{{ page_obj.number }}">
> <div id="indicator-search-page-{{ page_obj.number }}"
<div id="indicator-search-page-{{ page_obj.number }}" class="htmx-indicator p-2"> class="htmx-indicator p-2">
<button class="btn btn-warning" type="button" disabled> <button class="btn btn-warning" type="button" disabled>
<strong>Loading page {{ page_obj.next_page_number }} out of {{ page_obj.paginator.num_pages }}</strong> <strong>Loading page {{ page_obj.next_page_number }} out of {{ page_obj.paginator.num_pages }}</strong>
<div class="spinner-grow spinner-grow-sm ms-2" role="status" aria-hidden="true"></div>
<div class="spinner-grow spinner-grow-sm ms-2"
role="status"
aria-hidden="true"></div>
</button> </button>
</div> </div>
</div> </div>
......
...@@ -50,5 +50,6 @@ ...@@ -50,5 +50,6 @@
<div id="productionstream-{{ productionstream.id }}-summary-assignees" <div id="productionstream-{{ productionstream.id }}-summary-assignees"
class="col col-md-4 border-start" class="col col-md-4 border-start"
hx-get="{% url 'production:render_stream_assignees_status' productionstream.id %}" hx-get="{% url 'production:render_stream_assignees_status' productionstream.id %}"
hx-trigger="load"></div> hx-trigger="load, submit from:#productionstream-{{ productionstream.id }}-details target:form delay:500">
</div>
</div> </div>
...@@ -87,16 +87,21 @@ def _hx_productionstream_list(request): ...@@ -87,16 +87,21 @@ def _hx_productionstream_list(request):
def _hx_productionstream_details_contents(request, productionstream_id): def _hx_productionstream_details_contents(request, productionstream_id):
productionstream = get_object_or_404(ProductionStream, pk=productionstream_id) productionstream = get_object_or_404(ProductionStream, pk=productionstream_id)
status_form = StreamStatusForm( status_form = StreamStatusForm(
instance=productionstream, production_user=request.user.production_user instance=productionstream,
production_user=request.user.production_user,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
supervisor_form = AssignSupervisorForm( supervisor_form = AssignSupervisorForm(
instance=productionstream, instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
inv_officer_form = AssignInvitationsOfficerForm( inv_officer_form = AssignInvitationsOfficerForm(
instance=productionstream, instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
prod_officer_form = AssignOfficerForm( prod_officer_form = AssignOfficerForm(
instance=productionstream, instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
context = { context = {
...@@ -361,6 +366,7 @@ def update_status(request, stream_id): ...@@ -361,6 +366,7 @@ def update_status(request, stream_id):
request.POST or None, request.POST or None,
instance=productionstream, instance=productionstream,
production_user=request.user.production_user, production_user=request.user.production_user,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
if status_form.is_valid(): if status_form.is_valid():
...@@ -460,7 +466,9 @@ def update_officer(request, stream_id): ...@@ -460,7 +466,9 @@ def update_officer(request, stream_id):
} }
else: else:
prod_officer_form = AssignOfficerForm( prod_officer_form = AssignOfficerForm(
request.POST or None, instance=productionstream request.POST or None,
instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
if prod_officer_form.is_valid(): if prod_officer_form.is_valid():
prod_officer_form.save() prod_officer_form.save()
...@@ -601,7 +609,9 @@ def update_invitations_officer(request, stream_id): ...@@ -601,7 +609,9 @@ def update_invitations_officer(request, stream_id):
} }
else: else:
inv_officer_form = AssignInvitationsOfficerForm( inv_officer_form = AssignInvitationsOfficerForm(
request.POST or None, instance=productionstream request.POST or None,
instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
if inv_officer_form.is_valid(): if inv_officer_form.is_valid():
inv_officer_form.save() inv_officer_form.save()
...@@ -731,7 +741,9 @@ def update_supervisor(request, stream_id): ...@@ -731,7 +741,9 @@ def update_supervisor(request, stream_id):
ProductionStream.objects.ongoing(), pk=stream_id ProductionStream.objects.ongoing(), pk=stream_id
) )
supervisor_form = AssignSupervisorForm( supervisor_form = AssignSupervisorForm(
request.POST or None, instance=productionstream request.POST or None,
instance=productionstream,
auto_id=f"productionstream_{productionstream.id}_id_%s",
) )
prev_supervisor = productionstream.supervisor prev_supervisor = productionstream.supervisor
......
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