Skip to content

Commit ee52775

Browse files
committed
Allow to enter the submission date when sending (or editing) liaisons. Fixes ietf-tools#653
- Legacy-Id: 3067
1 parent 471d395 commit ee52775

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

ietf/liaisons/forms.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class LiaisonForm(forms.ModelForm):
2626
cc1 = forms.CharField(widget=forms.Textarea, label="CC", required=False, help_text='Please insert one email address per line')
2727
purpose_text = forms.CharField(widget=forms.Textarea, label='Other purpose')
2828
deadline_date = forms.DateField(label='Deadline')
29+
submitted_date = forms.DateField(label='Submission date', initial=datetime.date.today())
2930
title = forms.CharField(label=u'Title')
3031
attachments = forms.CharField(label='Attachments', widget=ShowAttachmentsWidget, required=False)
3132
attach_title = forms.CharField(label='Title', required=False)
@@ -42,7 +43,7 @@ class LiaisonForm(forms.ModelForm):
4243
('Other email addresses', ('response_contact', 'technical_contact', 'cc1')),
4344
('Purpose', ('purpose', 'purpose_text', 'deadline_date')),
4445
('References', ('related_to', )),
45-
('Liaison Statement', ('title', 'body', 'attachments')),
46+
('Liaison Statement', ('title', 'submitted_date', 'body', 'attachments')),
4647
('Add attachment', ('attach_title', 'attach_file', 'attach_button')),
4748
]
4849

@@ -205,7 +206,6 @@ def save(self, *args, **kwargs):
205206

206207
def save_extra_fields(self, liaison):
207208
now = datetime.datetime.now()
208-
liaison.submitted_date = now
209209
liaison.last_modified_date = now
210210
from_entity = self.get_from_entity()
211211
liaison.from_raw_body = from_entity.name
@@ -393,6 +393,7 @@ def __init__(self, *args, **kwargs):
393393
super(EditLiaisonForm, self).__init__(*args, **kwargs)
394394
self.edit = True
395395
self.initial.update({'attachments': self.instance.uploads_set.all()})
396+
self.fields['submitted_date'].initial = self.instance.submitted_date
396397

397398
def set_from_field(self):
398399
self.fields['from_field'].initial = self.instance.from_body

static/js/liaisons.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
var purpose = form.find('#id_purpose');
136136
var other_purpose = form.find('#id_purpose_text');
137137
var deadline = form.find('#id_deadline_date');
138+
var submission_date = form.find('#id_submitted_date');
138139
var other_organization = form.find('#id_other_organization');
139140
var approval = form.find('#id_approved');
140141
var cancel = form.find('#id_cancel');
@@ -350,6 +351,17 @@
350351
updateInfo(first_time);
351352
};
352353

354+
var checkSubmissionDate = function() {
355+
var date_str = submission_date.val();
356+
if (date_str) {
357+
var sdate = new Date(date_str);
358+
var today = new Date();
359+
if (Math.abs(today-sdate) > 2592000000) { // 2592000000 = 30 days in milliseconds
360+
return confirm('Submission date ' + date_str + ' differ more than 30 days.\n\nDo you want to continue and post this liaison using that submission date?\n');
361+
}
362+
}
363+
};
364+
353365
var initTriggers = function() {
354366
organization.change(function() {updateInfo(false);});
355367
organization.change(checkOtherSDO);
@@ -359,6 +371,7 @@
359371
cancel.click(cancelForm);
360372
related_trigger.click(selectRelated);
361373
unrelate_trigger.click(selectNoRelated);
374+
form.submit(checkSubmissionDate);
362375
};
363376

364377
var updateOnInit = function() {
@@ -373,6 +386,10 @@
373386
dateFormat: $.datepicker.ATOM,
374387
changeYear: true
375388
});
389+
submission_date.datepicker({
390+
dateFormat: $.datepicker.ATOM,
391+
changeYear: true
392+
});
376393
};
377394

378395
var initAttachments = function() {

0 commit comments

Comments
 (0)