SciPost Code Repository

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

convert creation of nominations into a button

parent 4536d03f
No related branches found
No related tags found
1 merge request!58[Fellowship Nominations] Rework the fellowship nomination system and UI
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
<div class="m-2 p-4 border border-warning">
<h3>Nomination to Fellowship:&emsp;<span class="bg-success bg-opacity-25 p-2"><em>{{ profile }}</em></span></h3> <h3>
<form Nomination to Fellowship:&emsp;<span class="bg-success bg-opacity-25 p-2"><em>{{ profile }}</em></span>
hx-post="{% url 'colleges:_hx_nomination_form' profile_id=profile.pk %}" </h3>
hx-target="#nomination_form_response" <form hx-post="{% url 'colleges:_hx_nomination_form' profile_id=profile.pk %}"
hx-indicator="#nomination_form_response-indicator" hx-target="#new-nomination-container"
> hx-indicator="#nomination_form_response-indicator">
{% crispy nomination_form %} {% crispy nomination_form %}
</form> </form>
</div>
{% load crispy_forms_tags %}
<div class="p-3 border border-success rounded rounded-lg">
<h2 class="mb-4">Nominate a new potential Fellow</h2>
<div class="row">
<div class="col-lg-6">
<h3>Procedure</h3>
<ul>
<li>Type your search query in the search form</li>
<li>
When the name you're looking for appears in the
<em>Matching profiles</em> list, double-click on it
</li>
<li>The nomination form will appear below</li>
<li>Non-eligibility flags (if any) will appear</li>
<li>If eligible, fill the form in (comments are optional)</li>
<li>Submit! (the vote will be arranged by EdAdmin)</li>
</ul>
<div class="row mb-0">
<div class="col-12">
<form hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}"
hx-trigger="keyup delay:200ms, change"
hx-target="#profile_dynsel_results"
hx-indicator="#profile_dynsel_results-indicator">
<div id="profile_dynsel_form">{% crispy profile_dynsel_form %}</div>
</form>
</div>
</div>
<div class="row mb-0">
<div class="col-auto">
<div id="nomination_form_response-indicator" class="htmx-indicator">
<button class="btn btn-sm btn-warning" type="button" disabled>
<strong>Loading form...</strong>
<div class="spinner-grow spinner-grow-sm ms-2"
role="status"
aria-hidden="true"></div>
</button>
</div>
</div>
<div class="col-auto">
<div id="profile_dynsel_results-indicator" class="htmx-indicator">
<button class="btn btn-sm btn-warning" type="button" disabled>
<strong>Loading results...</strong>
<div class="spinner-grow spinner-grow-sm ms-2"
role="status"
aria-hidden="true"></div>
</button>
</div>
</div>
</div>
</div>
<div class="col-lg-6">
<h3>Matching profiles</h3>
<div id="profile_dynsel_results" class="border border-light m-2 p-1"></div>
</div>
</div>
<div id="nomination_form_response">
<h3 class="mb-2">Not found?</h3>
<p>
Then add to our database by <a href="{% url 'profiles:profile_create' %}" target="_blank">creating a new Profile</a> (opens in new window).
</p>
</div>
</div>
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
&nbsp;<strong>Help out by nominating candidates!</strong> &nbsp;<strong>Help out by nominating candidates!</strong>
</p> </p>
<div id="new-nomination-container"></div>
<details id="voting_rounds-filter-details" class="card my-4"> <details id="voting_rounds-filter-details" class="card my-4">
<summary class="card-header d-flex flex-row align-items-center justify-content-between list-triangle"> <summary class="card-header d-flex flex-row align-items-center justify-content-between list-triangle">
<div class="fs-3">Search / Filter</div> <div class="fs-3">Search / Filter</div>
...@@ -50,7 +52,16 @@ ...@@ -50,7 +52,16 @@
hx-get="{% url 'colleges:_hx_voting_round_search_form' filter_set="empty" %}" hx-get="{% url 'colleges:_hx_voting_round_search_form' filter_set="empty" %}"
hx-target="#voting_round-search-form-container">Clear Filters</button> hx-target="#voting_round-search-form-container">Clear Filters</button>
<a id="refresh-button" class="m-2 btn btn-primary"> <button class="btn btn-success me-2 text-white"
type="button"
hx-get="{% url 'colleges:_hx_nominations_new' %}"
hx-trigger="click"
hx-target="#new-nomination-container">
{% include "bi/plus-square.html" %}
&nbsp;Add New
</button>
<a id="refresh-button" class="me-2 btn btn-primary">
{% include "bi/arrow-clockwise.html" %} {% include "bi/arrow-clockwise.html" %}
&nbsp;Refresh</a> &nbsp;Refresh</a>
</div> </div>
...@@ -65,80 +76,6 @@ ...@@ -65,80 +76,6 @@
<div id="search-voting_rounds-results" class="mt-2"></div> <div id="search-voting_rounds-results" class="mt-2"></div>
<details class="border border-warning border-2 mt-4">
<summary class="bg-warning bg-opacity-10 p-2 d-block list-triangle">
<div class="fs-5">Nominate</div>
</summary>
<div class="p-2">
<div class="row">
<div class="col-lg-6">
<h3>Procedure</h3>
<ul>
<li>Type your search query in the search form</li>
<li>
When the name you're looking for appears in the
<em>Matching profiles</em> list, double-click on it
</li>
<li>The nomination form will appear below</li>
<li>Non-eligibility flags (if any) will appear</li>
<li>If eligible, fill the form in (comments are optional)</li>
<li>Submit! (the vote will be arranged by EdAdmin)</li>
</ul>
<div class="row">
<div class="col-8">
<form hx-post="{% url 'profiles:_hx_profile_dynsel_list' %}"
hx-trigger="keyup delay:200ms, change"
hx-target="#profile_dynsel_results"
hx-indicator="#profile_dynsel_results-indicator">
<div id="profile_dynsel_form">{% crispy profile_dynsel_form %}</div>
</form>
</div>
<div class="col-2">
<div id="nomination_form_response-indicator" class="htmx-indicator">
<button class="btn btn-sm btn-warning" type="button" disabled>
<strong>Loading form...</strong>
<div class="spinner-grow spinner-grow-sm ms-2"
role="status"
aria-hidden="true"></div>
</button>
</div>
</div>
<div class="col-2">
<div id="profile_dynsel_results-indicator" class="htmx-indicator">
<button class="btn btn-sm btn-warning" type="button" disabled>
<strong>Loading results...</strong>
<div class="spinner-grow spinner-grow-sm ms-2"
role="status"
aria-hidden="true"></div>
</button>
</div>
</div>
</div>
<h3 class="mb-2">Not found?</h3>
<p>
Then add to our database by <a href="{% url 'profiles:profile_create' %}" target="_blank">creating a new Profile</a> (opens in new window).
</p>
</div>
<div class="col-lg-6">
<h3>Matching profiles</h3>
<div id="profile_dynsel_results" class="border border-light m-2 p-1"></div>
</div>
</div>
<div id="nomination_form_response"></div>
</div>
</details>
{% if "edadmin" in user_roles or "active_senior_fellow" in user_roles %} {% if "edadmin" in user_roles or "active_senior_fellow" in user_roles %}
<details id="ensure-specialties-details" <details id="ensure-specialties-details"
class="border border-danger border-2 mt-4"> class="border border-danger border-2 mt-4">
......
...@@ -273,6 +273,11 @@ urlpatterns = [ ...@@ -273,6 +273,11 @@ urlpatterns = [
views._hx_nominations_invitations, views._hx_nominations_invitations,
name="_hx_nominations_invitations", name="_hx_nominations_invitations",
), ),
path(
"_hx_nominations_new",
views._hx_nominations_new,
name="_hx_nominations_new",
),
path( path(
"fellowship_invitation/<int:pk>/email_initial", "fellowship_invitation/<int:pk>/email_initial",
views.FellowshipInvitationEmailInitialView.as_view(), views.FellowshipInvitationEmailInitialView.as_view(),
......
...@@ -697,18 +697,8 @@ def nominations(request): ...@@ -697,18 +697,8 @@ def nominations(request):
""" """
List Nominations. List Nominations.
""" """
profile_dynsel_form = ProfileDynSelForm(
initial={
"action_url_name": "colleges:_hx_nomination_form",
"action_url_base_kwargs": {},
"action_target_element_id": "nomination_form_response",
"action_target_swap": "innerHTML",
}
)
context = { context = {
"profile_dynsel_form": profile_dynsel_form,
"search_nominations_form": FellowshipNominationSearchForm(), "search_nominations_form": FellowshipNominationSearchForm(),
"rounds": FellowshipNominationVotingRound.objects.all()[:10],
} }
return render(request, "colleges/nominations.html", context) return render(request, "colleges/nominations.html", context)
...@@ -1050,6 +1040,24 @@ def _hx_nomination_decision_form(request, round_id): ...@@ -1050,6 +1040,24 @@ def _hx_nomination_decision_form(request, round_id):
return render(request, "colleges/_hx_nomination_decision_form.html", context) return render(request, "colleges/_hx_nomination_decision_form.html", context)
# Check permission to create a new nomination
def _hx_nominations_new(request):
"""Render the contents of the new nomination form."""
profile_dynsel_form = ProfileDynSelForm(
initial={
"action_url_name": "colleges:_hx_nomination_form",
"action_url_base_kwargs": {},
"action_target_element_id": "nomination_form_response",
"action_target_swap": "innerHTML",
}
)
context = {
"profile_dynsel_form": profile_dynsel_form,
}
return render(request, "colleges/_hx_nominations_new.html", context)
@login_required @login_required
@user_passes_test(is_edadmin) @user_passes_test(is_edadmin)
def _hx_nominations_invitations(request): def _hx_nominations_invitations(request):
......
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