Convert the Cc: field into an editable textarea. Fixes #647
- Legacy-Id: 3029
This commit is contained in:
parent
400fe65726
commit
199e469f87
|
@ -23,7 +23,7 @@ class LiaisonForm(forms.ModelForm):
|
|||
replyto = forms.CharField(label=u'Reply to')
|
||||
organization = forms.ChoiceField()
|
||||
to_poc = forms.CharField(widget=ReadOnlyWidget, label="POC", required=False)
|
||||
cc1 = forms.CharField(widget=ReadOnlyWidget, label="CC", required=False)
|
||||
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')
|
||||
title = forms.CharField(label=u'Title')
|
||||
|
@ -171,10 +171,30 @@ class LiaisonForm(forms.ModelForm):
|
|||
def get_poc(self, organization):
|
||||
return ', '.join([i.email()[1] for i in organization.get_poc()])
|
||||
|
||||
def clean_cc1(self):
|
||||
value = self.cleaned_data.get('cc1', '')
|
||||
result = []
|
||||
errors = []
|
||||
for address in value.split('\n'):
|
||||
address = address.strip();
|
||||
if not address:
|
||||
continue
|
||||
try:
|
||||
self.check_email(address)
|
||||
except forms.ValidationError:
|
||||
errors.append(address)
|
||||
result.append(address)
|
||||
if errors:
|
||||
raise forms.ValidationError('Invalid email addresses: %s' % ', '.join(errors))
|
||||
return ','.join(result)
|
||||
|
||||
def get_cc(self, from_entity, to_entity):
|
||||
persons = to_entity.get_cc(self.person)
|
||||
persons += from_entity.get_from_cc(self.person)
|
||||
return ', '.join(['%s <%s>' % i.email() for i in persons])
|
||||
#Old automatic Cc code, now we retrive it from cleaned_data
|
||||
#persons = to_entity.get_cc(self.person)
|
||||
#persons += from_entity.get_from_cc(self.person)
|
||||
#return ', '.join(['%s <%s>' % i.email() for i in persons])
|
||||
cc = self.cleaned_data.get('cc1', '')
|
||||
return cc
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
liaison = super(LiaisonForm, self).save(*args, **kwargs)
|
||||
|
|
|
@ -150,11 +150,15 @@
|
|||
config.info_update_url = confcontainer.find('.info_update_url').text();
|
||||
};
|
||||
|
||||
var render_mails_into = function(container, person_list) {
|
||||
var render_mails_into = function(container, person_list, as_html) {
|
||||
var html='';
|
||||
|
||||
$.each(person_list, function(index, person) {
|
||||
html += person[0] + ' <<a href="mailto:'+person[1]+'">'+person[1]+'</a>><br />';
|
||||
if (as_html) {
|
||||
html += person[0] + ' <<a href="mailto:'+person[1]+'">'+person[1]+'</a>><br />';
|
||||
} else {
|
||||
html += person[0] + ' <'+person[1]+'>\n';
|
||||
}
|
||||
});
|
||||
container.html(html);
|
||||
};
|
||||
|
@ -204,7 +208,7 @@
|
|||
updateReplyTo();
|
||||
};
|
||||
|
||||
var updateInfo = function() {
|
||||
var updateInfo = function(first_time) {
|
||||
var entity = organization;
|
||||
var to_entity = from;
|
||||
var url = config.info_update_url;
|
||||
|
@ -218,8 +222,10 @@
|
|||
from_entity_id: to_entity.val()},
|
||||
success: function(response){
|
||||
if (!response.error) {
|
||||
render_mails_into(cc, response.cc);
|
||||
render_mails_into(poc, response.poc);
|
||||
if (!first_time || !cc.text()) {
|
||||
render_mails_into(cc, response.cc, false);
|
||||
}
|
||||
render_mails_into(poc, response.poc, true);
|
||||
toggleApproval(response.needs_approval);
|
||||
checkPostOnly(response.post_only);
|
||||
userSelect(response.full_list);
|
||||
|
@ -317,10 +323,10 @@
|
|||
return false;
|
||||
};
|
||||
|
||||
var checkFrom = function() {
|
||||
var checkFrom = function(first_time) {
|
||||
var reduce_options = form.find('.reducedToOptions');
|
||||
if (!reduce_options.length) {
|
||||
updateInfo();
|
||||
updateInfo(first_time);
|
||||
return;
|
||||
}
|
||||
var to_select = organization;
|
||||
|
@ -341,13 +347,13 @@
|
|||
to_select.find('optgroup').show();
|
||||
to_select.find('option').show();
|
||||
}
|
||||
updateInfo();
|
||||
updateInfo(first_time);
|
||||
};
|
||||
|
||||
var initTriggers = function() {
|
||||
organization.change(updateInfo);
|
||||
organization.change(function() {updateInfo(false);});
|
||||
organization.change(checkOtherSDO);
|
||||
from.change(checkFrom);
|
||||
from.change(function() {checkFrom(false);});
|
||||
reply.keyup(updateFrom);
|
||||
purpose.change(updatePurpose);
|
||||
cancel.click(cancelForm);
|
||||
|
@ -357,7 +363,7 @@
|
|||
|
||||
var updateOnInit = function() {
|
||||
updateFrom();
|
||||
checkFrom();
|
||||
checkFrom(true);
|
||||
updatePurpose();
|
||||
checkOtherSDO();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue