akvo.rsr.models.related_project module

exception akvo.rsr.models.related_project.MultipleParentsDisallowed[source]

Bases: Exception

Exception raised when trying to create multiple parents for a project.

message = 'A project can have only one parent.'
exception akvo.rsr.models.related_project.ParentChangeDisallowed[source]

Bases: Exception

Exception raised when trying to change parent after importing results.

message = "Cannot change a project's parent after importing results."
class akvo.rsr.models.related_project.RelatedProject(id, project, related_project, related_iati_id, relation)[source]

Bases: Model

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

PROJECT_RELATION_CHILD = '2'
PROJECT_RELATION_CO_FUNDED = '4'
PROJECT_RELATION_PARENT = '1'
PROJECT_RELATION_SIBLING = '3'
PROJECT_RELATION_THIRD_PARTY = '5'
get_relation_display(*, field=<akvo.rsr.fields.ValidXMLCharField: relation>)
iati_relation()[source]
iati_relation_unicode()[source]
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

project_id
property reciprocal_relation

Return the relation between related_project and project.

relation specifies the relationship between project and related_project. This returns the reciprocal relationship.

related_iati_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

related_project

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

related_project_id
relation

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

akvo.rsr.models.related_project.get_project_parents(project)[source]
akvo.rsr.models.related_project.prevent_parent_delete(sender, **kwargs)[source]
akvo.rsr.models.related_project.validate_parents(sender, **kwargs)[source]

Validate creation and changing of parents for a project.

  1. Prevent creating multiple parents for a project.

2. Prevent modifying the parent for a project that has already imported results from the parent.