def METHOD_NAME(request):
    """Undo a DocEvent."""
    events = []
    events.extend(StateDocEvent.objects.filter(
        state_type="draft-rfceditor",
        time__gte=timezone.now() - datetime.timedelta(weeks=1)
    ).order_by("-time", "-id"))
    events.extend(DocEvent.objects.filter(
        type="sync_from_rfc_editor",
        time__gte=timezone.now() - datetime.timedelta(weeks=1)
    ).order_by("-time", "-id"))
    events.sort(key=lambda e: (e.time, e.id), reverse=True)
    if request.method == "POST":
        try:
            eid = int(request.POST.get("event", ""))
        except ValueError:
            return HttpResponse("Could not parse event id")
        for e in events:
            if e.id == eid:
                break
        else:
            return HttpResponse("Event does not exist")
        doc = e.doc
        # possibly reset the state of the document
        all_events = StateDocEvent.objects.filter(doc=doc, state_type="draft-rfceditor").order_by("-time", "-id")
        if all_events and all_events[0] == e:
            if len(all_events) > 1:
                doc.set_state(all_events[1].state)
            else:
                doc.unset_state("draft-rfceditor")
        dump = DeletedEvent()
        dump.content_type = ContentType.objects.get_for_model(type(e))
        dump.json = json.dumps(object_as_shallow_dict(e), indent=2)
        dump.by = request.user.person
        dump.save()
        e.delete()
        return HttpResponseRedirect("")
    return render(request, 'sync/rfceditor_undo.html', dict(events=events))