loefsys.events.models.event module

In this module, the models for events are defined.

class loefsys.events.models.event.OverwriteStorage(*args, **kwargs)

Bases: FileSystemStorage

Custom storage class that overwrites files with the same name.

Needed because when a user uploads a new profile picture, the old one would otherwise still be present together with the new one that gets renamed.

get_available_name(name, max_length=None)

Given the desired name, derive and return a name that is available.

class loefsys.events.models.event.Event(*args, **kwargs)

Bases: Model Extensions, Model Extensions

Model for an event.

An event is an activity that people can sign up for. This can be a sail training, a cantus, or any other activity that is organized for the association. Events have many properties, such as a start and end date, a category, a price, a location, and more.

created

The timestamp of the creation of the model, automatically generated upon creation.

Type:

datetime

modified

The timestamp of last modification of this model, automatically generated upon update.

Type:

datetime

title

The title to display for the event.

Type:

str

description

An optional description of the event.

Type:

str, None

picture

The picture for an event.

Type:

ImageFieldFile

slug

A slug for the URL of the event, automatically generated from the title.

Type:

str

start

The start date and time of the event.

Type:

datetime

end

The end date and time of the event.

Type:

datetime

registration_start

The start date and time of the registration window

Type:

datetime

registration_deadline

The end date and time of the registration window

Type:

datetime

cancelation_deadline

The end date and time of the cancelation window

Type:

datetime

category

The category of the event.

Type:

EventCategories

capacity

The maximum number of participants if there is one

Type:

Integer

price

The price.

Type:

Decimal

fine

The fine if a participant does not show up.

Type:

Decimal

location

The location of the event.

We might want to include a Google Maps widget showing the location. django-google-maps might be useful for this.

Type:

str

is_open_event

Flag to determine if non-members can register.

Type:

bool

published

Flag to determine if the event is publicly visible.

Type:

bool

send_cancel_email

Flag to determine if an email should be sent if a participant deregisters

Type:

~bool

eventregistration_set

A manager of registrations for this event.

It is the one-to-many relationship to EventRegistration.

Type:

EventRegistrationManager

event_picture_upload_path(_)

Return the upload path for the event picture.

picture

Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.

start

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

end

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

registration_start

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

registration_deadline

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

cancelation_deadline

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

category

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

capacity

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.

fine

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

location

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

is_open_event

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

published

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

send_cancel_email

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

property has_form_fields: bool

Check if the event has associated form fields.

Returns:

True if the event has form fields, otherwise False.

Return type:

bool

eventregistration_set: EventRegistrationManager

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 = <loefsys.events.models.managers.EventManager object>
property url: str

Url for the event.

get_absolute_url()

Return the detail page url for this registration.

mandatory_registration() bool

Check whether this event has mandatory registration.

Returns:

A boolean that defines whether registration is mandatory.

Return type:

bool

registrations_open() bool

Determine whether it is possible for users to register for this event.

Returns:

A boolean that defines whether registrations are open.

Return type:

bool

max_capacity_reached() bool

Check whether the max capacity for this event is reached.

Returns:

True when the event is full and False if there are places available.

Return type:

bool

fine_on_cancellation() bool

Check whether the cancellation of a registration will result in a fine.

Returns:

True when a fine will be applied and False when cancellation is free of charge.

Return type:

bool

process_cancellation() None

Process the side effects for an event of a cancellation.

Return type:

None

registration_window_open() bool

Determine whether it is possible for users to register for this event.

For events with required registration, registration is only possible when the event is published and in the registration window defined by start and end.

Returns:

A boolean that defines whether registrations are in the registration window.

Return type:

bool

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

created

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

description

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

eventorganizer

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.

get_category_display(*, field=<django.db.models.fields.PositiveSmallIntegerField: category>)
get_next_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=True, **kwargs)
get_next_by_end(*, field=<django.db.models.fields.DateTimeField: end>, is_next=True, **kwargs)
get_next_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=True, **kwargs)
get_next_by_start(*, field=<django.db.models.fields.DateTimeField: start>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=False, **kwargs)
get_previous_by_end(*, field=<django.db.models.fields.DateTimeField: end>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=False, **kwargs)
get_previous_by_start(*, field=<django.db.models.fields.DateTimeField: start>, is_next=False, **kwargs)
get_registrationformfield_order()
id

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

modified

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

registrationformfield_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.

set_registrationformfield_order(id_list, using=None)
slug

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

title

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

class loefsys.events.models.event.EventOrganizer(*args, **kwargs)

Bases: Model Extensions

Utility model collecting the organizers for an event.

created

The timestamp of the creation of the model, automatically generated upon creation.

Type:

datetime

modified

The timestamp of last modification of this model, automatically generated upon update.

Type:

datetime

event

The event that the current organizer organizes.

Type:

Event

groups

The groups organizing this event.

Type:

QuerySet of LoefbijterGroup

user

Individuals organizing this event.

Type:

QuerySet of User

event

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.

groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

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

user

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

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

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

created

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

event_id
get_next_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django_extensions.db.fields.CreationDateTimeField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<django_extensions.db.fields.ModificationDateTimeField: modified>, is_next=False, **kwargs)
id

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

modified

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

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