~mailmanweb-django/+junk/dev

« back to all changes in this revision

Viewing changes to views.py

  • Committer: Anna Granudd
  • Date: 2010-07-24 17:04:05 UTC
  • Revision ID: anna@athena-20100724170405-8xiqqv502ozeqzq6
Changed function names and calls in the view to make it work with the new rest-client.

Added the possibility to use fieldsets and divs in forms, by using as_div in the form.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
            parts = listname.split('@')
25
25
            try:
26
 
                r = c.read_domain(parts[1])
27
 
            except MailmanRESTClientError, e:
 
26
                domain = c.get_domain(parts[1])
 
27
            except ValueError, e:
28
28
                try:
29
29
                    c.create_domain(parts[1])
30
 
                except MailmanRESTClientError, e:
 
30
                except MailmanRESTClientError, e: 
 
31
                    # I don't think this error can ever appear but I couldn't 
 
32
                    # trigger the one that might appear -- Anna
31
33
                    return HttpResponse(e)
32
 
 
33
34
            try:
34
 
                response = c.create_list(fqdn_listname=listname)
 
35
                response = domain.create_list(parts[0])
35
36
                return HttpResponseRedirect(reverse('list_index'))
36
37
            except MailmanRESTClientError, e:
37
38
                return HttpResponse(e)
65
66
    """
66
67
    try:
67
68
        c = MailmanRESTClient('localhost:8001')
 
69
        the_list = c.get_list(fqdn_listname)
68
70
    except Exception, e:
69
71
        return HttpResponse(e)
70
72
    if request.method == 'POST':
80
82
            if action == "subscribe":
81
83
                real_name = form.cleaned_data.get('real_name', '')
82
84
                try:
83
 
                    response = c.subscribe_list(fqdn_listname=listname,
84
 
                                                address=email,
 
85
                    response = the_list.subscribe(address=email,
85
86
                                                real_name=real_name)
86
87
                    return HttpResponseRedirect(reverse('list_index'))
87
88
                except Exception, e:
88
89
                    return HttpResponse(e)
89
90
            elif action == "unsubscribe":
90
91
                try:
91
 
                    response = c.leave_list(fqdn_listname=listname, 
92
 
                                            address=email) # doesn't throw error when not subscribed...
 
92
                    response = the_list.unsubscribe(address=email)
93
93
                    return render_to_response('mailman-django/lists/unsubscribed.html', 
94
94
                                              {'listname': fqdn_listname})
95
95
                except Exception, e:
109
109
        unsubscribe = ListUnsubscribe(initial = {'listname': fqdn_listname, 
110
110
                                                 'name' : 'unsubscribe'})
111
111
 
112
 
    listinfo = c.read_list(fqdn_listname)
 
112
    listinfo = c.get_list(fqdn_listname)
113
113
 
114
114
    return render_to_response(template, {'subscribe': subscribe,
115
115
                                         'unsubscribe': unsubscribe,