langacore.kit.django 0.3.3 documentation

This Page

langacore.kit.django.common.models

langacore.kit.django.common.models

Contains a small set of useful abstract model base classes that are not application-specific.

Classes

class Named(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model with a name field.

class Titled(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model with a title field.

class Slugged(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model with a slug field.

class TimeTrackable(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model whose lifecycle is tracked by time. Includes a created field that is set automatically upon object creation and a modified field that is set automatically upon calling save() on the object.

class Localized(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model which holds data in a specified language. The language is chosen from the Language choices class but only from those specified in settings.LANGUAGES. The default value is settings.LANGUAGE_CODE.

class MonitoredActivity(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model which holds the timestamp of last user activity on the site. Activity is logged using the ActivityMiddleware.

is_currently_online(time_limit=120)

True if the user’s last activity was within the last time_limit seconds (default value 2 minutes, customizable by the CURRENTLY_ONLINE_INTERVAL setting.

was_recently_online(time_limit=300)

True if the user’s last activity was within the last time_limit seconds (default value 5 minutes, customizable by the RECENTLY_ONLINE_INTERVAL setting.

class DisplayCounter(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract model which display count can be incremented by calling bump(). Models inheriting from DisplayCounter can define a special bump_save() method which is called instead of the default save() on each bump() (for instance to circumvent updating the modified field if the model is also TimeTrackable.

class SoftDeletable(*args, **kwargs)

Bases: django.db.models.base.Model

Describes an abstract models which can be soft deleted, that is instead of actually removing objects from the database, they have a deleted field which is set to True and the object is then invisible in normal operations (thanks to ViewableSoftDeletableManager).

class ViewableSoftDeletableManager

Bases: django.db.models.manager.Manager

An objet manager to automatically hide objects that were soft deleted for models inheriting SoftDeletable.

class MassMailer(profiles, subject, content, inverval=1.0, force=False)

Bases: threading.Thread

A thread that can be used to mail the specified profiles with a certain message. After every message it waits a specified time (by default a second).