Refactor slightly to make views_doc.py independent of other idrfc code
- Legacy-Id: 5294
This commit is contained in:
parent
3e8de2a43f
commit
1a3aa3b443
|
@ -220,10 +220,16 @@ def add_state_change_event(doc, by, prev_state, new_state, timestamp=None):
|
|||
e.save()
|
||||
return e
|
||||
|
||||
|
||||
def prettify_std_name(n):
|
||||
if re.match(r"(rfc|bcp|fyi|std)[0-9]{4}", n):
|
||||
return n[:3].upper() + " " + n[3:]
|
||||
else:
|
||||
return n
|
||||
|
||||
def nice_consensus(consensus):
|
||||
mapping = {
|
||||
None: "Unknown",
|
||||
True: "Yes",
|
||||
False: "No"
|
||||
}
|
||||
return mapping[consensus]
|
||||
|
|
|
@ -177,19 +177,3 @@ def update_telechatREDESIGN(request, doc, by, new_telechat_date, new_returning_i
|
|||
if settings.USE_DB_REDESIGN_PROXY_CLASSES:
|
||||
update_telechat = update_telechatREDESIGN
|
||||
|
||||
def can_edit_intended_std_level(user, doc):
|
||||
return user.is_authenticated() and (
|
||||
has_role(user, ["Secretariat", "Area Director"]) or is_authorized_in_doc_stream(user, doc))
|
||||
|
||||
def can_edit_consensus(user, doc):
|
||||
return user.is_authenticated() and (
|
||||
has_role(user, ["Secretariat", "Area Director"]) or is_authorized_in_doc_stream(user, doc))
|
||||
|
||||
def nice_consensus(consensus):
|
||||
mapping = {
|
||||
None: "Unknown",
|
||||
True: "Yes",
|
||||
False: "No"
|
||||
}
|
||||
return mapping[consensus]
|
||||
|
||||
|
|
|
@ -43,7 +43,6 @@ from django.middleware.gzip import GZipMiddleware
|
|||
from django.core.urlresolvers import reverse as urlreverse, NoReverseMatch
|
||||
from django.conf import settings
|
||||
|
||||
from ietf.idrfc.utils import *
|
||||
from ietf.doc.models import *
|
||||
from ietf.doc.utils import *
|
||||
from ietf.utils.history import find_history_active_at
|
||||
|
@ -140,10 +139,11 @@ def document_main(request, name, rev=None):
|
|||
|
||||
can_edit = has_role(request.user, ("Area Director", "Secretariat"))
|
||||
stream_slugs = StreamName.objects.values_list("slug", flat=True)
|
||||
can_change_stream = bool(can_edit or (request.user.is_authenticated() and
|
||||
Role.objects.filter(name__in=("chair", "auth"),
|
||||
group__acronym__in=stream_slugs,
|
||||
person__user=request.user)))
|
||||
can_change_stream = bool(can_edit or (
|
||||
request.user.is_authenticated() and
|
||||
Role.objects.filter(name__in=("chair", "auth"),
|
||||
group__acronym__in=stream_slugs,
|
||||
person__user=request.user)))
|
||||
can_edit_iana_state = has_role(request.user, ("Secretariat", "IANA"))
|
||||
|
||||
rfc_number = name[3:] if name.startswith("") else None
|
||||
|
@ -313,8 +313,6 @@ def document_main(request, name, rev=None):
|
|||
can_change_stream=can_change_stream,
|
||||
can_edit_stream_info=can_edit_stream_info,
|
||||
can_edit_shepherd_writeup=can_edit_shepherd_writeup,
|
||||
can_edit_intended_std_level=can_edit_intended_std_level(request.user, doc),
|
||||
can_edit_consensus=can_edit_consensus(request.user, doc),
|
||||
can_edit_iana_state=can_edit_iana_state,
|
||||
|
||||
rfc_number=rfc_number,
|
||||
|
@ -644,7 +642,7 @@ def get_ballot(name):
|
|||
from ietf.doc.models import DocAlias
|
||||
alias = get_object_or_404(DocAlias, name=name)
|
||||
d = alias.document
|
||||
from ietf.idtracker.models import InternetDraft
|
||||
from ietf.idtracker.models import InternetDraft, BallotInfo
|
||||
from ietf.idrfc.idrfc_wrapper import BallotWrapper, IdWrapper, RfcWrapper
|
||||
id = None
|
||||
bw = None
|
||||
|
|
|
@ -271,7 +271,8 @@ def change_intention(request, name):
|
|||
if doc.type_id != 'draft':
|
||||
raise Http404
|
||||
|
||||
if not can_edit_intended_std_level(request.user, doc):
|
||||
if not (has_role(request.user, ("Secretariat", "Area Director"))
|
||||
or is_authorized_in_doc_stream(request.user, doc)):
|
||||
return HttpResponseForbidden("You do not have the necessary permissions to view this page")
|
||||
|
||||
login = request.user.get_profile()
|
||||
|
@ -902,7 +903,8 @@ def edit_consensus(request, name):
|
|||
|
||||
doc = get_object_or_404(Document, type="draft", name=name)
|
||||
|
||||
if not can_edit_consensus(request.user, doc):
|
||||
if not (has_role(request.user, ("Secretariat", "Area Director"))
|
||||
or is_authorized_in_doc_stream(request.user, doc)):
|
||||
return HttpResponseForbidden("You do not have the necessary permissions to view this page")
|
||||
|
||||
e = doc.latest_event(ConsensusDocEvent, type="changed_consensus")
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
<tr>
|
||||
<td>Intended RFC status:</td>
|
||||
<td>
|
||||
<a {% if can_edit %}class="editlink" href="{% url doc_change_intended_status name=doc.name %}"{% endif %}>
|
||||
<a {% if can_edit or can_edit_stream_info %}class="editlink" href="{% url doc_change_intended_status name=doc.name %}"{% endif %}>
|
||||
{{ doc.intended_std_level|default:"Unknown" }}</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -110,7 +110,7 @@
|
|||
<tr>
|
||||
<td>Consensus:</td>
|
||||
<td>
|
||||
<a title="Whether the document is the result of a community consensus process as defined in RFC 5741" {% if can_edit_consensus %}class="editlink" href="{% url doc_edit_consensus name=doc.name %}"{% endif %}>
|
||||
<a title="Whether the document is the result of a community consensus process as defined in RFC 5741" {% if can_edit or can_edit_stream_info %}class="editlink" href="{% url doc_edit_consensus name=doc.name %}"{% endif %}>
|
||||
{{ consensus }}
|
||||
</a>
|
||||
</td>
|
||||
|
|
Loading…
Reference in a new issue