changes to announcements: default reply_to=ietf@ietf.org, widen body field, add back button

- Legacy-Id: 5889
This commit is contained in:
Ryan Cross 2013-07-27 10:16:23 +00:00
parent 1c60bb6b00
commit 5855140136
3 changed files with 72 additions and 51 deletions

View file

@ -13,7 +13,7 @@ from ietf.wgchairs.accounts import get_person_for_user
# Globals
# ---------------------------------------------
#ANNOUNCE_FROM_GROUPS = ['ietf','rsoc','iab',current_nomcom().acronym]
ANNOUNCE_FROM_GROUPS = ['ietf','rsoc','iab',current_nomcom().acronym]
ANNOUNCE_TO_GROUPS= ['ietf']
# this list isn't currently available as a Role query so it's hardcoded
@ -34,7 +34,7 @@ FROM_LIST = ('IETF Secretariat <ietf-secretariat@ietf.org>',
'ISOC Board of Trustees <eburger@standardstrack.com>',
'RFC Series Editor <rse@rfc-editor.org>',
'IAB Executive Director <execd@iab.org>')
TO_LIST = ('IETF Announcement List <ietf-announce@ietf.org>',
'I-D Announcement List <i-d-announce@ietf.org>',
'The IESG <iesg@ietf.org>',
@ -52,14 +52,14 @@ class MultiEmailField(forms.Field):
# Return an empty list if no input was given.
if not value:
return []
import types
if isinstance(value, types.StringTypes):
values = value.split(',')
return [ x.strip() for x in values ]
else:
return value
def validate(self, value):
"Check if value consists only of valid emails."
@ -68,7 +68,7 @@ class MultiEmailField(forms.Field):
for email in value:
validate_email(email)
# ---------------------------------------------
# Helper Functions
# ---------------------------------------------
@ -88,13 +88,7 @@ def get_from_choices(user):
f = (FROM_LIST[6],)
elif has_role(user,'IAD'):
f = (FROM_LIST[9],)
# NomCom, RSOC Chair, IAOC Chair aren't supported by has_role()
elif Role.objects.filter(name="chair",
group__acronym__startswith="nomcom",
group__state="active",
group__type="ietf",
person=person):
f = (FROM_LIST[7],)
#RSOC Chair, IAOC Chair aren't supported by has_role()
elif Role.objects.filter(person=person,
group__acronym='rsoc',
name="chair"):
@ -111,17 +105,29 @@ def get_from_choices(user):
group__acronym='iab',
name='execdir'):
f = (FROM_LIST[6],FROM_LIST[16])
# NomCom
nomcoms = Role.objects.filter(name="chair",
group__acronym__startswith="nomcom",
group__state="active",
group__type="ietf",
person=person)
if nomcoms:
year = nomcoms[0].group.acronym[-4:]
alias = 'NomCom Chair %s <nomcom-chair-%s@ietf.org>' % (year,year)
f = (alias,)
return zip(f,f)
def get_to_choices():
#groups = Group.objects.filter(acronym__in=ANNOUNCE_TO_GROUPS)
#roles = Role.objects.filter(group__in=(groups),name="Announce")
#choices = [ (r.email, r.person.name) for r in roles ]
#choices.append(('Other...','Other...'),)
return zip(TO_LIST,TO_LIST)
# ---------------------------------------------
# Select Choices
# Select Choices
# ---------------------------------------------
#TO_CHOICES = tuple(AnnouncedTo.objects.values_list('announced_to_id','announced_to'))
TO_CHOICES = get_to_choices()
@ -132,24 +138,33 @@ TO_CHOICES = get_to_choices()
# ---------------------------------------------
class AnnounceForm(forms.ModelForm):
nomcom = forms.BooleanField(required=False)
#nomcom = forms.BooleanField(required=False)
nomcom = forms.ModelChoiceField(queryset=Group.objects.filter(acronym__startswith='nomcom',type='ietf',state='active'),required=False)
to_custom = MultiEmailField(required=False,label='')
#cc = MultiEmailField(required=False)
class Meta:
model = Message
fields = ('nomcom', 'to','to_custom','frm','cc','bcc','reply_to','subject','body')
def __init__(self, *args, **kwargs):
user = kwargs.pop('user')
person = user.get_profile()
super(AnnounceForm, self).__init__(*args, **kwargs)
self.fields['to'].widget = forms.Select(choices=TO_CHOICES)
self.fields['to'].help_text = 'Select name OR select Other... and enter email below'
self.fields['cc'].help_text = 'Use comma separated lists for emails (Cc, Bcc, Reply To)'
self.fields['frm'].widget = forms.Select(choices=get_from_choices(user))
self.fields['frm'].label = 'From'
self.fields['nomcom'].label = 'NomCom message?'
self.fields['nomcom'].label = 'NomCom message:'
nomcom_roles = person.role_set.filter(group__in=self.fields['nomcom'].queryset,name='chair')
secr_roles = person.role_set.filter(group__acronym='secretariat',name='secr')
if nomcom_roles:
self.initial['nomcom'] = nomcom_roles[0].group.pk
if not nomcom_roles and not secr_roles:
self.fields['nomcom'].widget = forms.HiddenInput()
self.initial['reply_to'] = 'ietf@ietf.org'
def clean(self):
super(AnnounceForm, self).clean()
data = self.cleaned_data
@ -157,9 +172,9 @@ class AnnounceForm(forms.ModelForm):
return self.cleaned_data
if data['to'] == 'Other...' and not data['to_custom']:
raise forms.ValidationError('You must enter a "To" email address')
return data
def save(self, *args, **kwargs):
user = kwargs.pop('user')
message = super(AnnounceForm, self).save(commit=False)
@ -168,10 +183,10 @@ class AnnounceForm(forms.ModelForm):
message.to = self.cleaned_data['to_custom']
if kwargs['commit']:
message.save()
# add nomcom to related groups if checked
if self.cleaned_data.get('nomcom', False):
nomcom = current_nomcom()
# handle nomcom message
nomcom = self.cleaned_data.get('nomcom',False)
if nomcom:
message.related_groups.add(nomcom)
return message

View file

@ -6,7 +6,7 @@
<script type="text/javascript" src="{{ SECR_STATIC_URL }}js/utils.js"></script>
{% endblock %}
{% block breadcrumbs %}{{ block.super }}
{% block breadcrumbs %}{{ block.super }}
&raquo; Announcement
{% endblock %}
@ -14,9 +14,9 @@
<div class="module">
<h2>Announcement</h2>
<form action="" method="POST">
<pre id="announce-confirm">
To: {{ to }}
From: {{ message.frm }}
@ -27,10 +27,11 @@ Subject: {{ message.subject }}
{{ message.body }}
</pre>
<div class="button-group">
<ul id="announcement-button-list">
<li><button type="submit" name="submit" value="Send">Send</button></li>
<li><button onclick="history.go(-1);return false">Back</button></li>
<li><button type="submit" name="submit" value="Cancel">Cancel</button></li>
</ul>
</div> <!-- button-group -->

View file

@ -12,7 +12,7 @@
}
#footer {
/* background-color: #DDDDDD;
/* background-color: #DDDDDD;
background-color: #EEEEFF; */
color: #888888;
margin-top: 8px;
@ -69,7 +69,7 @@
border-bottom: none;
}
.internal-form {
.internal-form {
padding: 1em;
}
@ -91,7 +91,7 @@
color: Blue;
text-decoration: underline;
}
.unlocked {
float: right;
}
@ -178,7 +178,7 @@ table.center {
background: none;
}
.button-group {
.button-group {
clear: both;
width: auto;
height: 2.5em;
@ -203,7 +203,7 @@ table.center {
}
button.fancy:hover {
background-color: #ffc;
background-color: #ffc;
}
/* Navigation Bar
@ -256,13 +256,13 @@ ul#list-nav a.current {
/* ==========================================================================
Announcement Tool
========================================================================== */
#announce-table input[type="text"] {
width: 40em;
width: 52em;
}
#announce-table #id_body {
width: 40em;
width: 52em;
}
#announce-table td {
@ -276,6 +276,11 @@ ul#list-nav a.current {
#announce-confirm {
color: black;
font-family: "Courier New",Courier,monospace;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
/* ==========================================================================
@ -302,7 +307,7 @@ ul#list-nav a.current {
/* ==========================================================================
Draft Tool
========================================================================== */
input.draft-file-input {
width: 40em;
}
@ -411,7 +416,7 @@ input.draft-file-input {
/* ==========================================================================
Group Tool
========================================================================== */
.awp-form input {
width: 30em;
}
@ -540,11 +545,11 @@ div.interim-scroll {
}
#proceedings-add-table th {
width: 25%;
width: 25%;
}
#proceedings-edit-table th {
width: 25%;
width: 25%;
}
#proceedings-upload-table th {
@ -558,14 +563,14 @@ div.interim-scroll {
#proceedings-left-col {
float: left;
width: 378px;
width: 378px;
margin: 0;
border-right: 1px solid #CCCCCC;
}
#proceedings-right-col {
float: left;
width: 377px;
width: 377px;
margin: 0;
border-right: 1px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
@ -611,7 +616,7 @@ tr.bg2 {
/*
table#sessions-new-table td {
padding: 2px;
border-spacing: 2px;
border-spacing: 2px;
border: 1;
}
@ -644,7 +649,7 @@ ul.session-buttons {
width: 294px;
background: url("../img/admin/default-bg.gif") repeat-x scroll left top #7CA0C7;
color: white;
min-height: 500px;
min-height: 500px;
padding: 0 0 0 6px;
}
@ -689,7 +694,7 @@ ul.doc-list li {
text-align: center;
}
/*
/*
#telechat-sidebar ol {
list-style-position: outside;
counter-reset: item;
@ -719,7 +724,7 @@ ul.doc-list li {
float: right;
}
.telechat-warn h3 {
.telechat-warn h3 {
color: white;
text-align: center;
background-color: #FF66FF;
@ -747,7 +752,7 @@ ul.doc-list li {
/* ==========================================================================
Redesign Section
========================================================================== */
table.amstable {
background-color: #F2F2E6;
}
@ -776,7 +781,7 @@ table.amsview td {
padding: 4px 10px 4px 4px;
}
.button-group {
.button-group {
background: #F2F2E6;
}