Autodocumentation of the Resources module

Models

Resource models.

class concord.resources.models.Comment(*args, **kwargs)

Comment model.

exception DoesNotExist
exception MultipleObjectsReturned
get_name()

Gets name of Model. By default, gets string representation.

class concord.resources.models.CommentCatcher(*args, **kwargs)

The comment catcher model is a hack to deal with leaving comments on non-permissioned models. Right now, the only model we’re doing this for is Action.

exception DoesNotExist
exception MultipleObjectsReturned
get_name()

Get name of object.

class concord.resources.models.Item(*args, **kwargs)

Simple item model.

Will eventually be removed when more usable resource is added.

exception DoesNotExist
exception MultipleObjectsReturned
get_name()

Get name of item.

class concord.resources.models.Resource(*args, **kwargs)

Simple resource model.

Will eventually be removed when a more usable resource is added.

exception DoesNotExist
exception MultipleObjectsReturned
get_items() → List[str]

Gets item associated with resource.

get_name()

Gets name of abstract resource.

get_nested_objects()

Get objects that Resource is nested on, in this case the owner.

class concord.resources.models.SimpleList(*args, **kwargs)

Model to store simple lists with arbitrary fields.

exception DoesNotExist
exception MultipleObjectsReturned
add_row(row, index=None)

Add a row to the list.

adjust_rows_to_new_configuration(configuration)

Given a new row configuration, goes through existing rows and adjusts them them.

check_row_against_configuration(row)

Given a row, check that it’s valid for the row configuration.

delete_row(index)

Delete a row from the list.

edit_row(row, index)

Edit a row in the list.

get_name()

Get name of item.

get_nested_objects()

Get models that permissions for this model might be set on.

get_row_configuration()

Gets row configuation json and loads to Python dict.

get_rows()

Get the rows in the list.

handle_missing_fields_and_values(row)

Given a row, check that it’s valid for the row configuration.

move_row(old_index, new_index)

Moves a row from old index to new index.

set_row_configuration(row_configuration)

Given a row configuration with format, validated and saves to DB.

validate_configuration(row_configuration)

Checks that a given configuration is valid. Should have format:

{ field_name : { ‘required’: True, ‘default_value’: ‘default’}}

If required is not supplied, defaults to False. If default_value is not supplied, defaults to None.

State Changes

Resource State Changes

class concord.resources.state_changes.AddCommentStateChange(text, original_creator_only=False)

State Change to add a comment.

classmethod check_configuration_is_valid(configuration)

Used primarily when setting permissions, this method checks that the supplied configuration is a valid one. By contrast, check_configuration checks a specific action against an already-validated configuration.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_configurable_fields()

Gets the fields of a change object which may be configured when used in a Permission model.

implement(actor, target)

Method that carries out the change of state.

input_target

alias of concord.resources.models.Comment

class concord.resources.state_changes.AddItemStateChange(name)

State Change to add item to a resource.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

An AddItem permission can be set on an item, a resource, or on the community that owns the item or resource.

implement(actor, target)

Method that carries out the change of state.

input_target

alias of concord.resources.models.Item

class concord.resources.state_changes.AddListStateChange(name, configuration, description=None)

State Change to create a list in a community (or other target).

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

implement(actor, target)

Method that carries out the change of state.

input_target

alias of concord.resources.models.SimpleList

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.AddRowStateChange(row_content, index=None)

State Change to add a row to a list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.ChangeResourceNameStateChange(name)

State Change to change a resource name.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

class concord.resources.state_changes.DeleteCommentStateChange(commenter_only=False, original_creator_only=False)

State Change to delete a comment.

classmethod check_configuration_is_valid(configuration)

Used primarily when setting permissions, this method checks that the supplied configuration is a valid one. By contrast, check_configuration checks a specific action against an already-validated configuration.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_configurable_fields()

Gets the fields of a change object which may be configured when used in a Permission model.

classmethod get_configured_field_text(configuration)

Gets additional text for permissions item instance descriptions from configured fields.

get_context_instances(action)

Returns the comment and the commented object. Also returns the commented object by its model name, to handle cases where the referer knows the model type vs doesn’t know the model type.

classmethod get_settable_classes()

Comments may be made on any target - it’s up to the front end to decide what comment functionality to expose to the user.

implement(actor, target)

Method that carries out the change of state.

class concord.resources.state_changes.DeleteListStateChange

State Change to delete an existing list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

class concord.resources.state_changes.DeleteRowStateChange(index)

State Change to delete a row in a list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.EditCommentStateChange(text, commenter_only=False, original_creator_only=False)

State Change to edit a comment.

classmethod check_configuration_is_valid(configuration)

Used primarily when setting permissions, this method checks that the supplied configuration is a valid one. By contrast, check_configuration checks a specific action against an already-validated configuration.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_configurable_fields()

Gets the fields of a change object which may be configured when used in a Permission model.

classmethod get_configured_field_text(configuration)

Gets additional text for permissions item instance descriptions from configured fields.

get_context_instances(action)

Returns the comment and the commented object. Also returns the commented object by its model name, to handle cases where the referer knows the model type vs doesn’t know the model type.

classmethod get_settable_classes()

Comments may be made on any target - it’s up to the front end to decide what comment functionality to expose to the user.

implement(actor, target)

Method that carries out the change of state.

class concord.resources.state_changes.EditListStateChange(name=None, configuration=None, description=None)

State Change to edit an existing list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.EditRowStateChange(row_content, index)

State Change to edit a row in a list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.MoveRowStateChange(old_index, new_index)

State Change to move a row in a list.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

validate(actor, target)

Method to check whether the data provided to a change object in an action is valid for the change object. Optional exclude_fields tells us not to validate the given field.

class concord.resources.state_changes.RemoveItemStateChange

State Change to remove item from a resource.

description_past_tense()

Returns the description of the state change object, in past tense.

description_present_tense()

Returns the description of the state change object, in present tense.

classmethod get_allowable_targets()

Returns the classes that an action of this type may target.

classmethod get_settable_classes()

Returns the classes that a permission with this change type may be set on. This overlaps with allowable targets, but also includes classes that allowable targets may be nested on. Most likely called by the validate method in AddPermissionStateChange.

implement(actor, target)

Method that carries out the change of state.

Client

Client for Resources.

class concord.resources.client.CommentClient(actor=None, target=None)

Client for interacting with Comment model.

add_comment(text)

Add a comment to the target.

delete_comment()

Delete a comment from the target.

edit_comment(text)

Edit a comment on the target.

get_all_comments_on_target()

Gets all comment son the current target.

get_comment(pk)

Gets specific comment given pk.

swap_target_if_needed(create=False)

The target of CommentClient needs to be the CommentCatcher object, but sometimes the target is set to action instead. We automatically handle that instead of making the user do it.

class concord.resources.client.ListClient(actor=None, target=None)

Client for interacting with Lists.

class concord.resources.client.ResourceClient(actor=None, target=None)

The target of a resource client, if a target is required, is always a resource model. As with all Concord clients, a target must be set for all methods not explicitly grouped as target-less methods.

add_item(*, item_name: str) → Tuple[int, Any]

Add item to resource.

change_name(*, new_name: str) → Tuple[int, Any]

Change name of resource.

create_resource(*, name: str) → concord.resources.models.Resource

Create a resource given name of resource to be created.

get_all_resources() → django.db.models.query.QuerySet

Get all resources in the system.

get_items_on_resource() → List[str]

Get items on targtet resource.

get_resource_given_name(*, resource_name: str) → django.db.models.query.QuerySet

Get a resource given a unique name.

get_resource_given_pk(*, pk: int) → django.db.models.query.QuerySet

Get a resource given pk.

remove_item() → Tuple[int, Any]

Remove item from resource.