~mailmanweb-django/+junk/dev

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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
# -*- 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 import forms
from django.utils.translation import gettext as _
from fieldset_forms import FieldsetForm

class ListNew(FieldsetForm):
    """
    Form fields to add a new list. Languages are hard coded which should 
    be replaced by a REST lookup of available languages.
    """
    languages = (("Arabic", "Arabic"),
                 ("Catalan", "Catalan"),
                 ("Chinese (China)", "Chinese (China)"),
                 ("Chinese (Taiwan)", "Chinese (Taiwan)"),
                 ("Croatian", "Croatian"),
                 ("Czech", "Czech"),
                 ("Danish", "Danish"),
                 ("Dutch", "Dutch"),
                 ("English (USA)", "English (USA)"),
                 ("Estonian", "Estonian"),
                 ("Estonian", "Estonian"),
                 ("Euskara", "Euskara"),
                 ("Finnish", "Finnish"),
                 ("French", "French"),
                 ("German", "German"),
                 ("Hungarian", "Hungarian"),
                 ("Interlingua", "Interlingua"),
                 ("Italian", "Italian"),
                 ("Japanese", "Japanese"),
                 ("Korean", "Korean"),
                 ("Lithuanian", "Lithuanian"),
                 ("Norwegian", "Norwegian"),
                 ("Polish", "Polish"),
                 ("Portuguese", "Portuguese"),
                 ("Portuguese (Brazil)",  "Portuguese (Brazil)"),
                 ("Romanian", "Romanian"),
                 ("Russian", "Russian"),
                 ("Serbian", "Serbian"),
                 ("Slovenian", "Slovenian"),
                 ("Spanish (Spain)", "Spanish (Spain)"),
                 ("Swedish", "Swedish"),
                 ("Turkish", "Turkish"),
                 ("Ukrainian", "Ukrainian"),
                 ("Vietnamese", "Vietnamese"))
    listname = forms.EmailField(
        label = _('List Name'), 
        error_messages = {'required': _('Please enter a name for your list.'), 
                          'invalid': _('Please enter a valid list name.')})
    list_owner = forms.EmailField(
        label = _('Inital list owner address'),
        error_messages = {
            'required': _("Please enter the list owner's email address."), 
            'invalid': _('Please enter a valid email adress.')
        },
        required = True)
    list_type = forms.ChoiceField(
        widget = forms.Select(),
        label = _('List Type'), 
        error_messages = {
            'required': _("Please choose a list type."), 
        },
        required = True,
        choices = (
            ("", _("Please choose")),
            ("closed_discussion", _("Closed discussion list")),
            ("announcement", _("Announcement list")),
        ))
    languages = forms.MultipleChoiceField(
        label = _('Language'),
        widget = forms.CheckboxSelectMultiple(),
        choices = languages,
        required = False)

    class Meta:
        """
        Class to handle the automatic insertion of fieldsets and divs.
        
        To use it: add a list for each wished fieldset. The first item in 
        the list should be the wished name of the fieldset, the following 
        the fields that should be included in the fieldset.
        """
        layout = [["List Details", "listname", "list_owner", "list_type"],
                  ["Available Languages", "languages"]]

class ListSubscribe(forms.Form):
    """Form fields to join an existing list.
    """
    listname = forms.EmailField(
        label = _('List Name'), 
        widget = forms.HiddenInput(),
        error_messages = {
            'required': _('Please enter the mailing list address.'), 
            'invalid': _('Please enter a valid email address.')
        })
    email = forms.EmailField(
        label = _('Your email address'), 
        error_messages = {'required': _('Please enter an email address.'), 
                          'invalid': _('Please enter a valid email address.')})
    real_name = forms.CharField(
        label = _('Your name'), 
        required = False,
    )
    name = forms.CharField(
        label = _('Name of action'), 
        widget = forms.HiddenInput(),
        #initial = 'subscribe',
    )
    
    # should add password!

class ListUnsubscribe(forms.Form):
    """Form fields to leave an existing list.
    """
    listname = forms.EmailField(
        label = _('List Name'), 
        widget = forms.HiddenInput(),
        error_messages = {
            'required': _('Please enter the mailing list address.'), 
            'invalid': _('Please enter a valid email address.')
        }
    )
    email = forms.EmailField(
        label = _('Your email address'), 
        error_messages = {
            'required': _('Please enter an email address.'), 
            'invalid': _('Please enter a valid email address.')
        }
    )
    name = forms.CharField(
    label = _('Name of action'), 
    widget = forms.HiddenInput(),
    #initial = 'unsubscribe'
    )

    # should at one point add the password to be required as well!
class ListSettings(FieldsetForm):
    """Form fields dealing with the list settings.
    """
    choices = ((True, 'Yes'), (False, 'No'),)
    list_name = forms.CharField(
        label = _('List Name'),
        required = False,
    )
    host_name = forms.CharField(
        label = _('Domain host name'),
        required = False,
    )
    fqdn_listname = forms.CharField(
        label = _('Fqdn listname'),
        required = False,
    )
    #id = forms.IntegerField(    # this should probably not be changeable...
        #label = _('ID'),
        #initial = 9,
        #widget = forms.HiddenInput(),
        #required = False,
        #error_messages = {
            #'invalid': _('Please provide an integer ID.')
        #}
    #)
    list_id = forms.CharField(    # this should probably not be changeable...
        label = _('List ID'),
        required = False,
    )
    http_etag = forms.CharField(
        label = _('Http etag'),
        required = False,
    )
    include_list_post_header = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Include list post header'),
    )
    include_rfc2369_headers = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Include RFC2369 headers'),
    )
    autorespond_owner = forms.IntegerField(
        label = _('Autorespond owner'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
    )
    autoresponse_owner_text = forms.CharField(
        label = _('Autoresponse owner text'),
    )
    autorespond_postings = forms.IntegerField(
        label = _('Autorespond postings'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
    )
    autoresponse_postings_text = forms.CharField(
        label = _('Autoresponse postings text'),
    )
    autorespond_requests = forms.IntegerField(
        label = _('Autorespond requests'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
    )
    autoresponse_request_text = forms.CharField(
        label = _('Autoresponse request text'),
    )
    autoresponse_grace_period = forms.CharField(
        label = _('Autoresponse grace period'),
    )
    bounces_address = forms.EmailField(
        label = _('Bounces Address'),
        required = False,
    )
    #ban_list = forms.CharField(
        #label = _('Ban list'),
        #widget = forms.Textarea
    #)
    #bounce_info_stale_after = forms.CharField(
        #label = _('Bounce info stale after'),
    #)
    #bounce_matching_headers = forms.CharField(
        #label = _('Bounce matching headers'),
    #)
    #bounce_notify_owner_on_disable = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Bounce notify owner on disable'),
    #)
    #bounce_notify_owner_on_removal = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Bounce notify owner on removal'),
    #)
    #bounce_processing = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Bounce processing'),
    #)
    #bounce_score_threshold = forms.IntegerField(
        #label = _('Bounce score threshold'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #bounce_score_threshold = forms.IntegerField(
        #label = _('Bounce score threshold'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #bounce_unrecognized_goes_to_list_owner = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Bounce unrecognized goes to list owner'),
    #)
    #bounce_you_are_disabled_warnings = forms.IntegerField(
        #label = _('Bounce you are disabled warnings'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #bounce_you_are_disabled_warnings_interval = forms.CharField(
        #label = _('Bounce you are disabled warnings interval'),
    #)
    #archive = forms.BooleanField(
        #widget = forms.RadioSelect(choices=choices),
        #required = False,
        #label = _('Archive'),
        #)
    #archive_private = forms.BooleanField(
        #widget = forms.RadioSelect(choices=choices),
        #required = False,
        #label = _('Private Archive'),
        #)
    advertised = forms.BooleanField(
        widget = forms.RadioSelect(choices=choices),
        required = False,
        label = _('Advertised'),
    )
    filter_content = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Filter content'),
    )
    collapse_alternatives = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Collapse alternatives'),
    )
    convert_html_to_plaintext = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Convert html to plaintext'),
    )
    #default_member_moderation = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Default member moderation'),
    #)
    description = forms.CharField(
        label = _('Description'),
    )
    #digest_footer = forms.CharField(
        #label = _('Digest footer'),
    #)
    #digest_header = forms.CharField(
        #label = _('Digest header'),
    #)
    #digest_is_default = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Digest is default'),
    #)
    #digest_send_periodic = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Digest send periodic'),
    #)
    digest_size_threshold = forms.DecimalField(
        label = _('Digest size threshold'),
    )
    #digest_volume_frequency = forms.CharField(
        #label = _('Digest volume frequency'),
    #)
    #digestable = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Digestable'),
    #)
    digest_last_sent_at = forms.IntegerField(
        label = _('Digest last sent at'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
        required = False,
    )
    #discard_these_nonmembers = forms.CharField(
        #label = _('Discard these nonmembers'),
        #widget = forms.Textarea
    #)
    #emergency = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Emergency'),
    #)
    #encode_ascii_prefixes = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Encode ascii prefixes'),
    #)
    #first_strip_reply_to = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('First strip reply to'),
    #)
    #forward_auto_discards = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Forward auto discards'),
    #)
    #gateway_to_mail = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Gateway to mail'),
    #)
    #gateway_to_news = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Gateway to news'),
    #)
    #generic_nonmember_action = forms.IntegerField(
        #label = _('Generic nonmember action'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #goodbye_msg = forms.CharField(
        #label = _('Goodbye message'),
    #)
    #header_matches = forms.CharField(
        #label = _('Header matches'),
        #widget = forms.Textarea
    #)
    #hold_these_nonmembers = forms.CharField(
        #label = _('Hold these nonmembers'),
        #widget = forms.Textarea
    #)
    #info = forms.CharField(
        #label = _('Information'),
    #)
    #linked_newsgroup = forms.CharField(
        #label = _('Linked newsgroup'),
    #)
    #max_days_to_hold = forms.IntegerField(
        #label = _('Maximum days to hold'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #max_message_size = forms.IntegerField(
        #label = _('Maximum message size'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #max_num_recipients = forms.IntegerField(
        #label = _('Maximum number of recipients'), 
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #member_moderation_action = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Member moderation action'),
    #)
    #member_moderation_notice = forms.CharField(
        #label = _('Member moderation notice'),
    #)
    #mime_is_default_digest = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Mime is default digest'),
    #)
    #moderator_password = forms.CharField(
        #label = _('Moderator password'),
        #widget = forms.PasswordInput,
        #error_messages = {'required': _('Please enter your password.'), 
                          #'invalid': _('Please enter a valid password.')},
    #)
    #msg_footer = forms.CharField(
        #label = _('Message footer'),
    #)
    #msg_header = forms.CharField(
        #label = _('Message header'),
    #)
    #new_member_options = forms.IntegerField(
        #label = _('New member options'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #news_moderation = forms.CharField(
        #label = _('News moderation'),
    #)
    #news_prefix_subject_too = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('News prefix subject too'),
    #)
    #nntp_host = forms.CharField(
        #label = _('Nntp host'),
    #)
    #nondigestable = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Nondigestable'),
    #)
    #nonmember_rejection_notice = forms.CharField(
        #label = _('Nonmember rejection notice'),
    #)
    next_digest_number = forms.IntegerField(
        label = _('Next digest number'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
        required = False,
    )
    no_reply_address = forms.EmailField(
        label = _('No reply address'),
        required = False,
    )
    #obscure_addresses = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Obscure addresses'), 
    #)
    #personalize = forms.CharField(
        #label = _('Personalize'),
    #)
    pipeline = forms.CharField(
        label = _('Pipeline'),
    )
    post_id = forms.IntegerField(
        label = _('Post ID'),
        error_messages = {
            'invalid': _('Please provide an integer.'),
        },
        required = False,
    )
    #preferred_language = forms.CharField(
        #label = _('Preferred language'),
    #)
    #private_roster = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Private roster'),
    #)
    real_name = forms.CharField(
        label = _('Real name'),
    )
    #reject_these_nonmembers = forms.CharField(
        #label = _('Reject these nonmembers'),
        #widget = forms.Textarea
    #)
    #reply_goes_to_list = forms.CharField(
        #label = _('Reply goes to list'),
    #)
    #reply_to_address = forms.EmailField(
        #label = _('Reply to address'),
    #)
    #require_explicit_destination = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Require explicit destination'),
    #)
    #respond_to_post_requests = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Respond to post requests'),
    #)
    request_address = forms.EmailField(
        label = _('Request address'),
        required = False,
    )
    #scrub_nondigest = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Scrub nondigest'),
    #)
    #send_goodbye_msg = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Send goodbye message'),
    #)
    #send_reminders = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Send reminders'),
    #)
    #send_welcome_msg = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Send welcome message'),
    #)
    #start_chain = forms.CharField(
        #label = _('Start chain'),
    #)
    #subject_prefix = forms.CharField(
        #label = _('Subject prefix'),
    #)
    #subscribe_auto_approval = forms.CharField(
        #label = _('Subscribe auto approval'),
        #widget = forms.Textarea
    #)
    #subscribe_policy = forms.IntegerField(
        #label = _('Subscribe policy'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    scheme = forms.CharField(
        label = _('Scheme'),
        required = False,
    )
    #topics = forms.CharField(
        #label = _('Topics'),
        #widget = forms.Textarea
    #)
    #topics_bodylines_limit = forms.IntegerField(
        #label = _('Topics bodylines limit'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #topics_enabled = forms.BooleanField(
        #widget = forms.RadioSelect(choices = choices), 
        #required = False,
        #label = _('Topics enabled'),
    #)
    #unsubscribe_policy = forms.IntegerField(
        #label = _('Unsubscribe policy'),
        #error_messages = {
            #'invalid': _('Please provide an integer.')
        #}
    #)
    #welcome_msg = forms.CharField(
        #label = _('Welcome message'),
    #)
    volume = forms.IntegerField(
        label = _('Volume'),
        required = False,
    )
    web_host = forms.CharField(
        label = _('Web host'),
        required = False,
    )
    acceptable_aliases = forms.CharField(
        label = _("Acceptable aliases"),
    )
    admin_immed_notify = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Admin immed notify'),
    )
    admin_notify_mchanges = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Admin notify mchanges'),
    )
    administrivia = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Administrivia'),
    )
    anonymous_list = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Anonymous list'),
    )
    created_at = forms.IntegerField(
        label = _('Created at'),
        widget = forms.HiddenInput(),
        required = False,
    )
    join_address = forms.EmailField(
        label = _('Join address'),
        required = False,
    )
    last_post_at = forms.IntegerField(
        label = _('Last post at'),
        required = False,
    )
    leave_address = forms.EmailField(
        label = _('Leave address'),
        required = False,
    )
    owner_address = forms.EmailField(
        label = _('Owner Address'),
        required = False,
    )
    posting_address = forms.EmailField(
        label = _('Posting Address'),
        required = False,
    )

    class Meta:
        """Class to handle the automatic insertion of fieldsets and divs.
        
        To use it: add a list for each wished fieldset. The first item in 
        the list should be the wished name of the fieldset, the following 
        the fields that should be included in the fieldset.
        """
        # just a really temporary layout to see that it works. -- Anna
        layout = [
            ["List Indentity", "real_name", "include_list_post_header", 
             "include_rfc2369_headers"], 
             #"info", "list_name", "host_name", "list_id", "fqdn_listname", 
             #"http_etag", "volume", "web_host"
            ["Automatic Responses", "autorespond_owner",
             "autoresponse_owner_text", "autorespond_postings",
             "autoresponse_postings_text", "autorespond_requests",
             "autoresponse_request_text", "autoresponse_grace_period"],
             #["Bounce", "ban_list", 
             #"bounce_info_stale_after", "bounce_matching_headers", 
             # "bounce_notify_owner_on_disable",
             #"bounce_notify_owner_on_removal", "bounce_processing",
             #"bounce_score_threshold",
             #"bounce_unrecognized_goes_to_list_owner",
             #"bounce_you_are_disabled_warnings",
             #"bounce_you_are_disabled_warnings_interval"],
            #["Archiving", "archive"],
            ["Content Filtering", "filter_content", "collapse_alternatives",
             "convert_html_to_plaintext", "description"], 
             #"default_member_moderation", "scheme"
            ["Digest", "digest_size_threshold"], #"next_digest_number", 
             #"last_post_at", "digest_last_sent_at", "digest_footer", 
             #"digest_header", "digest_is_default",
             #"digest_send_periodic", "digest_size_threshold",
             #"digest_volume_frequency", "digestable"],
             #["Moderation","discard_these_nonmembers", "emergency",
             #"generic_nonmember_action", "generic_nonmember_action",
             #"member_moderation_action", "member_moderation_notice",
             #"moderator_password", "hold_these_nonmembers"],
             #["Message Text", "msg_header", "msg_footer", "welcome_msg", 
             #"goodbye_msg"],
            ["Privacy", "advertised", "admin_immed_notify", 
             "admin_notify_mchanges", "anonymous_list"], #"archive_private", 
            #"obscure_addresses", "private_roster",
            #["Addresses", "bounces_address", "join_address", "leave_address", 
             #"no_reply_address", "owner_address", "posting_address", 
             #"request_address"],
            ["Assorted", "acceptable_aliases", "administrivia", "pipeline"]]
             #"post_id", "encode_ascii_prefixes", "first_strip_reply_to",
             #"forward_auto_discards", "gateway_to_mail", "gateway_to_news",
             #"header_matches", "linked_newsgroup", "max_days_to_hold",
             #"max_message_size", "max_num_recipients",
             #"mime_is_default_digest", "new_member_options",
             #"news_moderation", "news_prefix_subject_too", "nntp_host",
             #"nondigestable", "nonmember_rejection_notice", "personalize",
             #"preferred_language",
             #"reject_these_nonmembers", "reply_goes_to_list",
             #"reply_to_address", "require_explicit_destination",
             #"respond_to_post_requests", "scrub_nondigest",
             #"send_goodbye_msg", "send_reminders", "send_welcome_msg",
             #"start_chain", "subject_prefix", "subscribe_auto_approval",
             #"subscribe_policy", "topics", "topics_bodylines_limit",
             #"topics_enabled", "unsubscribe_policy"]]

class Login(FieldsetForm):
    """Form fields to let the user log in.
    """
    addr = forms.EmailField(
        label = _('Email address'),
        error_messages = {'required': _('Please enter an email address.'), 
                          'invalid': _('Please enter a valid email address.')},
        required = True,
    )
    psw = forms.CharField(
        label = _('Password'),
        widget = forms.PasswordInput,
        error_messages = {'required': _('Please enter your password.'), 
                          'invalid': _('Please enter a valid password.')},
        required = True,
    )

    class Meta:
        """
        Class to define the name of the fieldsets and what should be
        included in each.
        """
        layout = [["Login", "addr", "psw"],]

class ListMassSubscription(FieldsetForm):
    """Form fields to masssubscribe users to a list.
    """
    emails = forms.CharField(
        label = _('Emails to mass subscribe'),
        widget = forms.Textarea,
    )

    class Meta:
        """
        Class to define the name of the fieldsets and what should be
        included in each.
        """
        layout = [["Mass subscription", "emails"],]

class MembershipSettings(FieldsetForm):
    """Form handling the membership settings.
    """
    choices = ((True, 'Yes'), (False, 'No'),)
    acknowledge_posts = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Acknowledge posts'),
    )
    hide_address = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Hide address'),
    )
    receive_list_copy = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Receive list copy'),
    )
    receive_own_postings = forms.BooleanField(
        widget = forms.RadioSelect(choices = choices), 
        required = False,
        label = _('Receive own postings'),
    )
    delivery_mode = forms.ChoiceField(
        widget = forms.Select(),
        error_messages = {
            'required': _("Please choose a mode."),
        },
        required = False,
        choices = (
            ("", _("Please choose")),
            ("delivery_mode", "some mode..."), # TODO: this must later
            # be dynalically changed to what modes the list offers
            # (see the address field in __init__ in UserSettings for
            # how to do this)
        ),
        label = _('Delivery mode'),
    )
    delivery_status = forms.ChoiceField(
        widget = forms.Select(),
        error_messages = {
            'required': _("Please choose a status."),
        },
        required = False,
        choices = (
            ("", _("Please choose")),
            ("delivery_status", "some status..."), # TODO: this must 
            # later be dynalically changed to what statuses the list 
            # offers (see the address field in __init__ in UserSettings
            # for how to do this)
        ),
        label = _('Delivery status'),
    )

    class Meta:
        """
        Class to define the name of the fieldsets and what should be
        included in each.
        """
        layout = [["Membership Settings", "acknowledge_posts", "hide_address", 
                   "receive_list_copy", "receive_own_postings", 
                   "delivery_mode", "delivery_status"],]

class UserSettings(FieldsetForm):
    """Form handling the user settings.
    """
    def __init__(self, address_choices, *args, **kwargs):
        """
        Initialize the user settings with a field 'address' where 
        the values are set dynamically in the view.
        """
        super(UserSettings, self).__init__(*args, **kwargs)
        self.fields['address'] = forms.ChoiceField(choices=(address_choices), 
                                                   widget = forms.Select(), 
                                                   error_messages = {'required': _("Please choose an address."),},
                                                   required = True,
                                                   label = _('Default email address'),)
    
    id = forms.IntegerField(    # this should probably not be 
                                # changeable...
        label = _('ID'),
        initial = 9,
        widget = forms.HiddenInput(),
        required = False,
        error_messages = {
            'invalid': _('Please provide an integer ID.')
        }
    )
    mailing_list = forms.CharField( # not sure this needs to be here
        label = _('Mailing list'),
        widget = forms.HiddenInput(),
        required = False,
    )
    real_name =forms.CharField(
        label = _('Real name'),
        required = False,
    )
    preferred_language = forms.ChoiceField(
        label = _('Default/Preferred language'),
        widget = forms.Select(),
        error_messages = {
            'required': _("Please choose a language."),
        },
        required = False,
        choices = (
            ("", _("Please choose")),
            ("English (USA)", "English (USA)"), # TODO: this must later
            # be dynalically changed to what languages the list offers
            # (see the address field in __init__ for how to do this)
        )
    )
    password = forms.CharField(
        label = _('Change password'),
        widget = forms.PasswordInput,
        required = False,
        error_messages = {'required': _('Please enter your password.'), 
                          'invalid': _('Please enter a valid password.')},
    )
    conf_password = forms.CharField(
        label = _('Confirm password'),
        widget = forms.PasswordInput,
        required = False,
        error_messages = {'required': _('Please enter your password.'), 
                          'invalid': _('Please enter a valid password.')},
    )

    class Meta:
        """
        Class to define the name of the fieldsets and what should be
        included in each.
        """
        layout = [["User settings", "real_name", "password", 
                   "conf_password", "preferred_language", "address"],]