Programming API Project

Navigate

    A project in GeoKey represents a single mapping activity.

    Attributes

    Parameter Type Description
    id int Identifies the project in the database.
    name string Short title of the project.
    description string Longer description about the project.
    isprivate boolean Indicates if the project is private
    created_at datetime Date and time when project was created.
    creator User User who created the project.
    everyone_contributes string Indicates if all users, who have access to the project, can also contribute. Must be one of true (all users can contribute), auth (all user can contribute, but they have to be authenticated), false (only members of user groups with contribution rights can contribute).
    status string Status of the project, must be one of active, inactive, deleted. Defaults to active.
    geographic_extend geometry The geographic extent of the project. You can use it on client side to zoom the map to this extent.
    categories QuerySet List of categories assigned to the project
    observations QuerySet List of observations assigned to the project

    Methods

    delete()

    Deletes the project by setting its status to deleted.

    re_order_categories(order)

    Re-orders the categories of the project according to the order provided. order is a list of category ids.

    Parameters
    order: list
    List of category ids, in the desired order.
    Example
        project.re_order_categories([1, 3, 10, 2])
    

    get_role(user)

    Returns a human readable terms of the user’s role on the project

    Parameters
    order: User
    The user who's role is returned.
    Returns

    string

    is_admin(user)

    Returns true if the user is member of the administrators user group.

    Parameters
    order: User
    User that is examined.
    Returns

    boolean

    can_access(user)

    Returns true if the user has access to the project, i.e.:

    • the user is member of the administrators group
    • the user is member of one of the user groups
    • the project is public and has at least one public data grouping
    Parameters
    order: User
    User that is examined.
    Returns

    boolean

    can_contribute(user)

    Returns true if the user is member of at least one user group that has contributor rights.

    Parameters
    order: User
    User that is examined.
    Returns

    boolean

    can_moderate(user)

    Returns true if the user is member of at least one user group that has moderator rights.

    Parameters
    order: User
    User that is examined.
    Returns

    boolean

    is_involved(user)

    Returns true if the user is member of at least one user group.

    Parameters
    order: User
    User that is examined.
    Returns

    boolean

    get_all_contributions(user, search=None, subset=None)

    Returns all contributions in a project that the user can access. If either search or subset are given the query set will be filtered accordingly.

    Parameters
    user: User
    User for whom the contributions are returned.
    search: str
    Optional. A free-text search query. Contributions will be filtered agains the term.
    subset: int
    Optional. The ID of a subset that should be used to filter the data. </dl> ##### Returns django.db.models.query.QuerySet: List of [Observations](/docs/programming/observation.html) ### Creating a model instance #### `Project.create(name, description, isprivate, everyone_contributes, creator)` ##### Parameters
    name: string
    Title for the project.
    description: string
    A long-form description for the project
    isprivate: boolean
    Indicates if the project should be hidden from the public
    everyone_contributes: string
    Indicates if all users, who have access to the project, can also contribute.
    Must be one of:
    - true — all users can contribute
    - auth — all user can contribute, but they have to be authenticated
    - false — only members of user groups with contribution rights can contribute.
    user: User
    User, who creates the project.
    ##### Returns Project ### Accessing model instances #### `get_list(user)` Returns a list of all projects the user can access. ##### Parameters
    user: User
    User the projects are queried for.
    ##### Returns django.db.models.query.QuerySet: List of [Projects](/docs/programming/project.html) ##### Example use ```python from geokey.projects.models import Project Project.objects.get_list(user) ``` #### `get_single(user, project_id)` Returns a single project, if the user can access it. ##### Parameters
    user: User
    User the project is queried for.
    project_id: integer
    Identifies the project in the database.
    ##### Returns Project ##### Raises
    Project.DoesNotExist
    If the project was not found in the data base or if the user can not access the project.
    ##### Example use ```python from geokey.projects.models import Project Project.objects.get_single(user, 12) ``` #### `as_admin(user, project_id)` Returns a single project, if the user is administrator of the project. ##### Parameters
    user: User
    User the project is queried for.
    project_id: integer
    Identifies the project in the database.
    ##### Returns Project ##### Raises
    Project.DoesNotExist
    If the project was not found in the database or if the user can not access the project.
    PermissionDenied
    If the user is not member of the administrator group.
    ##### Example use ```python from geokey.projects.models import Project Project.objects.as_admin(user, 12) ``` #### `as_contributor(user, project_id)` Returns a single project, if the user is contributor of the project. ##### Parameters
    user: User
    User the project is queried for.
    project_id: integer
    Identifies the project in the database.
    ##### Returns Project ##### Raises
    Project.DoesNotExist
    If the project was not found in the database or if the user can not access the project.
    PermissionDenied
    If the user is not member of any user group that has contributing rights.
    ##### Example use ```python from geokey.projects.models import Project Project.objects.as_contributor(user, 12) ```