Models¶
- class terminusgps_notifications.models.MessagePackage(id, price, count, max, customer)[source]¶
-
Public Methods:
__str__()Returns 'MessagePackage #<pk>'.
Message package price.
Message package current execution count.
Message package maximum allowed executions.
idA wrapper for a deferred-loading field.
objectsInherited from
Model__init__(*args, **kwargs)from_db(db, field_names, values)__repr__()Return repr(self).
__str__()Return str(self).
__eq__(other)Return self==value.
__hash__()Return hash(self).
__reduce__()Helper for pickle.
__getstate__()Hook to allow choosing the attributes to pickle.
__setstate__(state)get_deferred_fields()Return a set containing names of deferred fields for this instance.
refresh_from_db([using, fields, from_queryset])Reload field values from the database.
arefresh_from_db([using, fields, from_queryset])serializable_value(field_name)Return the value of the field name for this instance.
save(*[, force_insert, force_update, using, ...])Save the current instance.
asave(*[, force_insert, force_update, ...])save_base([raw, force_insert, force_update, ...])Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.
delete([using, keep_parents])adelete([using, keep_parents])prepare_database_save(field)clean()Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.
validate_unique([exclude])Check unique constraints on the model and raise ValidationError if any failed.
date_error_message(lookup_type, field_name, ...)unique_error_message(model_class, unique_check)get_constraints()validate_constraints([exclude])full_clean([exclude, validate_unique, ...])Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model.
clean_fields([exclude])Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
check(**kwargs)Inherited from
AltersData__init_subclass__(**kwargs)This method is called when a class is subclassed.
Private Data Attributes:
_metaPrivate Methods:
Inherited from
Model_get_pk_val([meta])_set_pk_val(value)_is_pk_set([meta])_validate_force_insert(force_insert)_save_parents(cls, using, update_fields, ...)Save all the parents of cls using values from self.
_save_table([raw, cls, force_insert, ...])Do the heavy-lifting involved in saving.
_do_update(base_qs, using, pk_val, values, ...)Try to update the model.
_do_insert(manager, using, fields, ...)Do an INSERT.
_assign_returned_values(returned_values, ...)_prepare_related_fields_for_save(operation_name)_get_FIELD_display(field)_get_next_or_previous_by_FIELD(field, ...)_get_next_or_previous_in_order(is_next)_get_field_expression_map(meta[, exclude])_get_unique_checks([exclude, ...])Return a list of checks to perform.
_perform_unique_checks(unique_checks)_perform_date_checks(date_checks)_check_composite_pk()_check_db_table_comment(databases)_check_swappable()Check if the swapped model exists.
_check_model()_check_managers(**kwargs)Perform all manager checks.
_check_fields(**kwargs)Perform all field checks.
_check_m2m_through_same_relationship()Check if no relationship model is used by more than one m2m field.
_check_id_field()Check if id field is a primary key.
_check_field_name_clashes()Forbid field shadowing in multi-table inheritance.
_check_column_name_clashes()_check_model_name_db_lookup_clashes()_check_property_name_related_field_accessor_clashes()_check_single_primary_key()_check_unique_together()Check the value of "unique_together" option.
_check_indexes(databases)_check_local_fields(fields, option)_check_ordering()Check "ordering" option -- is it a list of strings and do all fields exist?
_check_long_column_names(databases)Check that any auto-generated column names are shorter than the limits for each database in which the model will be created.
_get_expr_references(expr)_check_constraints(databases)
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- customer¶
Associated customer.
- class terminusgps_notifications.models.TerminusgpsNotificationsCustomer(*args, **kwargs)[source]¶
A Terminus GPS Notifications customer.
Public Data Attributes:
user_idDjango user.
subscription_idAssociated subscription.
packagesAccessor to the related objects manager on the reverse side of a many-to-one relation.
tokenAccessor to the related object on the reverse side of a one-to-one relation.
notificationsAccessor to the related objects manager on the reverse side of a many-to-one relation.
Inherited from
ModelpkPublic Methods:
__str__()Returns the customer user's username.
get_units_from_wialon(resource_id, session)Returns a list of of customer Wialon unit dictionaries from the Wialon API.
get_resources_from_wialon(session[, force, ...])Returns a list of of customer Wialon resource dictionaries from the Wialon API.
Company name.
Date format for notifications.
get_date_format_display(*[, field])Subscription tax rate.
Subscription current subtotal.
Subscription tax total.
Subscription grand total (subtotal + tax).
Maximum number of notification executions in a single period.
Maximum base number of notification executions in a single period.
Current number of notification executions this period.
idA wrapper for a deferred-loading field.
objectsInherited from
Model__init__(*args, **kwargs)from_db(db, field_names, values)__repr__()Return repr(self).
__str__()Return str(self).
__eq__(other)Return self==value.
__hash__()Return hash(self).
__reduce__()Helper for pickle.
__getstate__()Hook to allow choosing the attributes to pickle.
__setstate__(state)get_deferred_fields()Return a set containing names of deferred fields for this instance.
refresh_from_db([using, fields, from_queryset])Reload field values from the database.
arefresh_from_db([using, fields, from_queryset])serializable_value(field_name)Return the value of the field name for this instance.
save(*[, force_insert, force_update, using, ...])Save the current instance.
asave(*[, force_insert, force_update, ...])save_base([raw, force_insert, force_update, ...])Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.
delete([using, keep_parents])adelete([using, keep_parents])prepare_database_save(field)clean()Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.
validate_unique([exclude])Check unique constraints on the model and raise ValidationError if any failed.
date_error_message(lookup_type, field_name, ...)unique_error_message(model_class, unique_check)get_constraints()validate_constraints([exclude])full_clean([exclude, validate_unique, ...])Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model.
clean_fields([exclude])Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
check(**kwargs)Inherited from
AltersData__init_subclass__(**kwargs)This method is called when a class is subclassed.
Private Data Attributes:
_metaPrivate Methods:
Inherited from
Model_get_pk_val([meta])_set_pk_val(value)_is_pk_set([meta])_validate_force_insert(force_insert)_save_parents(cls, using, update_fields, ...)Save all the parents of cls using values from self.
_save_table([raw, cls, force_insert, ...])Do the heavy-lifting involved in saving.
_do_update(base_qs, using, pk_val, values, ...)Try to update the model.
_do_insert(manager, using, fields, ...)Do an INSERT.
_assign_returned_values(returned_values, ...)_prepare_related_fields_for_save(operation_name)_get_FIELD_display(field)_get_next_or_previous_by_FIELD(field, ...)_get_next_or_previous_in_order(is_next)_get_field_expression_map(meta[, exclude])_get_unique_checks([exclude, ...])Return a list of checks to perform.
_perform_unique_checks(unique_checks)_perform_date_checks(date_checks)_check_composite_pk()_check_db_table_comment(databases)_check_swappable()Check if the swapped model exists.
_check_model()_check_managers(**kwargs)Perform all manager checks.
_check_fields(**kwargs)Perform all field checks.
_check_m2m_through_same_relationship()Check if no relationship model is used by more than one m2m field.
_check_id_field()Check if id field is a primary key.
_check_field_name_clashes()Forbid field shadowing in multi-table inheritance.
_check_column_name_clashes()_check_model_name_db_lookup_clashes()_check_property_name_related_field_accessor_clashes()_check_single_primary_key()_check_unique_together()Check the value of "unique_together" option.
_check_indexes(databases)_check_local_fields(fields, option)_check_ordering()Check "ordering" option -- is it a list of strings and do all fields exist?
_check_long_column_names(databases)Check that any auto-generated column names are shorter than the limits for each database in which the model will be created.
_get_expr_references(expr)_check_constraints(databases)
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- get_resources_from_wialon(session: ~terminusgps.wialon.session.WialonSession, force: bool = False, flags: int = <DataFlag.RESOURCE_BASE: 1>, start: int = 0, end: int = 0) list[dict[str, Any]][source]¶
Returns a list of of customer Wialon resource dictionaries from the Wialon API.
Default Wialon resource dictionary format (flags=1):
key
type
desc
"mu"Measurement system
"nm"Resource name
"cls"Superclass ID: ‘avl_resource’
"id"Resource ID
"uacl"User’s access rights
- Parameters:
- Returns:
A list of Wialon resource dictionaries.
- Return type:
- get_units_from_wialon(resource_id: str | int, session: ~terminusgps.wialon.session.WialonSession, items_type: str = 'avl_unit', force: bool = False, flags: int = <DataFlag.RESOURCE_BASE: 1>, start: int = 0, end: int = 0) list[dict[str, Any]][source]¶
Returns a list of of customer Wialon unit dictionaries from the Wialon API.
Default Wialon unit dictionary format (flags=1):
key
type
desc
"mu"Measurement system
"nm"Unit name
"cls"Superclass ID: ‘avl_unit’
"id"Unit ID
"uacl"User’s access rights
- Parameters:
- Raises:
ValueError – If
resource_idwas a string and contained non-digit characters.- Returns:
A list of Wialon unit dictionaries.
- Return type:
- messages_max¶
Maximum number of notification executions in a single period. Default is
500.- Type:
- messages_max_base¶
Maximum base number of notification executions in a single period. Default is
500.- Type:
- subscription¶
Associated subscription. Optional.
- Type:
terminusgps_payments.models.Subscription | None
- user¶
Django user.
- Type:
- class terminusgps_notifications.models.WialonToken(*args, **kwargs)[source]¶
Wialon API token.
Public Methods:
__str__()Returns '<customer email>'s WialonToken'.
Encrypted Wialon API token name.
Wialon token flags.
idA wrapper for a deferred-loading field.
objectsInherited from
Model__init__(*args, **kwargs)from_db(db, field_names, values)__repr__()Return repr(self).
__str__()Return str(self).
__eq__(other)Return self==value.
__hash__()Return hash(self).
__reduce__()Helper for pickle.
__getstate__()Hook to allow choosing the attributes to pickle.
__setstate__(state)get_deferred_fields()Return a set containing names of deferred fields for this instance.
refresh_from_db([using, fields, from_queryset])Reload field values from the database.
arefresh_from_db([using, fields, from_queryset])serializable_value(field_name)Return the value of the field name for this instance.
save(*[, force_insert, force_update, using, ...])Save the current instance.
asave(*[, force_insert, force_update, ...])save_base([raw, force_insert, force_update, ...])Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.
delete([using, keep_parents])adelete([using, keep_parents])prepare_database_save(field)clean()Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.
validate_unique([exclude])Check unique constraints on the model and raise ValidationError if any failed.
date_error_message(lookup_type, field_name, ...)unique_error_message(model_class, unique_check)get_constraints()validate_constraints([exclude])full_clean([exclude, validate_unique, ...])Call clean_fields(), clean(), validate_unique(), and validate_constraints() on the model.
clean_fields([exclude])Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
check(**kwargs)Inherited from
AltersData__init_subclass__(**kwargs)This method is called when a class is subclassed.
Private Data Attributes:
_metaPrivate Methods:
Inherited from
Model_get_pk_val([meta])_set_pk_val(value)_is_pk_set([meta])_validate_force_insert(force_insert)_save_parents(cls, using, update_fields, ...)Save all the parents of cls using values from self.
_save_table([raw, cls, force_insert, ...])Do the heavy-lifting involved in saving.
_do_update(base_qs, using, pk_val, values, ...)Try to update the model.
_do_insert(manager, using, fields, ...)Do an INSERT.
_assign_returned_values(returned_values, ...)_prepare_related_fields_for_save(operation_name)_get_FIELD_display(field)_get_next_or_previous_by_FIELD(field, ...)_get_next_or_previous_in_order(is_next)_get_field_expression_map(meta[, exclude])_get_unique_checks([exclude, ...])Return a list of checks to perform.
_perform_unique_checks(unique_checks)_perform_date_checks(date_checks)_check_composite_pk()_check_db_table_comment(databases)_check_swappable()Check if the swapped model exists.
_check_model()_check_managers(**kwargs)Perform all manager checks.
_check_fields(**kwargs)Perform all field checks.
_check_m2m_through_same_relationship()Check if no relationship model is used by more than one m2m field.
_check_id_field()Check if id field is a primary key.
_check_field_name_clashes()Forbid field shadowing in multi-table inheritance.
_check_column_name_clashes()_check_model_name_db_lookup_clashes()_check_property_name_related_field_accessor_clashes()_check_single_primary_key()_check_unique_together()Check the value of "unique_together" option.
_check_indexes(databases)_check_local_fields(fields, option)_check_ordering()Check "ordering" option -- is it a list of strings and do all fields exist?
_check_long_column_names(databases)Check that any auto-generated column names are shorter than the limits for each database in which the model will be created.
_get_expr_references(expr)_check_constraints(databases)
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- customer¶
Associated customer.
- class terminusgps_notifications.models.WialonNotification(*args, **kwargs)[source]¶
Wialon notification.
- exception DoesNotExist¶
- exception MultipleObjectsReturned¶
- exception NotUpdated¶
- get_data_from_wialon(session: WialonSession) dict[str, Any][source]¶
Returns the notification data from Wialon using the Wialon API.
Notification data format:
key
type
desc
"id"Notification ID
"n"Notification name
"txt"Notification text
"ta"Activation time (UNIX timestamp)
"td"Deactivation time (UNIX timestamp)
"ma"Maximum number of alarms (0 = unlimited)
"mmtd"Maximum time interval between messages (sec)
"cdt"Alarm timeout (sec)
"mast"Minimum duration of the alarm state (sec)
"mpst"Minimum duration of previous state (sec)
"cp"Control period relative to current time (sec)
"fl"Notification flags
"tz"Notification timezone
"la"Notification language code
"ac"Alarms count
"d"Notification description
"sch"Notification schedule (see below)
"ctrl_sch"Notification control schedule (see below)
"un"List of unit/unit group IDs
"act"List of notification actions (see below)
"trg"Notification trigger (see below)
"ct"Creation time (UNIX timestamp)
"mt"Last modification time (UNIX timestamp)
Notification schedule/control schedule format:
key
type
desc
"f1"Beginning of interval 1 (minutes from midnight)
"f2"Beginning of interval 2 (minutes from midnight)
"t1"End of interval 1 (minutes from midnight)
"t2"End of interval 2 (minutes from midnight)
"m"Mask of the days of the month (1: 20, 31: 230)
"y"Mask of months (Jan: 20, Dec: 211)
"w"Mask of days of the week (Mon: 20, Sun: 26)
"f"Schedule flags
Notification action format (each item in the
actlist):key
type
desc
"t"Action type
"p"Action parameters
Notification trigger format:
key
type
desc
"t"Trigger type
"p"Trigger parameters
- get_resource_name(session: WialonSession) str[source]¶
Returns the Wialon resource name.
- Parameters:
session (WialonSession) – A valid Wialon API session.
- Returns:
The Wialon resource name.
- Return type:
- get_wialon_parameters(call_mode: str) dict[str, Any][source]¶
Returns parameters for Wialon notification API calls.
- save(**kwargs) None[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.
- update_in_wialon(call_mode: WialonNotificationUpdateCallModeType, session: WialonSession) dict[str, Any][source]¶
Updates the notification in Wialon.
- Parameters:
call_mode (WialonNotificationUpdateCallMode) – Call mode to use when calling
resource/update_notification.session (WialonSession) – A valid Wialon API session.
- Raises:
WialonAPIError – If something went wrong calling the Wialon API.
- Returns:
A dictionary of notification data.
- Return type:
- actions¶
Actions.
- activations¶
Activation count.
- alarm_timeout¶
Alarm timeout in seconds. Default is
0. Max is1800(30 minutes in seconds).- Type:
- control_period¶
Control period relative to current time in seconds. Default is
3600.Options are:
value
desc
0Any time
60Last minute
600Last 10 minutes
3600Last hour
86400Last day
- control_schedule¶
Control schedule.
- customer¶
Associated customer.
- date_created¶
Date created.
- enabled¶
Whether the notification is enabled in Wialon.
- flags¶
Flags. Default is
0.Options are:
value
desc
0Trigger on first message
1Trigger on every message
2Disabled
- max_message_interval¶
Max time interval between messages. Default is
3600.Options are:
value
desc
0Any time
601 minute
60010 minutes
180030 minutes
36001 hour
216006 hours
4320012 hours
864001 day
86400010 days
- Type:
- method¶
Notification method. Default is
"sms".Options are:
value
desc
"sms"Deliver via SMS
"voice"Deliver via TTS voice
- Type:
- min_duration_alarm¶
Minimum duration of alarm state in seconds. Default is
0. Max is86400(1 day).
- min_duration_prev¶
Minimum duration of previous state in seconds. Default is
0. Max is86400(1 day).- Type:
- resource_id¶
Resource id.
- resource_name¶
Resource name.
- schedule¶
Schedule.
- text¶
Text.
- timezone¶
Timezone.
- trigger_parameters¶
Trigger parameters.
- trigger_type¶
Trigger type.
- unit_list¶
List of Wialon units.
- wialon_id¶
Wialon id.