order.py

Functions and request handlers related to orders.

Special permissions are required to access orders:

  • If you have permission DATA_EDIT you have CRUD permissions to your own orders.

  • If you have permission DATA_MANAGEMENT you have CRUD permissions to any orders.

order.add_dataset(identifier: str)[source]

Add a dataset to the given order.

Parameters

identifier (str) – The order to add the dataset to.

order.add_order()[source]

Add an order.

Returns

Json structure with _id of the added order.

Return type

flask.Response

order.delete_order(identifier: str)[source]

Delete the order with the given identifier.

Returns

Status code

Return type

flask.Response

order.get_order(identifier)[source]

Retrieve the order with the provided uuid.

order['datasets'] is returned as [{_id, title}, ...].

Parameters

identifier (str) – Uuid for the wanted order.

Returns

JSON structure for the order.

Return type

flask.Response

order.get_order_logs(identifier)[source]

List changes to the dataset.

Logs will be sorted chronologically.

The data in each log will be trimmed to only show the changed fields.

Parameters

identifier (str) – Uuid for the wanted order.

Returns

Json structure for the logs.

Return type

flask.Response

order.list_orders()[source]

List all orders visible to the current user.

Returns

JSON structure with a list of orders.

Return type

flask.Response

order.prepare()[source]

All order request require DATA_EDIT.

Make sure that the user is logged in and has the required permission.

order.prepare_order_response(order_data: dict, mongodb)[source]

Prepare an order by e.g. converting user uuids to names etc.

Changes are done in-place.

Parameters
  • order_data (dict) – The order entry from the db.

  • mongodb – The mongo database to use.

order.update_order(identifier: str)[source]

Update an existing order.

Parameters

identifier (str) – Order uuid.

Returns

Status code of the request.

Return type

flask.Response