Skip to content

Commit 793856c

Browse files
committed
Add RFC Editor undo page, missing test and dump model
- Legacy-Id: 5013
1 parent 63fb1cb commit 793856c

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

ietf/sync/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
urlpatterns = patterns('',
44
url(r'^discrepancies/$', 'ietf.sync.views.discrepancies'),
55
url(r'^(?P<org>\w+)/notify/(?P<notification>\w+)/$', 'ietf.sync.views.notify'),
6+
url(r'^rfceditor/undo/', 'ietf.sync.views.rfceditor_undo')
67
)
78

ietf/sync/views.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import subprocess, os
22

3-
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseServerError
3+
from django.http import HttpResponse, HttpResponseForbidden, HttpResponseServerError, HttpResponseRedirect
44
from django.shortcuts import render_to_response
55
from django.template import RequestContext
66
from django.template.loader import render_to_string
@@ -100,3 +100,33 @@ def runscript(name):
100100
help_text=known_notifications[notification],
101101
),
102102
context_instance=RequestContext(request))
103+
104+
def rfceditor_undo(request):
105+
"""Undo a DocEvent."""
106+
107+
if not request.user.is_authenticated() or not has_role(request.user, ("Secretariat", "RFC Editor")):
108+
return HttpResponseForbidden("You do not have the necessary permissions to view this page")
109+
110+
events = StateDocEvent.objects.filter(state_type="draft-rfceditor",
111+
time__gte=datetime.datetime.now() - datetime.timedelta(weeks=1)
112+
).order_by("-time", "-id")
113+
114+
if request.method == "POST":
115+
try:
116+
eid = int(request.POST.get("event", ""))
117+
except ValueError:
118+
return HttpResponse("Could not parse event id")
119+
120+
try:
121+
e = events.get(id=eid)
122+
except StateDocEvent.DoesNotExist:
123+
return HttpResponse("Event does not exist")
124+
125+
e.delete()
126+
127+
return HttpResponseRedirect(urlreverse("ietf.sync.views.rfceditor_undo"))
128+
129+
return render_to_response('sync/rfceditor_undo.html',
130+
dict(events=events,
131+
),
132+
context_instance=RequestContext(request))
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{% extends "base.html" %}
2+
3+
{% block title %}Undo RFC Editor state events{% endblock %}
4+
5+
{% block content %}
6+
<h1>Undo RFC Editor state events</h1>
7+
8+
<table class="ietf-table">
9+
<tr>
10+
<th>Time</th>
11+
<th>Document</th>
12+
<th>Text</th>
13+
<th>Undo</th>
14+
</tr>
15+
{% for e in events %}
16+
<tr class="{% if forloop.counter|divisibleby:2 %}evenrow{% else %}oddrow{% endif %}">
17+
<td>{{ e.time|date:"Y-m-d H:i:s"}}</td>
18+
<td><a href="{% url doc_history e.doc_id %}">{{ e.doc_id }}</a></td>
19+
<td>{{ e.desc|safe }}</td>
20+
<td>
21+
<form method="post">
22+
<input type="hidden" name="event" value="{{ e.id }}"/>
23+
<input type="submit" value="Remove"/>
24+
</form>
25+
</td>
26+
</tr>
27+
{% endfor %}
28+
</table>
29+
{% endblock %}

0 commit comments

Comments
 (0)