newsletters package

Submodules

newsletters.admin module

Registers admin interfaces for the newsletters module

class newsletters.admin.NewsletterAdmin(model, admin_site)[source]

Bases: utils.translation.TranslatedModelAdmin

Manage the newsletters

change_view(request, object_id, form_url='')[source]

Renders the change view Disallow change access if a newsletter is marked as sent

date_hierarchy = 'date'

field to use for date filtering

exclude = None
fields = None
fieldsets = ((None, {'fields': ('title_en', 'title_nl', 'date', 'send_date', 'description_en', 'description_nl')}),)

available fieldsets in the admin change form

get_actions(request)[source]

Remove the deletion action from the admin

has_delete_permission(request, obj=None)[source]

Check if delete permission is granted Disallow deletion if a newsletter is marked as sent

inlines = (<class 'newsletters.admin.NewsletterItemInline'>, <class 'newsletters.admin.NewsletterEventInline'>)

available inlines in the admin change form

list_display = ('title', 'date', 'send_date', 'sent')

available fields in the admin overview list

property media
search_fields = ('title_en', 'title_nl', 'description_en', 'description_nl')

available fields for searching

class newsletters.admin.NewsletterEventInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

The inline for the event items in the newsletter

extra = 0
form

alias of newsletters.forms.NewsletterEventForm

property media
model

alias of newsletters.models.NewsletterEvent

class newsletters.admin.NewsletterItemInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

The inline for the text items in the newsletter

extra = 0
fields = ('order', 'title_en', 'title_nl', 'url', 'description_en', 'description_nl')
property media
model

alias of newsletters.models.NewsletterItem

newsletters.apps module

Configuration for the newsletters package

class newsletters.apps.NewslettersConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

AppConfig for the newsletters package

name = 'newsletters'
verbose_name = 'Newsletters'

newsletters.emails module

The emails defined by the newsletters package

newsletters.emails.send_newsletter(newsletter)[source]

Sends the newsletter as HTML and plaintext email

Parameters

newsletter – the newsletter to be send

newsletters.forms module

The forms defined by the newsletters package

class newsletters.forms.NewsletterEventForm(*args, **kwargs)[source]

Bases: django.forms.models.ModelForm

Custom ModelForm for the NewsletterEvent model to add the order field and javascript for automatic field filling

class Media[source]

Bases: object

js = ('js/js.cookie.min.js', 'admin/newsletters/js/forms.js')
class Meta[source]

Bases: object

fields = ('order', 'event', 'title_en', 'title_nl', 'url', 'description_en', 'description_nl', 'where_en', 'where_nl', 'start_datetime', 'end_datetime', 'show_costs_warning', 'price', 'penalty_costs')
model

alias of newsletters.models.NewsletterEvent

base_fields = {'description_en': <django.forms.fields.CharField object>, 'description_nl': <django.forms.fields.CharField object>, 'end_datetime': <django.forms.fields.DateTimeField object>, 'event': <django.forms.fields.ChoiceField object>, 'order': <django.forms.fields.IntegerField object>, 'penalty_costs': <django.forms.fields.DecimalField object>, 'price': <django.forms.fields.DecimalField object>, 'show_costs_warning': <django.forms.fields.BooleanField object>, 'start_datetime': <django.forms.fields.DateTimeField object>, 'title_en': <django.forms.fields.CharField object>, 'title_nl': <django.forms.fields.CharField object>, 'url': <django.forms.fields.URLField object>, 'where_en': <django.forms.fields.CharField object>, 'where_nl': <django.forms.fields.CharField object>}
declared_fields = {'event': <django.forms.fields.ChoiceField object>}
property media

Return all media required to render the widgets on this form.

newsletters.models module

The models defined by the newsletters package

class newsletters.models.Newsletter(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes a newsletter

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property description

Accessor that fetches the localized variant of description

description_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description_nl

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_absolute_url()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

newslettercontent_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <django.db.models.manager.Manager object>
save(*args, **kwargs)[source]

Save the current instance. Override this in a subclass if you want to control the saving process.

The ‘force_insert’ and ‘force_update’ parameters can be used to insist that the “save” must be an SQL insert or update (or equivalent for non-SQL backends), respectively. Normally, they should not be set.

send_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

sent

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property title

Accessor that fetches the localized variant of title

title_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_nl

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class newsletters.models.NewsletterContent(*args, **kwargs)[source]

Bases: django.db.models.base.Model

Describes one piece of basic content of a newsletter

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

clean()[source]

Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.

property description

Accessor that fetches the localized variant of description

description_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

description_nl

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

newsletter

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

newsletter_id
newsletterevent

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

newsletteritem

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

objects = <django.db.models.manager.Manager object>
order

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property title

Accessor that fetches the localized variant of title

title_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

title_nl

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

url

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class newsletters.models.NewsletterEvent(*args, **kwargs)[source]

Bases: newsletters.models.NewsletterContent

Describes one piece of event content of a newsletter

exception DoesNotExist

Bases: newsletters.models.NewsletterContent.DoesNotExist

exception MultipleObjectsReturned

Bases: newsletters.models.NewsletterContent.MultipleObjectsReturned

clean()[source]

Make sure that the event end date is after the start date

end_datetime

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_end_datetime(*, field=<django.db.models.fields.DateTimeField: end_datetime>, is_next=True, **kwargs)
get_next_by_start_datetime(*, field=<django.db.models.fields.DateTimeField: start_datetime>, is_next=True, **kwargs)
get_previous_by_end_datetime(*, field=<django.db.models.fields.DateTimeField: end_datetime>, is_next=False, **kwargs)
get_previous_by_start_datetime(*, field=<django.db.models.fields.DateTimeField: start_datetime>, is_next=False, **kwargs)
newslettercontent_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

newslettercontent_ptr_id
penalty_costs

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

price

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

show_costs_warning

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

start_datetime

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

property where

Accessor that fetches the localized variant of where

where_en

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

where_nl

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

class newsletters.models.NewsletterItem(*args, **kwargs)[source]

Bases: newsletters.models.NewsletterContent

Describes one piece of text content of a newsletter

exception DoesNotExist

Bases: newsletters.models.NewsletterContent.DoesNotExist

exception MultipleObjectsReturned

Bases: newsletters.models.NewsletterContent.MultipleObjectsReturned

newslettercontent_ptr

Accessor to the related object on the forward side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Restaurant.place is a ForwardOneToOneDescriptor instance.

newslettercontent_ptr_id

newsletters.services module

newsletters.services.get_agenda(start_date)[source]
newsletters.services.save_to_disk(newsletter, request)[source]

Writes the newsletter as HTML to file (in all languages)

newsletters.services.send_newsletter(newsletter)[source]
newsletters.services.write_to_file(pk, lang, html_message)[source]

Write newsletter to a file

newsletters.urls module

The routes defined by the newsletters package

newsletters.views module

Views provided by the newsletters package

newsletters.views.admin_send(request, pk)[source]

If this is a GET request this view will render a confirmation page for the administrator. If it is a POST request the newsletter will be sent to all recipients

Parameters
  • request – the request object

  • pk – the newsletter’s primary key

Returns

302 RedirectResponse if POST else 200 with the confirmation page HTML

newsletters.views.preview(request, pk, lang=None)[source]

View that renders the newsletter as HTML

Parameters
  • request – the request object

  • pk – the newsletter’s primary key

  • lang – the language of the render

Returns

HttpResponse 200 containing the newsletter HTML