Offers

This package contains all data models related to offers: Document, Language, Offer and OfferVersion.

Document

class integreat_compass.cms.models.offers.document.Document(*args, **kwargs)

Bases: AbstractBaseModel

Data model representing a Language.

Parameters:

Relationship fields:

Parameters:

offer_version (ForeignKey to OfferVersion) – Offer version (related name: documents)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

file

Type: FileField

File

file_size

Type: IntegerField

File size

file_type

Type: CharField

File type

Choices:

  • image/png

  • image/jpeg

  • application/pdf

get_file_type_display(*, field=<django.db.models.CharField: file_type>)

Shows the label of the file_type. See get_FOO_display() for more information.

get_repr()

This overwrites the default Django __repr__() method which would return <MediaFile: Document object (id)>. It is used for logging.

Returns:

The canonical string representation of the document

Return type:

str

id

Type: BigAutoField

Primary key: ID

name

Type: CharField

Name

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

Type: ForeignKey to OfferVersion

Offer version (related name: documents)

offer_version_id

Internal field, use offer_version instead.

url

Returns the URL of the document

Returns:

URL of the document

Return type:

str

integreat_compass.cms.models.offers.document.file_size_limit(value)

This function checks if the uploaded file exceeds the file size limit

Parameters:

value (int) – the size of upload file

Raises:

ValidationError – when the file size exceeds the size given in the settings.

Language

class integreat_compass.cms.models.offers.language.Language(*args, **kwargs)

Bases: AbstractBaseModel

Data model representing a Language.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • native_name (CharField) – Native name. The name of the language in this language

  • english_name (CharField) – Name in English. The name of the language in English

Reverse relationships:

Parameters:

offer_versions (Reverse ForeignKey from OfferVersion) – All offer versions of this language (related name of language)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

english_name

Type: CharField

Name in English. The name of the language in English

get_repr()

This overwrites the default Django __repr__() method which would return <Language: Language object (id)>. It is used for logging.

Returns:

The canonical string representation of the page

Return type:

str

id

Type: BigAutoField

Primary key: ID

native_name

Type: CharField

Native name. The name of the language in this language

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

Type: Reverse ForeignKey from OfferVersion

All offer versions of this language (related name of language)

Offer

class integreat_compass.cms.models.offers.offer.Offer(*args, **kwargs)

Bases: AbstractBaseModel

Data model representing an Offer.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • group_type (CharField) – Group type. Select in what group sizes lessons are offered

  • mode_type (CharField) – Lesson mode. Select in what mode lessons are offered

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

comments

Method to retrieve all comments on an Offer.

Returns:

List of comments together with information on whether the comment was made on the latest offer version

Return type:

list [ dict [ Comment, bool ] ]

creator

Type: ForeignKey to User

Creator (related name: offer)

creator_id

Internal field, use creator instead.

favorite

Type: Reverse ForeignKey from Favorite

All favorite of this offer (related name of offer)

get_group_type_display(*, field=<django.db.models.CharField: group_type>)

Shows the label of the group_type. See get_FOO_display() for more information.

get_mode_type_display(*, field=<django.db.models.CharField: mode_type>)

Shows the label of the mode_type. See get_FOO_display() for more information.

get_repr()

This overwrites the default Django __repr__() method which would return <Offer: Offer object (id)>. It is used for logging.

Returns:

The canonical string representation of the page

Return type:

str

group_type

Type: CharField

Group type. Select in what group sizes lessons are offered

Choices:

  • PRIVATE

  • GROUP

  • BOTH

id

Type: BigAutoField

Primary key: ID

location

Type: ForeignKey to Location

Location (related name: offer)

location_id

Internal field, use location instead.

mode_type

Type: CharField

Lesson mode. Select in what mode lessons are offered

Choices:

  • ONLINE

  • HYBRID

  • IN_PERSON

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

Type: ForeignKey to Contact

Offer contact (related name: offer)

offer_contact_id

Internal field, use offer_contact instead.

organization

Type: ForeignKey to Organization

Organization (related name: offer)

organization_id

Internal field, use organization instead.

public_version

Returns the latest approved version of an offer, it such a version exists.

Returns:

OfferVersion or None

Return type:

OfferVersion

tags

Type: ManyToManyField to Tag

Tags (related name: offer)

versions

Type: Reverse ForeignKey from OfferVersion

All versions of this offer (related name of offer)

Offer Version

class integreat_compass.cms.models.offers.offer_version.OfferVersion(*args, **kwargs)

Bases: AbstractBaseModel

Data model representing a Language.

Parameters:
  • id (BigAutoField) – Primary key: ID

  • offer_version_date (DateTimeField) – Offer version date

  • title (CharField) – Title. Title of this offer

  • description (TextField) – Description. Detailed information about the offer

  • is_free (BooleanField) – Free offer. Whether this offer is free or not

Relationship fields:

Parameters:

Reverse relationships:

Parameters:
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

comments

Type: Reverse ForeignKey from Comment

All comments of this offer version (related name of offer_version)

description

Type: TextField

Description. Detailed information about the offer

documents

Type: Reverse ForeignKey from Document

All documents of this offer version (related name of offer_version)

get_next_by_offer_version_date(*, field=<django.db.models.DateTimeField: offer_version_date>, is_next=True, **kwargs)

Finds next instance based on offer_version_date. See get_next_by_FOO() for more information.

get_previous_by_offer_version_date(*, field=<django.db.models.DateTimeField: offer_version_date>, is_next=False, **kwargs)

Finds previous instance based on offer_version_date. See get_previous_by_FOO() for more information.

get_repr()

This overwrites the default Django __repr__() method which would return <OfferVersion: OfferVersion object (id)>. It is used for logging.

Returns:

The canonical string representation of the page

Return type:

str

id

Type: BigAutoField

Primary key: ID

is_free

Type: BooleanField

Free offer. Whether this offer is free or not

is_initial_version

Check if this offer version is the first version for its corresponding offer.

Returns:

True if this offer version is the first version for its corresponding offer, False otherwise.

Return type:

bool

language

Type: ForeignKey to Language

Language. The language being taught in this offer (related name: offer_versions)

language_id

Internal field, use language instead.

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

Type: ForeignKey to Offer

Offer (related name: versions)

offer_id

Internal field, use offer instead.

offer_version_date

Type: DateTimeField

Offer version date

reports

Type: Reverse ForeignKey from Report

All reports of this offer version (related name of offer_version)

state

Returns the state of the offer version based on the votes cast on it

Returns:

State of the offer version (one of CHOICES)

Return type:

str

title

Type: CharField

Title. Title of this offer

votes

Type: Reverse ForeignKey from Vote

All votes of this offer version (related name of offer_version)

integreat_compass.cms.models.offers.offer_version.get_default_language()

Helper function to get or create the default offer language.

Returns:

pk of the default offer language

Return type:

int

Tag

class integreat_compass.cms.models.offers.tag.Tag(*args, **kwargs)

Bases: AbstractBaseModel

Data model representing a Tag.

Parameters:

Reverse relationships:

Parameters:

offer (Reverse ManyToManyField from Offer) – All offers of this tag (related name of tags)

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

get_repr()

This overwrites the default Django __repr__() method which would return <Tag: Tag object (id)>. It is used for logging.

Returns:

The canonical string representation of the page

Return type:

str

id

Type: BigAutoField

Primary key: ID

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

Type: Reverse ManyToManyField from Offer

All offers of this tag (related name of tags)

title

Type: CharField

Tag. Title of the tag