Allow to enter the submission date when sending (or editing) liaisons. Fixes #653
- Legacy-Id: 3067
This commit is contained in:
parent
471d3952da
commit
ee52775458
|
@ -26,6 +26,7 @@ class LiaisonForm(forms.ModelForm):
|
|||
cc1 = forms.CharField(widget=forms.Textarea, label="CC", required=False, help_text='Please insert one email address per line')
|
||||
purpose_text = forms.CharField(widget=forms.Textarea, label='Other purpose')
|
||||
deadline_date = forms.DateField(label='Deadline')
|
||||
submitted_date = forms.DateField(label='Submission date', initial=datetime.date.today())
|
||||
title = forms.CharField(label=u'Title')
|
||||
attachments = forms.CharField(label='Attachments', widget=ShowAttachmentsWidget, required=False)
|
||||
attach_title = forms.CharField(label='Title', required=False)
|
||||
|
@ -42,7 +43,7 @@ class LiaisonForm(forms.ModelForm):
|
|||
('Other email addresses', ('response_contact', 'technical_contact', 'cc1')),
|
||||
('Purpose', ('purpose', 'purpose_text', 'deadline_date')),
|
||||
('References', ('related_to', )),
|
||||
('Liaison Statement', ('title', 'body', 'attachments')),
|
||||
('Liaison Statement', ('title', 'submitted_date', 'body', 'attachments')),
|
||||
('Add attachment', ('attach_title', 'attach_file', 'attach_button')),
|
||||
]
|
||||
|
||||
|
@ -205,7 +206,6 @@ class LiaisonForm(forms.ModelForm):
|
|||
|
||||
def save_extra_fields(self, liaison):
|
||||
now = datetime.datetime.now()
|
||||
liaison.submitted_date = now
|
||||
liaison.last_modified_date = now
|
||||
from_entity = self.get_from_entity()
|
||||
liaison.from_raw_body = from_entity.name
|
||||
|
@ -393,6 +393,7 @@ class EditLiaisonForm(LiaisonForm):
|
|||
super(EditLiaisonForm, self).__init__(*args, **kwargs)
|
||||
self.edit = True
|
||||
self.initial.update({'attachments': self.instance.uploads_set.all()})
|
||||
self.fields['submitted_date'].initial = self.instance.submitted_date
|
||||
|
||||
def set_from_field(self):
|
||||
self.fields['from_field'].initial = self.instance.from_body
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
var purpose = form.find('#id_purpose');
|
||||
var other_purpose = form.find('#id_purpose_text');
|
||||
var deadline = form.find('#id_deadline_date');
|
||||
var submission_date = form.find('#id_submitted_date');
|
||||
var other_organization = form.find('#id_other_organization');
|
||||
var approval = form.find('#id_approved');
|
||||
var cancel = form.find('#id_cancel');
|
||||
|
@ -350,6 +351,17 @@
|
|||
updateInfo(first_time);
|
||||
};
|
||||
|
||||
var checkSubmissionDate = function() {
|
||||
var date_str = submission_date.val();
|
||||
if (date_str) {
|
||||
var sdate = new Date(date_str);
|
||||
var today = new Date();
|
||||
if (Math.abs(today-sdate) > 2592000000) { // 2592000000 = 30 days in milliseconds
|
||||
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');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var initTriggers = function() {
|
||||
organization.change(function() {updateInfo(false);});
|
||||
organization.change(checkOtherSDO);
|
||||
|
@ -359,6 +371,7 @@
|
|||
cancel.click(cancelForm);
|
||||
related_trigger.click(selectRelated);
|
||||
unrelate_trigger.click(selectNoRelated);
|
||||
form.submit(checkSubmissionDate);
|
||||
};
|
||||
|
||||
var updateOnInit = function() {
|
||||
|
@ -373,6 +386,10 @@
|
|||
dateFormat: $.datepicker.ATOM,
|
||||
changeYear: true
|
||||
});
|
||||
submission_date.datepicker({
|
||||
dateFormat: $.datepicker.ATOM,
|
||||
changeYear: true
|
||||
});
|
||||
};
|
||||
|
||||
var initAttachments = function() {
|
||||
|
|
Loading…
Reference in a new issue