Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions ietf/doc/migrations/0023_bofreqspamstate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright The IETF Trust 2024, All Rights Reserved

from django.db import migrations


def forward(apps, schema_editor):
State = apps.get_model("doc", "State")
State.objects.get_or_create(
type_id="bofreq",
slug="spam",
defaults={"name": "Spam", "desc": "The BOF request is spam", "order": 5},
)


def reverse(apps, schema_editor):
State = apps.get_model("doc", "State")
Document = apps.get_model("doc", "Document")
assert not Document.objects.filter(
states__type="bofreq", states__slug="spam"
).exists()
State.objects.filter(type_id="bofreq", slug="spam").delete()


class Migration(migrations.Migration):

dependencies = [
("doc", "0022_remove_dochistory_internal_comments_and_more"),
]

operations = [migrations.RunPython(forward, reverse)]
11 changes: 9 additions & 2 deletions ietf/doc/tests_bofreq.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,22 @@ def test_show_bof_requests(self):
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
for state in states:
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1)
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3)
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1 if state.slug!="spam" else 0)
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3 if state.slug!="spam" else 0)
self.assertFalse(q('#start_button'))
PersonFactory(user__username='nobody')
self.client.login(username='nobody', password='nobody+password')
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertTrue(q('#start_button'))
self.client.logout()
self.client.login(username='secretary', password='secretary+password')
r = self.client.get(url)
q = PyQuery(r.content)
for state in states:
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1)
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3)


def test_bofreq_main_page(self):
Expand Down
13 changes: 13 additions & 0 deletions ietf/name/fixtures/names.json
Original file line number Diff line number Diff line change
Expand Up @@ -2617,6 +2617,19 @@
"model": "doc.state",
"pk": 180
},
{
"fields": {
"desc": "The BOF request is spam",
"name": "Spam",
"next_states": [],
"order": 5,
"slug": "spam",
"type": "bofreq",
"used": true
},
"model": "doc.state",
"pk": 182
},
{
"fields": {
"label": "State"
Expand Down
68 changes: 35 additions & 33 deletions ietf/templates/doc/bofreq/bof_requests.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{# Copyright The IETF Trust 2021 All Rights Reserved #}
{% load origin %}
{% load person_filters %}
{% load person_filters ietf_filters %}
{% load static %}
{% block pagehead %}
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
Expand All @@ -26,40 +26,42 @@ <h1>BOF Requests</h1>
{% else %}
{% regroup reqs by get_state_slug as grouped_reqs %}
{% for req_group in grouped_reqs %}
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
<table id="bofreqs-{{ req_group.grouper }}"
class="table table-sm table-striped tablesorter">
<thead>
<tr>
<th scope="col" data-sort="name">Name</th>
<th scope="col" class="d-none d-sm-table-cell" data-sort="date">Date</th>
<th scope="col" data-sort="title">Title</th>
<th scope="col" data-sort="responsible">Responsible</th>
<th scope="col" data-sort="editors">Editors</th>
</tr>
</thead>
<tbody>
{% for req in req_group.list %}
{% if req_group.grouper != "spam" or request.user|has_role:"Secretariat" %}
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
<table id="bofreqs-{{ req_group.grouper }}"
class="table table-sm table-striped tablesorter">
<thead>
<tr>
<td>
<a href="{% url 'ietf.doc.views_doc.document_main' name=req.name %}">{{ req.name }}-{{ req.rev }}</a>
</td>
<td class="d-none d-sm-table-cell">{{ req.latest_revision_event.time|date:"Y-m-d" }}</td>
<td>{{ req.title }}</td>
<td>
{% for person in req.responsible %}
{% person_link person %}{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
<td>
{% for person in req.editors %}
{% person_link person %}{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
<th scope="col" data-sort="name">Name</th>
<th scope="col" class="d-none d-sm-table-cell" data-sort="date">Date</th>
<th scope="col" data-sort="title">Title</th>
<th scope="col" data-sort="responsible">Responsible</th>
<th scope="col" data-sort="editors">Editors</th>
</tr>
{% endfor %}
</tbody>
</table>
</thead>
<tbody>
{% for req in req_group.list %}
<tr>
<td>
<a href="{% url 'ietf.doc.views_doc.document_main' name=req.name %}">{{ req.name }}-{{ req.rev }}</a>
</td>
<td class="d-none d-sm-table-cell">{{ req.latest_revision_event.time|date:"Y-m-d" }}</td>
<td>{{ req.title }}</td>
<td>
{% for person in req.responsible %}
{% person_link person %}{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
<td>
{% for person in req.editors %}
{% person_link person %}{% if not forloop.last %},{% endif %}
{% endfor %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
Expand Down