Models

Organisation

class viitata.models.Organisation(*args, **kwargs)

An Organisation is an entity that will deal with referrals. Organisations will accept referrals matching a defined criteria. Criteria include:

  • accepting referrals from defined organisations
  • accepting referrals from defined local authorities
  • accepting referrals associated with defined issues
  • accepting referrals associated with defined secondary issues
  • accepting referrals associated with defined genders

An organisation can define their contact information that will be available to other users of the referral system.

parent

Parent organisation of the organisation.

address

Address of the organisation.

name

Name of the organisation.

phone_number

Phone number for the organisation.

website

Website URL for an organisation.

description

Organisation description.

criteria

Organisation criteria.

alert

Organisation alert.

service_offer

The service offerings that this organisation provides.

skype

An organisations Skype details.

Organisation logo.

contact_email

Organisation contact email.

active

Whether the organisation is currently active.

accepts_referrals

Whether the organisation is accepting referrals.

accepts_referrals_from

List of organisations that the organisation accepts referrals from. When the list is empty this infers that the organisation accepts referrals from all organisations.

accepted_issues

List of issues that the organisation will accept referrals for. When the list is empty this infers that all issues will be accepted.

accepted_secondary_issues

List of secondary issues that the organisation will accept referrals for. When the list is empty this infers that all issues will be accepted.

local_authorities

List of local authorities that the organisation will accept referrals for. When the list is empty this infers that referrals from all local authorities are accepted by this organisation.

genders

List of genders that the organisation will accept referrals for, When the list is empty this infers that referrals for all genders are accepted by the organisation.

minimum_age

the minimum age that referrals are accepted. When this is blank it infers that there is no minimum limit.

maximum_age

the maximum age that referrals are accepted. When this is blank it infers that there is no maximum limit.

location_longitude

the latitude location of the organisation.

location_latitude

the longitude location of the organisation.

tags = <taggit.managers._TaggableManager object>

tags associated with this organisation.

descriptive_name

Property used to show the name of the parent with the name with a dash in the middle. :returns: a more descriptive name for the organisation includes the parent organisation when available. :rtype: string

property accepting_referrals
Returns:whether the organisation is active and accepts referrals at present.
Return type:bool
property accepts_referrals_from_all_organisations
Returns:whether the organisation accepts referrals from all organisations.
Return type:bool
exception DoesNotExist
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception MultipleObjectsReturned
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

clean()

perform model validations on save:

  • validate minimum and maximum ages.
clean_fields(exclude=None)

Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.

full_clean(exclude=None, validate_unique=True)

Call clean_fields(), clean(), and validate_unique() on the model. Raise a ValidationError for any errors that occur.

get_deferred_fields()

Return a set containing names of deferred fields for this instance.

refresh_from_db(using=None, fields=None)

Reload field values from the database.

By default, the reloading happens from the database this instance was loaded from, or by the read router if this instance wasn’t loaded from any database. The using parameter will override the default.

Fields can be used to specify which fields to reload. The fields should be an iterable of field attnames. If fields is None, then all non-deferred fields are reloaded.

When accessing deferred fields of an instance, the deferred loading of the field will call this method.

save(*args, **kwargs)

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.

save_base(raw=False, force_insert=False, force_update=False, using=None, update_fields=None)

Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too. This includes some sanity checks and signal sending.

The ‘raw’ argument is telling save_base not to save any parent models and not to do any changes to the values before save. This is used by fixture loading.

save_without_historical_record(*args, **kwargs)

Save model without saving a historical record

Make sure you know what you’re doing before you use this method.

serializable_value(field_name)

Return the value of the field name for this instance. If the field is a foreign key, return the id value instead of the object. If there’s no Field object with this name on the model, return the model attribute’s value.

Used to serialize a field’s value (in the serializer, or form output, for example). Normally, you would just access the attribute directly and not use this method.

set_audit_trails()

Set the appropriate user in the audit trail fields.

If created_by and created_at are null then it will use the updated by equivalents. This is to allow code to only have to set updated attributes, as on object creation updated and created must be by definition the same.

The operation can be primarily set using the obj.set_updated_by property. If this is not set then https://github.com/PaesslerAG/django-currentuser will look for the current user that has previously been set on the local thread.

Finally, if none of these are available, then a system (robot) user will be defined as per the result of get_robot_user().

Returns:None
classmethod update_all_search_vectors()

convenience method to update all the search vectors at once for the model.

update_search_vectors(*args, **kwargs)

update search vectors by building up the annotation kwargs - some models may use search_vector_fields, single_search_vector_field or both.

validate_unique(exclude=None)

Check unique constraints on the model and raise ValidationError if any failed.

validate_minimum_maximum_ages()

validate minimum age less than or equal maximum age.

property min_date_of_birth

minimum date of birth that is available.

Returns:minimum date of birth based on the minimum age defined by the organisation.
Return type:date
property max_date_of_birth

maximum date of birth that is available.

Returns:maximum date of birth based on the maximum age defined by the organisation.
Return type:date
property logo_signed_url

get signed url for logo.

Returns:URL to logo when a logo has been uploaded. None when no logo is available.
Return type:url / None