parent
7e1bf17c86
commit
8680c99324
|
@ -140,8 +140,13 @@ class LiaisonForm(forms.ModelForm):
|
|||
return ', '.join(['%s <%s>' % i.email() for i in persons])
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
now = datetime.datetime.now()
|
||||
liaison = super(LiaisonForm, self).save(*args, **kwargs)
|
||||
self.save_extra_fields(liaison)
|
||||
self.save_attachments(liaison)
|
||||
return liaison
|
||||
|
||||
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()
|
||||
|
@ -152,8 +157,6 @@ class LiaisonForm(forms.ModelForm):
|
|||
liaison.submitter_name, liaison.submitter_email = self.person.email()
|
||||
liaison.cc1 = self.get_cc(from_entity, organization)
|
||||
liaison.save()
|
||||
self.save_attachments(liaison)
|
||||
return liaison
|
||||
|
||||
def save_attachments(self, instance):
|
||||
for key in self.files.keys():
|
||||
|
@ -225,8 +228,8 @@ class OutgoingLiaisonForm(LiaisonForm):
|
|||
def get_poc(self, organization):
|
||||
return self.cleaned_data['to_poc']
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
liaison = super(OutgoingLiaisonForm, self).save(*args, **kwargs)
|
||||
def save_extra_fields(self, liaison):
|
||||
super(OutgoingLiaisonForm, self).save_extra_fields(liaison)
|
||||
from_entity = self.get_from_entity()
|
||||
needs_approval = from_entity.needs_approval(self.person)
|
||||
if not needs_approval or self.cleaned_data.get('approved', False):
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.db import models
|
||||
from ietf.idtracker.models import Acronym,PersonOrOrgInfo
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.db import models
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from ietf.idtracker.models import Acronym,PersonOrOrgInfo
|
||||
from ietf.liaisons.mail import IETFEmailMessage
|
||||
|
||||
class LiaisonPurpose(models.Model):
|
||||
purpose_id = models.AutoField(primary_key=True)
|
||||
|
@ -110,6 +114,30 @@ class LiaisonDetail(models.Model):
|
|||
class Meta:
|
||||
db_table = 'liaison_detail'
|
||||
|
||||
def send_by_email(self, fake=False):
|
||||
subject = 'New Liaison Statement, "%s"' % (self.title)
|
||||
from_email = settings.LIAISON_UNIVERSAL_FROM
|
||||
to_email = self.to_poc.split(',')
|
||||
cc = self.cc1.split(',')
|
||||
if self.technical_contact:
|
||||
cc += self.technical_contact.split(',')
|
||||
if self.response_contact:
|
||||
cc += self.response_contact.split(',')
|
||||
bcc = ['statements@ietf.org']
|
||||
body = render_to_string('liaisons/liaison_mail.txt',
|
||||
{'liaison': self,
|
||||
})
|
||||
mail = IETFEmailMessage(subject=subject,
|
||||
to=to_email,
|
||||
from_email=from_email,
|
||||
cc = cc,
|
||||
bcc = bcc,
|
||||
body = body)
|
||||
if not fake:
|
||||
mail.send()
|
||||
return mail
|
||||
|
||||
|
||||
class SDOs(models.Model):
|
||||
sdo_id = models.AutoField(primary_key=True)
|
||||
sdo_name = models.CharField(blank=True, max_length=255)
|
||||
|
|
|
@ -11,7 +11,7 @@ info_dict = {
|
|||
# there's an opportunity for date-based filtering.
|
||||
urlpatterns = patterns('django.views.generic.list_detail',
|
||||
url(r'^$', 'object_list', info_dict, name='liaison_list'),
|
||||
(r'^(?P<object_id>\d+)/$', 'object_detail', info_dict),
|
||||
url(r'^(?P<object_id>\d+)/$', 'object_detail', info_dict, name='liaison_detail'),
|
||||
)
|
||||
|
||||
urlpatterns += patterns('django.views.generic.simple',
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
from django.shortcuts import render_to_response
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.utils import simplejson
|
||||
|
||||
|
@ -18,7 +19,16 @@ def add_liaison(request):
|
|||
form = liaison_form_factory(request, data=request.POST.copy(),
|
||||
files = request.FILES)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
liaison = form.save()
|
||||
if not settings.DEBUG:
|
||||
liaison.send_by_mail()
|
||||
else:
|
||||
mail = liaison.send_by_email(fake=True)
|
||||
return render_to_response('liaisons/liaison_mail_detail.html',
|
||||
{'mail': mail,
|
||||
'message': mail.message(),
|
||||
'liaison': liaison},
|
||||
context_instance=RequestContext(request))
|
||||
return HttpResponseRedirect(reverse('liaison_list'))
|
||||
else:
|
||||
form = liaison_form_factory(request)
|
||||
|
|
17
ietf/templates/liaisons/liaison_mail.txt
Normal file
17
ietf/templates/liaisons/liaison_mail.txt
Normal file
|
@ -0,0 +1,17 @@
|
|||
Title: {{ liaison.title }}
|
||||
Submission Date: {{ liaison.submitted_date }}
|
||||
URL of the IETF Web page: {% url liaison_detail object_id=liaison.pk %}
|
||||
{% if liaison.deadline_date %}Please reply by {{ liaison.deadline_date }}{% endif %}
|
||||
From: {{ liaison.from_body }} ({{ liaison.person }} <{{ liaison.replyto|default:liaison.from_email|fix_ampersands }}>)
|
||||
To: {{ liaison.to_body }} ({{ liaison.to_poc }})
|
||||
Cc: {{ liaison.cc1 }}
|
||||
Reponse Contact: {{ liaison.response_contact }}
|
||||
Technical Contact: {{ liaison.technical_contact }}
|
||||
Purpose: {% if liaison.purpose_text %}{{ liaison.purpose_text }}{% else %}{{ liaison.purpose.purpose_text }}{% endif %}
|
||||
Body: {{ liaison.body }}
|
||||
Attachment(s):
|
||||
{% for file in liaison.uploads_set.all %}
|
||||
{{ file.file_title }} https://datatracker.ietf.org/documents/LIAISON/file{{ file.file_id }}{{ file.file_extension }}
|
||||
{% empty %}
|
||||
No document has been attached
|
||||
{% endfor %}
|
35
ietf/templates/liaisons/liaison_mail_detail.html
Normal file
35
ietf/templates/liaisons/liaison_mail_detail.html
Normal file
|
@ -0,0 +1,35 @@
|
|||
{% extends "base.html" %}
|
||||
{# Copyright The IETF Trust 2007, All Rights Reserved #}
|
||||
{% load ietf_filters %}
|
||||
{% block title %}{{ liaison.title }}{% endblock %}
|
||||
|
||||
{% block pagehead %}
|
||||
{{ form.media }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Simulated Mail for Liaison Statement</h1>
|
||||
|
||||
<p>
|
||||
Demo version of this tool does NOT actually send the liaison statement to the recipients.
|
||||
</p>
|
||||
<p>
|
||||
Rather, the actual email body (including mail header) is displayed below.
|
||||
</p>
|
||||
<p>
|
||||
In production mode, you will not see this screen.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
From: {{ message.From }}
|
||||
To: {{ message.To }}
|
||||
Cc: {{ message.Cc }}
|
||||
Bcc: {{ message.Bcc }}
|
||||
Subject: {{ message.Subject }}
|
||||
|
||||
{{ mail.body }}
|
||||
</pre>
|
||||
|
||||
<a href="{% url liaison_list %}">Return to liaison list</a>
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue