diff --git a/src/postorius/forms.py b/src/postorius/forms.py index 8687e5b..374dfd4 100644 --- a/src/postorius/forms.py +++ b/src/postorius/forms.py @@ -219,6 +219,24 @@ for address in user_emails) +class ListAnonymousSubscribe(forms.Form): + """Form fields to join an existing list as an anonymous user. + """ + + email = forms.CharField( + label=_('Your email address'), + validators=[validate_email], + error_messages={ + 'required': _('Please enter an email address.'), + 'invalid': _('Please enter a valid email address.')}) + + display_name = forms.CharField( + label=_('Your name (optional)'), required=False) + + def __init__(self, *args, **kwargs): + super(ListAnonymousSubscribe, self).__init__(*args, **kwargs) + + class ListSettingsForm(forms.Form): """ Base class for list settings forms. diff --git a/src/postorius/templates/postorius/lists/summary.html b/src/postorius/templates/postorius/lists/summary.html index 6dc2a77..f964d0f 100644 --- a/src/postorius/templates/postorius/lists/summary.html +++ b/src/postorius/templates/postorius/lists/summary.html @@ -70,8 +70,23 @@ {% endif %} {% else %} -

{% trans 'If you want to subscribe to this list, you have to log in first.' %}

+
+

{% trans 'If you want to subscribe to this list and you have an account, please log in first.' %}

{% trans 'Log In' %}

+
+
+
+

+ {% blocktrans %} + However you can also subscribe without creating an account. + If you wish to to so, please use the form below. + {% endblocktrans%} +

+
+ {% bootstrap_form_horizontal anonymous_subscription_form 2 8 'Subscribe' %} +
+
{% endif %} {# List metrics #} diff --git a/src/postorius/tests/mailman_api_tests/test_list_summary.py b/src/postorius/tests/mailman_api_tests/test_list_summary.py index ee4aee5..b7cf12d 100644 --- a/src/postorius/tests/mailman_api_tests/test_list_summary.py +++ b/src/postorius/tests/mailman_api_tests/test_list_summary.py @@ -22,6 +22,7 @@ from django.core.urlresolvers import reverse from postorius.tests.utils import ViewTestCase +from postorius.forms import ListAnonymousSubscribe class ListSummaryPageTest(ViewTestCase): @@ -41,13 +42,15 @@ user=self.user, email=self.user.email, verified=True) def test_list_summary_logged_out(self): - # Response must contain list obj but not the form. + # Response must contain list obj and anonymous subscribe form. response = self.client.get(reverse('list_summary', args=('foo@example.com', ))) self.assertEqual(response.status_code, 200) self.assertEqual(response.context['list'].fqdn_listname, 'foo@example.com') - self.assertNotContains(response, '