Skip to content

Commit

Permalink
Allow Secretariat to submit drafts during blackout period. Fixes #1755.…
Browse files Browse the repository at this point in the history
… Commit ready for merge.

 - Legacy-Id: 9821
  • Loading branch information
rpcross committed Jul 20, 2015
1 parent 39fd739 commit 007d7d2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ietf/submit/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

import debug # pyflakes:ignore

from ietf.group.models import Group
from ietf.doc.models import Document
from ietf.group.models import Group
from ietf.ietfauth.utils import has_role
from ietf.meeting.models import Meeting
from ietf.submit.models import Submission, Preapproval
from ietf.submit.utils import validate_submission_rev, validate_submission_document_date
Expand All @@ -32,6 +33,7 @@ def __init__(self, request, *args, **kwargs):

self.remote_ip = request.META.get('REMOTE_ADDR', None)

self.request = request
self.in_first_cut_off = False
self.cutoff_warning = ""
self.shutdown = False
Expand Down Expand Up @@ -104,7 +106,7 @@ def clean_xml(self):
return self.clean_file("xml", XMLParser)

def clean(self):
if self.shutdown:
if self.shutdown and not has_role(self.request.user, "Secretariat"):
raise forms.ValidationError('The tool is shut down')

# sanity check that paths exist (for development servers)
Expand Down
24 changes: 24 additions & 0 deletions ietf/submit/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ietf.utils.test_data import make_test_data
from ietf.utils.mail import outbox
from ietf.utils.test_utils import TestCase
from ietf.meeting.models import Meeting
from ietf.submit.utils import expirable_submissions, expire_submission, ensure_person_email_info_exists
from ietf.person.models import Person
from ietf.group.models import Group
Expand Down Expand Up @@ -608,6 +609,29 @@ def test_help_pages(self):
r = self.client.get(urlreverse("submit_tool_instructions"))
self.assertEquals(r.status_code, 200)

def test_blackout_access(self):
make_test_data()

# get
url = urlreverse('submit_upload_submission')
# set meeting to today so we're in blackout period
meeting = Meeting.get_current_meeting()
meeting.date = datetime.datetime.today()
meeting.save()

# regular user, no access
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('input[type=file][name=txt]')), 0)

# Secretariat has access
self.client.login(username="secretary", password="secretary+password")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('input[type=file][name=txt]')), 1)

class ApprovalsTestCase(TestCase):
def test_approvals(self):
make_test_data()
Expand Down
8 changes: 6 additions & 2 deletions ietf/templates/submit/upload_submission.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "submit/submit_base.html" %}
{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}

{% load ietf_filters %}
{% load bootstrap3 %}

{% block title %}Upload{% endblock %}
Expand All @@ -10,6 +10,10 @@
{% origin %}
{% bootstrap_messages %}

{% if form.shutdown and user|has_role:"Secretariat" %}
<p class="bg-warning">WARNING: currently in draft submission blackout period</p>
{% endif %}

{% if form.cutoff_warning %}
<div class="cutoff-warning">
{{ form.cutoff_warning|safe }}
Expand All @@ -28,7 +32,7 @@
six months. They may be updated, replaced, or obsoleted by other
documents at any time.</p>

{% if not form.shutdown %}
{% if not form.shutdown or user|has_role:"Secretariat" %}
<p>If you run into problems when submitting an Internet-Draft
using this and the following pages, you may alternatively submit
your draft by email to
Expand Down

0 comments on commit 007d7d2

Please sign in to comment.