diff --git a/src/postorius/auth/decorators.py b/src/postorius/auth/decorators.py index 2791825..ad3aa07 100644 --- a/src/postorius/auth/decorators.py +++ b/src/postorius/auth/decorators.py @@ -30,7 +30,7 @@ if request.user.is_authenticated(): print('already logged in') if not request.user.is_authenticated(): - if request.META.has_key('HTTP_AUTHORIZATION'): + if 'HTTP_AUTHORIZATION' in request.META: authmeth, auth = request.META['HTTP_AUTHORIZATION'].split(' ', 1) if authmeth.lower() == 'basic': diff --git a/src/postorius/tests/mailman_api_tests/test_list_members.py b/src/postorius/tests/mailman_api_tests/test_list_members.py index c36135a..c57c43e 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_members.py +++ b/src/postorius/tests/mailman_api_tests/test_list_members.py @@ -234,7 +234,8 @@ self.assertEqual(len(response.context['members']), 0) self.assertNotContains(response, member_1.email) self.assertNotContains(response, member_2.email) - self.assertEqual(response.context['empty_error'],'No member was found matching the search') + self.assertEqual(response.context['empty_error'], + 'No member was found matching the search') self.foo_list.unsubscribe('member-1@example.com') self.foo_list.unsubscribe('member-2@example.com') response = self.client.get(reverse( @@ -242,4 +243,5 @@ {'q': 'member-1'}) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context['members']), 0) - self.assertEqual(response.context['empty_error'],'List has no Subscribers') + self.assertEqual(response.context['empty_error'], + 'List has no Subscribers') diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 55c115f..0731b59 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -108,7 +108,8 @@ if len(mailing_list.members) == 0: context['empty_error'] = _('List has no Subscribers') else: - context['empty_error'] = _('No member was found matching the search') + context['empty_error'] =\ + _('No member was found matching the search') context['count_options'] = [25, 50, 100, 200] context['form'] = form else: @@ -324,10 +325,10 @@ display_name, address = email.utils.parseaddr(data) validate_email(address) mailing_list.subscribe(address=address, - display_name=display_name, - pre_verified=True, - pre_confirmed=True, - pre_approved=True) + display_name=display_name, + pre_verified=True, + pre_confirmed=True, + pre_approved=True) messages.success( request, _('The address %(address)s has been' ' subscribed to %(list)s.') % @@ -363,14 +364,14 @@ if not form.is_valid(): messages.error(request, _('Please fill out the form correctly.')) else: - for email in form.cleaned_data['emails']: + for address in form.cleaned_data['emails']: try: - validate_email(email) - self.mailing_list.unsubscribe(email.lower()) + validate_email(address) + self.mailing_list.unsubscribe(address.lower()) messages.success( request, _('The address %(address)s has been' ' unsubscribed from %(list)s.') % - {'address': email, + {'address': address, 'list': self.mailing_list.fqdn_listname}) except MailmanApiError: return utils.render_api_error(request) @@ -378,7 +379,7 @@ messages.error(request, e) except ValidationError: messages.error(request, _('The email address %s' - ' is not valid.') % email) + ' is not valid.') % address) return redirect('mass_removal', self.mailing_list.list_id) @@ -494,8 +495,8 @@ be logged in to create a new list. """ mailing_list = None - choosable_domains = [('', _('Choose a Domain'))] +\ - _get_choosable_domains(request) + choosable_domains = [('', _('Choose a Domain'))] + choosable_domains += _get_choosable_domains(request) if request.method == 'POST': form = ListNew(choosable_domains, request.POST) if form.is_valid(): @@ -782,7 +783,9 @@ if addban_form.is_valid(): try: ban_list.add(addban_form.cleaned_data['email']) - messages.success(request, _('The email {} has been banned.'.format(addban_form.cleaned_data['email']))) + messages.success(request, _( + 'The email {} has been banned.'.format( + addban_form.cleaned_data['email']))) except HTTPError as e: messages.error( request, _('An error occured: %s') % e.reason) @@ -792,7 +795,9 @@ elif 'del' in request.POST: try: ban_list.remove(request.POST['email']) - messages.success(request, _('The email {} has been un-banned'.format(request.POST['email']))) + messages.success(request, _( + 'The email {} has been un-banned'.format( + request.POST['email']))) except HTTPError as e: messages.error(request, _('An error occured: %s') % e.reason) except ValueError as e: