Skip to content

Commit

Permalink
Fixed errors with the edit state link, the new ability to set an init…
Browse files Browse the repository at this point in the history
…ial state when adding a document, the status date on the edit state form, and brought several tests up to date.

Fixes bug 695, bug 696, bug 697, and bug 698.
 - Legacy-Id: 3272
  • Loading branch information
rjsparks committed Jul 31, 2011
1 parent 47e8f76 commit 0389ebf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
12 changes: 2 additions & 10 deletions ietf/idrfc/tests.py
Expand Up @@ -258,10 +258,10 @@ def test_add_draft(self):

r = self.client.post(url,
dict(intended_status=str(draft.intended_status_id),
status_date=str(date.today() + timedelta(2)),
area_acronym=str(area.area_acronym_id),
via_rfc_editor="1",
job_owner=job_owner.id,
create_in_state=IDState.PUBLICATION_REQUESTED,
state_change_notice_to="test@example.com",
note="This is a note",
telechat_date="",
Expand Down Expand Up @@ -441,7 +441,7 @@ def test_edit_position_as_secretary(self):
comments_before = draft.idinternal.comments().count()
self.assertTrue(not Position.objects.filter(ballot=draft.idinternal.ballot, ad__login_name="rhousley"))

r = self.client.post(url, dict(position="discuss"))
r = self.client.post(url, dict(position="discuss",discuss_text="A non-empty discuss"))
self.assertEquals(r.status_code, 302)

pos = Position.objects.get(ballot=draft.idinternal.ballot, ad__login_name="rhousley")
Expand Down Expand Up @@ -648,14 +648,6 @@ def test_edit_approval_text(self):
self.assertEquals(len(q('textarea[name=approval_text]')), 1)
self.assertEquals(len(q('input[type=submit][value*="Save Approval"]')), 1)

# subject error
r = self.client.post(url, dict(
last_call_text="Subject: test\r\nhello\r\n\r\n",
save_last_call_text="1"))
self.assertEquals(r.status_code, 200)
q = PyQuery(r.content)
self.assertTrue(len(q('ul.errorlist')) > 0)

# save
r = self.client.post(url, dict(
approval_text="This is a simple test.",
Expand Down
19 changes: 5 additions & 14 deletions ietf/idrfc/views_edit.py
Expand Up @@ -84,11 +84,10 @@ def dehtmlify_textarea_text(s):

class EditInfoForm(forms.Form):
intended_status = forms.ModelChoiceField(IDIntendedStatus.objects.all(), empty_label=None, required=True)
status_date = forms.DateField(required=False, help_text="Format is YYYY-MM-DD")
area_acronym = forms.ModelChoiceField(Area.active_areas(), required=True, empty_label='None Selected')
via_rfc_editor = forms.BooleanField(required=False, label="Via IRTF or RFC Editor")
job_owner = forms.ModelChoiceField(IESGLogin.objects.filter(user_level__in=(IESGLogin.AD_LEVEL, IESGLogin.INACTIVE_AD_LEVEL)).order_by('user_level', 'last_name'), label="Responsible AD", empty_label=None, required=True)
create_in_state = forms.ModelChoiceField(IDState.objects.filter(document_state_id__in=(IDState.PUBLICATION_REQUESTED, IDState.AD_WATCHING)), empty_label=None, required=True)
create_in_state = forms.ModelChoiceField(IDState.objects.filter(document_state_id__in=(IDState.PUBLICATION_REQUESTED, IDState.AD_WATCHING)), empty_label=None, required=False)
state_change_notice_to = forms.CharField(max_length=255, label="Notice emails", help_text="Separate email addresses with commas", required=False)
note = forms.CharField(widget=forms.Textarea, label="IESG note", required=False)
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False)
Expand Down Expand Up @@ -136,16 +135,6 @@ def __init__(self, *args, **kwargs):
# returning item is rendered non-standard
self.standard_fields = [x for x in self.visible_fields() if x.name not in ('returning_item',)]

def clean_status_date(self):
d = self.cleaned_data['status_date']
if d:
if d < date.today():
raise forms.ValidationError("Date must not be in the past.")
if d >= date.today() + timedelta(days=365 * 2):
raise forms.ValidationError("Date must be within two years.")

return d

def clean_note(self):
# note is stored munged in the database
return self.cleaned_data['note'].replace('\n', '<br>').replace('\r', '').replace(' ', '&nbsp; ')
Expand Down Expand Up @@ -209,6 +198,7 @@ def edit_info(request, name):
old_ads=False,
initial=dict(telechat_date=initial_telechat_date,
area_acronym=doc.idinternal.area_acronym_id))

if form.is_valid():
changes = []
r = form.cleaned_data
Expand Down Expand Up @@ -239,7 +229,6 @@ def diff(obj, attr, name):
setattr(obj, attr, r[attr])

diff(doc, 'intended_status', "Intended Status")
diff(doc.idinternal, 'status_date', "Status Date")
if 'area_acronym' in r and r['area_acronym']:
diff(doc.idinternal, 'area_acronym', 'Area acronym')
diff(doc.idinternal, 'job_owner', 'Responsible AD')
Expand Down Expand Up @@ -273,6 +262,7 @@ def diff(obj, attr, name):
doc.idinternal.token_email = doc.idinternal.job_owner.person.email()[1]
doc.idinternal.mark_by = login
doc.idinternal.event_date = date.today()
doc.idinternal.status_date = date.today()

if changes and not new_document:
email_owner(request, doc, orig_job_owner, login, "\n".join(changes))
Expand All @@ -284,7 +274,6 @@ def diff(obj, attr, name):
return HttpResponseRedirect(doc.idinternal.get_absolute_url())
else:
init = dict(intended_status=doc.intended_status_id,
status_date=doc.idinternal.status_date,
area_acronym=doc.idinternal.area_acronym_id,
job_owner=doc.idinternal.job_owner_id,
state_change_notice_to=doc.idinternal.state_change_notice_to,
Expand All @@ -298,6 +287,8 @@ def diff(obj, attr, name):
if not in_group(request.user, 'Secretariat'):
form.standard_fields = [x for x in form.standard_fields if x.name != "via_rfc_editor"]

if not new_document:
form.standard_fields = [x for x in form.standard_fields if x.name != "create_in_state"]

return render_to_response('idrfc/edit_info.html',
dict(doc=doc,
Expand Down
2 changes: 1 addition & 1 deletion ietf/templates/idrfc/doc_tab_document_id.html
Expand Up @@ -91,7 +91,7 @@


<tr><td><a href="/idtracker/help/state/">IESG State</>:</td><td>
{% if user|in_group:"Area_Director,Secretariat" %}
{% if doc.in_ietf_process and user|in_group:"Area_Director,Secretariat" %}
<a href="{% url doc_change_state name=doc.draft_name %}"> {{ doc.friendly_state|safe }} </a>
{% else %}
{{ doc.friendly_state|safe }}
Expand Down

0 comments on commit 0389ebf

Please sign in to comment.