~mailmanweb-django/mailmanweb/systers_django

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
# Copyright (C) 1998-2010 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.

from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.utils.translation import ugettext as _ # needed here?
from systers_django.models import MailingList
from forms import ListNewForm



def systers_create_list(request):
    """Create a Systers list."""
    if request.method == 'POST':
        form = ListNewForm(request.POST)
        if form.is_valid():
            new_list = form.save(commit=False)
            new_list._mm_listname = form.cleaned_data['listname']
            new_list.save()
            new_list.set_list_owner(form.cleaned_data['list_owner'])
            new_list.set_list_type(form.cleaned_data['list_type'])
            new_list.set_languages(form.cleaned_data['languages'])
            return HttpResponseRedirect(new_list.get_absolute_url())
    else:
        form = ListNewForm()
    return render_to_response('systers_django/lists/new.html', {'form': form})

########################################
def list_index(request):
    """Showing all created Systers lists."""
    lists = MailingList.objects.all()
    return render_to_response('systers_django/lists/index.html', 
                              {'lists': lists})