diff --git a/src/mailman_django/models.py b/src/mailman_django/models.py index 578f3b6..1fab6d9 100644 --- a/src/mailman_django/models.py +++ b/src/mailman_django/models.py @@ -95,6 +95,34 @@ pass +class MailmanListManager(MailmanRestManager): + + def __init__(self): + super(MailmanListManager, self).__init__('list', 'lists') + + def all(self, only_public=False): + try: + objects = getattr(self.client, self.resource_name_plural) + except AttributeError: + raise MailmanApiError + if only_public: + public = [] + for obj in objects: + if obj.settings.get('advertised', False): + public.append(obj) + return public + else: + return objects + + def by_mail_host(self, mail_host, only_public=False): + objects = self.all(only_public) + host_objects = [] + for obj in objects: + if obj.mail_host == mail_host: + host_objects.append(obj) + return host_objects + + class MailmanRestModel(object): """Simple REST Model class to make REST API calls Django style. """ @@ -120,4 +148,6 @@ class List(MailmanRestModel): """List model class. """ - objects = MailmanRestManager('list', 'lists') + objects = MailmanListManager() + + diff --git a/src/mailman_django/static/mailman_django/default/css/style.css b/src/mailman_django/static/mailman_django/default/css/style.css index 418bebf..86ab271 100755 --- a/src/mailman_django/static/mailman_django/default/css/style.css +++ b/src/mailman_django/static/mailman_django/default/css/style.css @@ -76,7 +76,6 @@ /* Add layout tyles here */ body { - background-color: #d4d4d4; font-size: 87.5%; font-family: Verdana, Arial, sans-serif; } @@ -94,9 +93,6 @@ margin: 5px auto; padding: 25px 0 25px 35px; border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - background: #fff repeat top left url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAKCAYAAAD2Fg1xAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAN1wAADdcBQiibeAAAAAd0SU1FB9sHFAYzEtopMl4AAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAUklEQVQ4y+2T0QnAQAhDbbkf3X/DW0JDsN2h4IHSN0DgkeRy90eas/eWW4ZQIgJAAPQXISkkj4qsilAzmzGtMR+JCImI/tPKzOONlIio6v+Rr7wQbht30ThlBAAAAABJRU5ErkJggg=='); } .mm_actionButtons { margin: 30px 0 30px 0; diff --git a/src/mailman_django/templates/mailman-django/lists/index.html b/src/mailman_django/templates/mailman-django/lists/index.html index 50e2ec0..a493901 100644 --- a/src/mailman_django/templates/mailman-django/lists/index.html +++ b/src/mailman_django/templates/mailman-django/lists/index.html @@ -17,7 +17,7 @@
- {{ list.real_name }} + {{ list.real_name }} ({{ list.fqdn_listname }}) {% if not list.settings.advertised %}(non-public){% endif %}
diff --git a/src/mailman_django/views.py b/src/mailman_django/views.py index a0828f9..f42fb8c 100644 --- a/src/mailman_django/views.py +++ b/src/mailman_django/views.py @@ -144,28 +144,27 @@ def list_index(request, template = 'mailman-django/lists/index.html'): - """Show a table of all mailing lists. + """Show a table of all public mailing lists. """ lists = [] error = None domain_name = None domain = None + if request.user.is_authenticated(): + only_public = False + else: + only_public = True if "HTTP_HOST" in request.META.keys(): scheme = 'http' if "HTTPS" in request.META.keys(): scheme = 'https' domain_name = request.META["HTTP_HOST"].split(":")[0] - web_host = '%s://%s' % (scheme, domain_name) try: - domain = Domain.objects.get(web_host=web_host) + domain = Domain.objects.get(web_host=domain_name) if domain is not None: - domain_name = domain.mail_host - lists = List.objects.all() - for list in Lists.objects.all(): - if list.mail_host == domain_name: - lists.append(list) + lists = List.objects.by_mail_host(domain.mail_host, only_public=only_public) else: - lists = List.objects.all() + lists = List.objects.all(only_public=only_public) except MailmanApiError: return render_api_error(request) if request.method == 'POST':