OpenBlock 1.2 documentation

alerts Package

alerts Package

models Module

class ebpub.alerts.models.EmailAlert(*args, **kwargs)

Bases: django.db.models.base.Model

EmailAlert(id, user_id, block_center, location_id, frequency, radius, include_new_schemas, schemas, signup_date, cancel_date, is_active)

Parameters:
  • id (AutoField) -- Id
  • user_id (IntegerField, required) -- User id
  • block_center (PointField) -- Point representing the center of a related block.
  • location (ForeignKey) -- Location
  • frequency (PositiveIntegerField, required) -- How often to send.
  • radius (PositiveIntegerField) -- Radius
  • include_new_schemas (BooleanField) -- If True, schemas should be treated as an exclusion list instead of an inclusion list. This allows people to exclude existing schemas, but still receive updates for new schemas when we add them later.
  • schemas (TextField, required) -- A comma-separated list of schema IDs. Semantics depend on the value of include_new_schemas (see above).
  • signup_date (DateTimeField, required) -- Signup date
  • cancel_date (DateTimeField) -- Cancel date
  • is_active (BooleanField) -- Is active

sending Module

ebpub.alerts.sending.email_for_subscription(alert, start_date, frequency)

Returns a (place_name, text, html) tuple for the given EmailAlert object and date.

ebpub.alerts.sending.email_text_for_place(alert, place, place_name, place_url, news_groups, date, frequency)

Returns a tuple of (text, html) for the given args. text is the text-only e-mail, and html is the HTML version.

ebpub.alerts.sending.send_all(frequency, verbose=False)

Sends an e-mail to all alert subscribers in the system with data with the given frequency (in days).

Note that it does not keep track of already-sent messages, so take care not to call send_all(frequency) more often than frequency days.

views Module