Finish non-wg wizard logic: update database, send email.

Still need several templates (most notably deletion preview and
wizard_done)
 - Legacy-Id: 166
This commit is contained in:
Bill Fenner 2007-05-24 21:05:51 +00:00
parent ec09ffa870
commit 95a5093e53
6 changed files with 85 additions and 4 deletions

View file

@ -1,5 +1,6 @@
from django.db import models
from ietf.idtracker.models import Acronym, Areas, PersonOrOrgInfo
import random
class ImportedMailingList(models.Model):
group_acronym = models.ForeignKey(Acronym, null=True)
@ -70,6 +71,16 @@ class MailingList(models.Model):
domain_name = models.CharField(blank=True, maxlength=10)
def __str__(self):
return self.mlist_name
def save(self, *args, **kwargs):
if self.mailing_list_id is None:
generate = True
while generate:
self.mailing_list_id = ''.join([random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for i in range(35)])
try:
MailingList.objects.get(pk=self.mailing_list_id)
except MailingList.DoesNotExist:
generate = False
super(MailingList, self).save(*args, **kwargs)
class Meta:
db_table = 'mailing_list'
class Admin:
@ -94,6 +105,16 @@ class NonWgMailingList(models.Model):
msg_to_ad = models.TextField(blank=True)
def __str__(self):
return self.list_name
def save(self, *args, **kwargs):
if self.id is None:
generate = True
while generate:
self.id = ''.join([random.choice('0123456789abcdefghijklmnopqrstuvwxyz') for i in range(35)])
try:
NonWgMailingList.objects.get(pk=self.id)
except NonWgMailingList.DoesNotExist:
generate = False
super(NonWgMailingList, self).save(*args, **kwargs)
def choices():
return [(list.id, list.list_name) for list in NonWgMailingList.objects.all().filter(status__gt=0)]
choices = staticmethod(choices)

View file

@ -11,5 +11,4 @@ urlpatterns = patterns('django.views.generic.list_detail',
urlpatterns += patterns('',
(r'^nonwg_lists/submit/$', views.non_wg_wizard),
(r'^request/$', views.list_req_wizard),
(r'^nonwg_lists/s2/$', views.non_wg_submit),
)

View file

@ -5,7 +5,7 @@ from django import newforms as forms
from django.shortcuts import render_to_response
from django.template import RequestContext
from ietf.contrib import wizard, form_decorator
from ietf.utils.mail import send_mail
from ietf.utils.mail import send_mail_subj
def formchoice(form, field):
if not(form.is_valid()):
@ -107,15 +107,26 @@ class NonWgWizard(wizard.Wizard):
super(NonWgWizard, self).process_step(request, form, step)
def done(self, request, form_list):
add_edit = self.clean_forms[0].clean_data['add_edit']
# save row to database properly
list = None
old = None
if add_edit == 'add' or add_edit == 'edit':
template = 'mailinglists/nwg_addedit_email.txt'
approver = self.clean_forms[2].clean_data['approver']
list = NonWgMailingList(**self.clean_forms[1].clean_data)
list.__dict__.update(self.clean_forms[2].clean_data)
list.id = None # create a new row no matter what
list.status = 0
if add_edit == 'edit':
old = NonWgMailingList.objects.get(pk=self.clean_forms[0].clean_data['list_id'])
else:
template = 'mailinglists/nwg_delete_email.txt'
approver = self.clean_forms[1].clean_data['approver']
list = NonWgMailingList.objects.get(pk=self.clean_forms[0].clean_data['list_id_delete'])
list.__dict__.update(self.clean_forms[1].clean_data)
list.status = 1
list.save()
approver_email = PersonOrOrgInfo.objects.get(pk=approver).email()
send_mail(request, [ approver_email ], None, 'Request to %s on the Non-WG Mailing List Web Page' % add_edit, template, {'forms': self.clean_forms})
send_mail_subj(request, [ approver_email ], None, 'mailinglists/nwg_wizard_subject.txt', 'mailinglists/nwg_wizard_done_email.txt', {'add_edit': add_edit, 'old': old, 'list': list, 'forms': self.clean_forms})
return render_to_response( 'mailinglists/nwg_wizard_done.html', {'forms': self.clean_forms}, context_instance=RequestContext(request) )
def non_wg_wizard(request):

View file

@ -0,0 +1,5 @@
{% extends "mailinglists/nwg_wizard_base.html" %}
{% block nwgcontent %}
Your mail has been sent, blah blah blah.
{% endblock %}

View file

@ -0,0 +1,36 @@
The Secretariat has received a request to {% ifequal add_edit "edit" %}edit an existing entry on{% else %}{% ifequal add_edit "add" %}add a new entry to{% else %}delete an existing entry from{% endifequal %}{% endifequal %}
the "IETF Non-WG Mailing Lists" Web Page, https://datatracker.ietf.org/public/nwg_list.cgi
The details of the request are provided below.
Please approve or deny this request via the "IETF Non-WG Mailing List Approval Page,"
https://datatracker.ietf.org/cgi-bin/nwg_list_approve.cgi?id={{ list.id }}&old_id={% firstof old.id "0" %}
You can use the same user name and password that you use with the I-D Tracker.
-------------------------
{% if old %}
Current Entry:
Submitter's Name: {{ old.s_name }}
Submitter's Email Address: {{ old.s_email }}
List Name: {{ old.list_name }}
URL or Email Address of Mailing List: {{ old.list_url }}
URL to Subscribe: {{ old.subscribe_url }}
Other Info. to Subscribe: {{ old.subscribe_other }}
Administrator(s)' Email Address(es): {{ old.admin }}
Purpose: {{ old.purpose }}
Area: {{ old.area }}
Revised Entry:
{% endif %}
Submitter's Name: {% ifequal add_edit "delete" %}{{ list.ds_name }}{% else %}{{ list.s_name }}{% endifequal %}
Submitter's Email Address: {% ifequal add_edit "delete" %}{{ list.ds_name }}{% else %}{{ list.s_email }}{% endifequal %}
Mailing List Name: {{ list.list_name }}
URL or Email Address of Mailing List: {{ list.list_url }}
URL to Subscribe: {{ list.subscribe_url }}
Other Info. to Subscribe: {{ list.subscribe_other }}
Administrator(s)' Email Address(es): {{ list.admin }}
Purpose: {{ list.purpose }}
Area: {{ list.area }}
{% ifequal add_edit "delete" %}
Message from submitter:
{{ list.msg_to_ad }}
{% endifequal %}

View file

@ -0,0 +1,9 @@
{% ifequal add_edit "edit" %}
Request to Edit an Existing Entry on the Non-WG Mailing List Web Page
{% else %}
{% ifequal add_edit "add" %}
Request to Add a New Entry to the Non-WG Mailing List Web Page
{% else %}
Request to Delete an Existing Entry on the Non-WG Mailing List Web Page
{% endifequal %}
{% endifequal %}