Skip to content

Commit 1f6db0f

Browse files
authored
feat: mark bofreqs as spam (ietf-tools#7869)
1 parent 715edaf commit 1f6db0f

4 files changed

Lines changed: 87 additions & 35 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright The IETF Trust 2024, All Rights Reserved
2+
3+
from django.db import migrations
4+
5+
6+
def forward(apps, schema_editor):
7+
State = apps.get_model("doc", "State")
8+
State.objects.get_or_create(
9+
type_id="bofreq",
10+
slug="spam",
11+
defaults={"name": "Spam", "desc": "The BOF request is spam", "order": 5},
12+
)
13+
14+
15+
def reverse(apps, schema_editor):
16+
State = apps.get_model("doc", "State")
17+
Document = apps.get_model("doc", "Document")
18+
assert not Document.objects.filter(
19+
states__type="bofreq", states__slug="spam"
20+
).exists()
21+
State.objects.filter(type_id="bofreq", slug="spam").delete()
22+
23+
24+
class Migration(migrations.Migration):
25+
26+
dependencies = [
27+
("doc", "0022_remove_dochistory_internal_comments_and_more"),
28+
]
29+
30+
operations = [migrations.RunPython(forward, reverse)]

ietf/doc/tests_bofreq.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,22 @@ def test_show_bof_requests(self):
5454
self.assertEqual(r.status_code, 200)
5555
q = PyQuery(r.content)
5656
for state in states:
57-
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1)
58-
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3)
57+
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1 if state.slug!="spam" else 0)
58+
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3 if state.slug!="spam" else 0)
5959
self.assertFalse(q('#start_button'))
6060
PersonFactory(user__username='nobody')
6161
self.client.login(username='nobody', password='nobody+password')
6262
r = self.client.get(url)
6363
self.assertEqual(r.status_code, 200)
6464
q = PyQuery(r.content)
6565
self.assertTrue(q('#start_button'))
66+
self.client.logout()
67+
self.client.login(username='secretary', password='secretary+password')
68+
r = self.client.get(url)
69+
q = PyQuery(r.content)
70+
for state in states:
71+
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1)
72+
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3)
6673

6774

6875
def test_bofreq_main_page(self):

ietf/name/fixtures/names.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2617,6 +2617,19 @@
26172617
"model": "doc.state",
26182618
"pk": 180
26192619
},
2620+
{
2621+
"fields": {
2622+
"desc": "The BOF request is spam",
2623+
"name": "Spam",
2624+
"next_states": [],
2625+
"order": 5,
2626+
"slug": "spam",
2627+
"type": "bofreq",
2628+
"used": true
2629+
},
2630+
"model": "doc.state",
2631+
"pk": 182
2632+
},
26202633
{
26212634
"fields": {
26222635
"label": "State"

ietf/templates/doc/bofreq/bof_requests.html

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% extends "base.html" %}
22
{# Copyright The IETF Trust 2021 All Rights Reserved #}
33
{% load origin %}
4-
{% load person_filters %}
4+
{% load person_filters ietf_filters %}
55
{% load static %}
66
{% block pagehead %}
77
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
@@ -26,40 +26,42 @@ <h1>BOF Requests</h1>
2626
{% else %}
2727
{% regroup reqs by get_state_slug as grouped_reqs %}
2828
{% for req_group in grouped_reqs %}
29-
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
30-
<table id="bofreqs-{{ req_group.grouper }}"
31-
class="table table-sm table-striped tablesorter">
32-
<thead>
33-
<tr>
34-
<th scope="col" data-sort="name">Name</th>
35-
<th scope="col" class="d-none d-sm-table-cell" data-sort="date">Date</th>
36-
<th scope="col" data-sort="title">Title</th>
37-
<th scope="col" data-sort="responsible">Responsible</th>
38-
<th scope="col" data-sort="editors">Editors</th>
39-
</tr>
40-
</thead>
41-
<tbody>
42-
{% for req in req_group.list %}
29+
{% if req_group.grouper != "spam" or request.user|has_role:"Secretariat" %}
30+
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
31+
<table id="bofreqs-{{ req_group.grouper }}"
32+
class="table table-sm table-striped tablesorter">
33+
<thead>
4334
<tr>
44-
<td>
45-
<a href="{% url 'ietf.doc.views_doc.document_main' name=req.name %}">{{ req.name }}-{{ req.rev }}</a>
46-
</td>
47-
<td class="d-none d-sm-table-cell">{{ req.latest_revision_event.time|date:"Y-m-d" }}</td>
48-
<td>{{ req.title }}</td>
49-
<td>
50-
{% for person in req.responsible %}
51-
{% person_link person %}{% if not forloop.last %},{% endif %}
52-
{% endfor %}
53-
</td>
54-
<td>
55-
{% for person in req.editors %}
56-
{% person_link person %}{% if not forloop.last %},{% endif %}
57-
{% endfor %}
58-
</td>
35+
<th scope="col" data-sort="name">Name</th>
36+
<th scope="col" class="d-none d-sm-table-cell" data-sort="date">Date</th>
37+
<th scope="col" data-sort="title">Title</th>
38+
<th scope="col" data-sort="responsible">Responsible</th>
39+
<th scope="col" data-sort="editors">Editors</th>
5940
</tr>
60-
{% endfor %}
61-
</tbody>
62-
</table>
41+
</thead>
42+
<tbody>
43+
{% for req in req_group.list %}
44+
<tr>
45+
<td>
46+
<a href="{% url 'ietf.doc.views_doc.document_main' name=req.name %}">{{ req.name }}-{{ req.rev }}</a>
47+
</td>
48+
<td class="d-none d-sm-table-cell">{{ req.latest_revision_event.time|date:"Y-m-d" }}</td>
49+
<td>{{ req.title }}</td>
50+
<td>
51+
{% for person in req.responsible %}
52+
{% person_link person %}{% if not forloop.last %},{% endif %}
53+
{% endfor %}
54+
</td>
55+
<td>
56+
{% for person in req.editors %}
57+
{% person_link person %}{% if not forloop.last %},{% endif %}
58+
{% endfor %}
59+
</td>
60+
</tr>
61+
{% endfor %}
62+
</tbody>
63+
</table>
64+
{% endif %}
6365
{% endfor %}
6466
{% endif %}
6567
{% endblock %}

0 commit comments

Comments
 (0)