Coverage for src/postorius/models.py : 83%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- # Copyright (C) 1998-2019 by the Free Software Foundation, Inc. # # This file is part of Postorius. # # Postorius 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. # # Postorius 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 # Postorius. If not, see <http://www.gnu.org/licenses/>.
absolute_import, division, print_function, unicode_literals)
def create_mailman_user(sender, **kwargs):
"""Raised if the API is not available. """
"""Proxy exception. Raised if the API returns 404."""
"""Manager class to give a model class CRUD access to the API. Returns objects (or lists of objects) retrieved from the API. """
except AttributeError: raise MailmanApiError except MailmanConnectionError as e: raise MailmanApiError(e)
raise MailmanApiError(e) else: raise except MailmanConnectionError as e: raise MailmanApiError(e)
"""Similar to `self.get` but raises standard Django 404 error. """ except Mailman404Error: raise Http404 except MailmanConnectionError as e: raise MailmanApiError(e)
get_mailman_client(), 'create_' + self.resource_name) raise MailmanApiError(e) raise MailmanApiError else: except MailmanConnectionError: raise MailmanApiError
"""Not implemented since the objects returned from the API have a `delete` method of their own. """ pass
get_mailman_client(), 'get_' + self.resource_name_plural) except AttributeError: raise MailmanApiError except MailmanConnectionError as e: raise MailmanApiError(e)
email=user.email, password=None, display_name=user.get_full_name())
"""Simple REST Model class to make REST API calls Django style. """
"""Proxy function for `objects.create`. (REST API uses `create`, while Django uses `save`.) """
"""Domain model class. """
"""List model class. """
"""MailmanUser model class. """
"""Member model class. """
""" """
('site', 'Site Wide'), ('domain', 'Domain Wide'), ('list', 'MailingList Wide') )
"""A Template represents contents of partial or complete emails sent out by Mailman Core on various events or when an action is required. Headers and Footers on emails for decorations are also repsented as templates. """
max_length=100, choices=TEMPLATES_LIST, help_text=_('Choose the template you want to customize.')) help_text=_( 'Note: Do not add any secret content in templates as they are ' 'publicly accessible.\n' 'You can use these variables in the templates. \n' '$hyperkitty_url: Permalink to archived message in Hyperkitty\n' '$listname: Name of the Mailing List e.g. ant@example.com \n' '$list_id: The List-ID header e.g. ant.example.com \n' '$display_name: Display name of the mailing list e.g. Ant \n' '$short_listname: Local part of the listname e.g. ant \n' '$domain: The domain part of the listname e.g. example.com \n' '$info: The mailing list\'s longer descriptive text \n' '$request_email: The email address for -request address \n' '$owner_email: The email address for -owner address \n' '$site_email: The email address to reach the owners of the site \n' '$language: The two letter language code for list\'s preferred language e.g. fr, en, de \n' # noqa: E501 ) ) max_length=5, choices=LANGUAGES, help_text=_('Language for the template, this should be the list\'s preferred language.'), # noqa: E501 blank=True)
return '<EmailTemplate {0} for {1}>'.format(self.name, self.context)
def description(self): """Return the long description of template that is human readable."""
def api_url(self): """API url is the remote url that Core can use to fetch templates""" raise ImproperlyConfigured 'rest_template', kwargs=dict(context=self.context, identifier=self.identifier, name=self.name) )
elif self.context == 'site': obj = get_mailman_client() else: obj = None
return
# POST'ing an empty string will delete this record in Core. else: # Use the API endpoint of self that Core can use to fetch this.
def update_core_post_update(sender, **kwargs):
def update_core_post_delete(sender, **kwargs): |