Skip to content

Commit

Permalink
Hide Petitions (#320)
Browse files Browse the repository at this point in the history
* new pref

* lint
  • Loading branch information
Incompleteusern authored Oct 27, 2023
1 parent b3b0738 commit 96011b3
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 33 deletions.
20 changes: 20 additions & 0 deletions core/migrations/0058_unitgroup_guest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.5 on 2023-10-16 23:53

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0057_userprofile_show_portal_instructions"),
]

operations = [
migrations.AddField(
model_name="unitgroup",
name="guest",
field=models.BooleanField(
default=False, help_text="Whether this unit is a guest unit."
),
preserve_default=False,
),
]
25 changes: 25 additions & 0 deletions core/migrations/0059_remove_unitgroup_guest_and_more.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.5 on 2023-10-26 01:07

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("core", "0058_unitgroup_guest"),
]

operations = [
migrations.RemoveField(
model_name="unitgroup",
name="guest",
),
migrations.AddField(
model_name="userprofile",
name="show_unit_petitions",
field=models.BooleanField(
default=True,
help_text="Show previous unit petitions that you have requested. Useful to disable if you have far too many.",
verbose_name="Show unit petitions",
),
),
]
5 changes: 5 additions & 0 deletions core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ class UserProfile(models.Model):
help_text="Show the instruction text above the units on the home page",
default=True,
)
show_unit_petitions = models.BooleanField(
verbose_name="Show unit petitions",
help_text="Show previous unit petitions that you have requested. Useful to disable if you have far too many.",
default=True,
)

last_seen = models.DateTimeField(
help_text="Last time user was seen at all",
Expand Down
1 change: 1 addition & 0 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class UserProfileUpdateView(
"dynamic_progress",
"use_twemoji",
"show_portal_instructions",
"show_unit_petitions",
)
success_url = reverse_lazy("profile")
object: UserProfile
Expand Down
69 changes: 36 additions & 33 deletions roster/templates/roster/inquiry.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "layout.html" %}
{% load static %}
{% load otis_extras %}
{% block css %}
<style type="text/css">
a.chosen-single {
Expand Down Expand Up @@ -35,43 +36,45 @@
</p>
<h2>New petition</h2>
{% include "generic_form.html" with submit_name="Send" %}
<h2>Current petitions</h2>
<table class="table">
<thead class="thead-dark">
<tr>
<th>Created</th>
<th>Unit</th>
<th>Action</th>
<th>Status</th>
</tr>
</thead>
<tbody>
{% for inquiry in inquiries %}
{% if request.user|getconfig:"show_unit_petitions" %}
<h2>Current petitions</h2>
<table class="table">
<thead class="thead-dark">
<tr>
<td>{{ inquiry.created_at|date:"SHORT_DATE_FORMAT" }}</td>
<th>{{ inquiry.unit }}</th>
<td>{{ inquiry.get_action_type_display }}</td>
<td>
{% if inquiry.status == "INQ_NEW" %}
Pending
{% elif inquiry.status == "INQ_ACC" %}
<strong class="text-success">Accepted</strong>
{% elif inquiry.status == "INQ_REJ" %}
<strong class="text-danger">Rejected</strong>
{% elif inquiry.status == "INQ_HOLD" %}
<strong class="text-warning">On hold</strong>
{% endif %}
</td>
<th>Created</th>
<th>Unit</th>
<th>Action</th>
<th>Status</th>
</tr>
{% if inquiry.explanation %}
</thead>
<tbody>
{% for inquiry in inquiries %}
<tr>
<td></td>
<td colspan="3" class="fst-italic">{{ inquiry.explanation }}</td>
<td>{{ inquiry.created_at|date:"SHORT_DATE_FORMAT" }}</td>
<th>{{ inquiry.unit }}</th>
<td>{{ inquiry.get_action_type_display }}</td>
<td>
{% if inquiry.status == "INQ_NEW" %}
Pending
{% elif inquiry.status == "INQ_ACC" %}
<strong class="text-success">Accepted</strong>
{% elif inquiry.status == "INQ_REJ" %}
<strong class="text-danger">Rejected</strong>
{% elif inquiry.status == "INQ_HOLD" %}
<strong class="text-warning">On hold</strong>
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% if inquiry.explanation %}
<tr>
<td></td>
<td colspan="3" class="fst-italic">{{ inquiry.explanation }}</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
{% endif %}
<h2>Current units</h2>
<p>For your reference, here is the existing curriculum.</p>
{% include "dashboard/curriculum_list.html" %}
Expand Down

0 comments on commit 96011b3

Please sign in to comment.