An Observation represents an entry contributed by a user. Together with a Location, an observations forms a contribution.
| Parameter | Type | Description |
|---|---|---|
id |
int | Identifies the observation in the database. |
location |
Location | Geographic location of the observation. |
project |
Project | Project the observation has been contributed to. |
category |
Category | Category of the observation. |
status |
string | Status of the observation. Must be one of active, draft review, pending, deleted. Defaults to the default_status of the contributions category. |
properties |
dict | Key-value pairs of the observation’s attributes. Keys represent the key of the category’s fields. |
created_at |
datetime | Date and time when the observation was created. |
creator |
User | User who created the observation. |
updated_at |
datetime | Date and time when the observation last updated. |
updator |
User | User who last updated the observation. |
version |
int | Version of the observation. Is increased every time the observation is updated. |
validate_partial(category, data)Partially validates data against the category. A partial validation only validates against those fields that are present in data; if a field that is required is not provided it will be ignored. This method should be used to validate drafts only.
from geokey.contributions.models import Observation
data = {
'name': 'Buckingham Palace',
'built-in': 1703
}
Contribution.validate_partial(category, data)
validate_full(category, data)Validates the data against all fields defined for the category.
from geokey.contributions.models import Observation
data = {
'name': 'Buckingham Palace',
'built-in': 1703
}
Contribution.validate_full(category, data)
update(properties, updator, status=None)Updates the properties of the Contribution.
Observation
delete()Deletes the contribution by setting its status to deleted.
Observation.create(properties=None, creator=None, location=None, category=None, project=None, status=None)Observation
Returns all observations for moderators; That includes all observations in a project; except this with status='draft', which where not created by the given user.
django.db.models.query.QuerySet: List of Observation
project.observations.for_moderator(user)
Returns all observations for viewer, i.e. users who have no moderation permissions on the project.
If the user is anonymous, it returns only observations with status='active' and status='review'
If the user is not anonymous, it returns it returns only observations with status='active' and status='review' as well as status='pending' when the given user is creator of those observation.
django.db.models.query.QuerySet: List of Observation
project.observations.for_viewer(user)
Returns a subset of the QuerySet containing observations where one of the properties matches the given query.
django.db.models.query.QuerySet: List of Observation
project.observations.search('Palace')