Joanna Skrzeszewska has proposed merging lp:~jskrzeszewska/postorius/enablingArchivers into lp:postorius.
Requested reviews: Barry Warsaw (barry) For more details, see: https://code.launchpad.net/~jskrzeszewska/postorius/enablingArchivers/+merge/184460 Changes for enabling/disabling archivers using postorius (bug 1158040). -- https://code.launchpad.net/~jskrzeszewska/postorius/enablingArchivers/+merge/184460 Your team Mailman Coders is subscribed to branch lp:postorius.
=== modified file 'src/postorius/forms.py' --- src/postorius/forms.py 2013-03-21 18:43:28 +0000 +++ src/postorius/forms.py 2013-09-08 07:33:01 +0000 @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License along with # Postorius. If not, see <http://www.gnu.org/licenses/>. +from copy import deepcopy from django import forms from django.core.validators import validate_email from django.utils.translation import gettext as _ @@ -222,6 +223,10 @@ label=_('Archive Policy'), help_text=_('Policy for archiving messages for this list'), ) + enable_archiver_choices = ( + (1, _("On")), + (0, _("Off")) + ) autorespond_choices = ( ("respond_and_continue", _("Respond and continue processing")), ("respond_and_discard", _("Respond and discard message")), @@ -467,7 +472,8 @@ "Alter Messages": _("Settings that modify member messages"), "Digest": _("Digest-related options"), "Message Acceptance": _("Options related to accepting messages"), - "Archives": _("Options related to archiving messages")} + "Archives": _("Options related to archiving messages"), + "Enable Archivers": _("Enable/disable archivers")} def clean_acceptable_aliases(self): data = self.cleaned_data['acceptable_aliases'] @@ -475,6 +481,7 @@ def __init__(self, visible_section, visible_option, *args, **kwargs): super(ListSettings, self).__init__(*args, **kwargs) + self.layout = deepcopy(self.layout) # if settings: # raise Exception(settings) # debug if visible_option: @@ -499,6 +506,24 @@ except: pass # empty form + try: + data = kwargs['data'] + except: + data = None + if data: + for key, value in data.iteritems(): + if key.startswith('enable_archiver_'): + # remove 'enable_archiver_' prefix to get real archiver name + real_name = key[16:] + # append field name to layout to make it visible + self.layout[0].append(key) + # create field + self.fields[key] = forms.BooleanField( + widget=forms.RadioSelect(choices=self.enable_archiver_choices), + required=False, + label=_('Enable archiver ' + real_name), + help_text=('Enable archiver ' + real_name)) + def truncate(self): """ truncates the form to have only those fields which are in self.layout @@ -542,7 +567,7 @@ ["Digest", "digest_size_threshold"], ["Message Acceptance", "acceptable_aliases", "administrivia", "default_nonmember_action", "default_member_action"], - ["Archives", "archive_policy"], + ["Archives", "archive_policy", "enable_archivers"], ] === modified file 'src/postorius/views/list.py' --- src/postorius/views/list.py 2013-07-14 20:39:16 +0000 +++ src/postorius/views/list.py 2013-09-08 07:33:01 +0000 @@ -511,9 +511,21 @@ form.truncate() if form.is_valid(): list_settings = the_list.settings + # TODO: dict does not work, sending list of strings for now + archivers = [] for key in form.fields.keys(): - list_settings[key] = form.cleaned_data[key] - list_settings.save() + # special case for archivers + if key.startswith('enable_archiver_'): + real_name = key[16:] + if form.cleaned_data[key]: + value = '1' + else: + value = '0' + archivers.append(real_name + "|" + value) + else: + list_settings[key] = form.cleaned_data[key] + list_settings['archivers'] = archivers + list_settings.save() message = _("The list settings have been updated.") else: message = _("Validation Error - The list settings have not been updated.") @@ -525,9 +537,13 @@ used_settings = {} for section in form.layout: for option in section[1:]: - used_settings[option] = the_list.settings[option] - if option == u'acceptable_aliases': - used_settings[option] = '\n'.join(used_settings[option]) + if option == u'enable_archivers': + for key, value in the_list.settings['archivers'].iteritems(): + used_settings['enable_archiver_' + key] = value + else: + used_settings[option] = the_list.settings[option] + if option == u'acceptable_aliases': + used_settings[option] = '\n'.join(used_settings[option]) # recreate the form using the settings form = ListSettings(visible_section, visible_option, data=used_settings)
_______________________________________________ Mailman-coders mailing list [email protected] https://mail.python.org/mailman/listinfo/mailman-coders
