feat: mark bofreqs as spam (#7869)
This commit is contained in:
parent
715edafcdc
commit
1f6db0fef1
30
ietf/doc/migrations/0023_bofreqspamstate.py
Normal file
30
ietf/doc/migrations/0023_bofreqspamstate.py
Normal file
|
@ -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)]
|
|
@ -54,8 +54,8 @@ This test section has some text.
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
q = PyQuery(r.content)
|
q = PyQuery(r.content)
|
||||||
for state in states:
|
for state in states:
|
||||||
self.assertEqual(len(q(f'#bofreqs-{state.slug}')), 1)
|
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)
|
self.assertEqual(len(q(f'#bofreqs-{state.slug} tbody tr')), 3 if state.slug!="spam" else 0)
|
||||||
self.assertFalse(q('#start_button'))
|
self.assertFalse(q('#start_button'))
|
||||||
PersonFactory(user__username='nobody')
|
PersonFactory(user__username='nobody')
|
||||||
self.client.login(username='nobody', password='nobody+password')
|
self.client.login(username='nobody', password='nobody+password')
|
||||||
|
@ -63,6 +63,13 @@ This test section has some text.
|
||||||
self.assertEqual(r.status_code, 200)
|
self.assertEqual(r.status_code, 200)
|
||||||
q = PyQuery(r.content)
|
q = PyQuery(r.content)
|
||||||
self.assertTrue(q('#start_button'))
|
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):
|
def test_bofreq_main_page(self):
|
||||||
|
|
|
@ -2617,6 +2617,19 @@
|
||||||
"model": "doc.state",
|
"model": "doc.state",
|
||||||
"pk": 180
|
"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": {
|
"fields": {
|
||||||
"label": "State"
|
"label": "State"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{# Copyright The IETF Trust 2021 All Rights Reserved #}
|
{# Copyright The IETF Trust 2021 All Rights Reserved #}
|
||||||
{% load origin %}
|
{% load origin %}
|
||||||
{% load person_filters %}
|
{% load person_filters ietf_filters %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% block pagehead %}
|
{% block pagehead %}
|
||||||
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
|
<link rel="stylesheet" href="{% static "ietf/css/list.css" %}">
|
||||||
|
@ -26,40 +26,42 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{% regroup reqs by get_state_slug as grouped_reqs %}
|
{% regroup reqs by get_state_slug as grouped_reqs %}
|
||||||
{% for req_group in grouped_reqs %}
|
{% for req_group in grouped_reqs %}
|
||||||
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
|
{% if req_group.grouper != "spam" or request.user|has_role:"Secretariat" %}
|
||||||
<table id="bofreqs-{{ req_group.grouper }}"
|
<h2 class="mt-5">{{ req_group.grouper|capfirst }} BOF Requests</h2>
|
||||||
class="table table-sm table-striped tablesorter">
|
<table id="bofreqs-{{ req_group.grouper }}"
|
||||||
<thead>
|
class="table table-sm table-striped tablesorter">
|
||||||
<tr>
|
<thead>
|
||||||
<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 %}
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<th scope="col" data-sort="name">Name</th>
|
||||||
<a href="{% url 'ietf.doc.views_doc.document_main' name=req.name %}">{{ req.name }}-{{ req.rev }}</a>
|
<th scope="col" class="d-none d-sm-table-cell" data-sort="date">Date</th>
|
||||||
</td>
|
<th scope="col" data-sort="title">Title</th>
|
||||||
<td class="d-none d-sm-table-cell">{{ req.latest_revision_event.time|date:"Y-m-d" }}</td>
|
<th scope="col" data-sort="responsible">Responsible</th>
|
||||||
<td>{{ req.title }}</td>
|
<th scope="col" data-sort="editors">Editors</th>
|
||||||
<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>
|
</tr>
|
||||||
{% endfor %}
|
</thead>
|
||||||
</tbody>
|
<tbody>
|
||||||
</table>
|
{% 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 %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue