A category is represents a data type in GeoKey. Each contribution has a category that defines “what” that contribution is. A set of fields is assigned to each category that structure the data that is being collected for contributions of a category.
Parameter | Type | Description |
---|---|---|
id |
int | Identifies the category in the database. |
name |
string | Short title of the category. |
description |
string | Longer description about the category. |
project |
Project | The project this category is assigned to. |
created_at |
datetime | Date and time when the category was created. |
creator |
User | The user who created the category |
order |
int | Position at which the category should be displayed in the list of the project’s categories. |
status |
string | Current status of the category, must be one of active , inactive or deleted . Defaults to active . |
display_field |
Field | Field that is used to display contributions in a list. That field should be a descriptive field, such as a name. |
expiry_field |
Field | Field that is used to set the expiry date for contributions. |
default_status |
string | Default status that is assigned to all contributions of that category when they are created. Must be one of active or pending . Defaults to pending . |
colour |
string | Hex code defining the colour that is used to display contributions of that category on the map. |
symbol |
File | An image file that is used to display contributions of that category on the map. |
fields |
QuerySet | List of fields assigned to this category. |
re_order_fields(order)
Re-orders the fields of the category according to the order provided. order
is a list of field ids.
category.re_order_fields([1, 3, 10, 2])
delete()
Deletes the category by setting its status to deleted
.
Category.objects.create(
name='Category',
description='This is a category',
project=project,
creator=user,
default_status='active',
colour='#fff000',
symbol=file
)
get_list(user, project_id)
Returns a list of categories for a project that the user can access.
django.db.models.query.QuerySet: List of Categories
get_single(user, project_id, category_id)
Returns a single category.
as_admin(user, project_id, category_id)
Returns a single category if the user is admin of the project.