akvo.rest.serializers.project module

class akvo.rest.serializers.project.ProjectDirectoryDynamicFieldsSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = '__all__'
model

alias of Project

get_countries(project)[source]
get_image(project: Project)[source]
get_partners(project)[source]
class akvo.rest.serializers.project.ProjectDirectorySerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

fields = ('id', 'title', 'subtitle', 'summary', 'latitude', 'longitude', 'image', 'countries', 'organisation', 'organisations', 'sectors', 'dropdown_custom_fields', 'order_score')
model

alias of Project

get_countries(project)[source]
get_dropdown_custom_fields(project)[source]
get_image(project)[source]
get_order_score(project)[source]
get_organisations(project)[source]
get_sectors(project)[source]
class akvo.rest.serializers.project.ProjectExtraSerializer(*args, **kwargs)[source]

Bases: ProjectSerializer

class Meta[source]

Bases: Meta

class akvo.rest.serializers.project.ProjectIatiExportSerializer(*args, **kwargs)[source]

Bases: BaseRSRSerializer

class Meta[source]

Bases: object

fields = ('id', 'title', 'is_public', 'publishing_status', 'status', 'checks_errors', 'checks_warnings', 'iati_status', 'date_start_actual', 'date_end_actual')
model

alias of Project

class akvo.rest.serializers.project.ProjectMetadataSerializer(*args, **kwargs)[source]

Bases: BaseRSRSerializer

class Meta[source]

Bases: object

fields = ('id', 'title', 'subtitle', 'date_end_actual', 'date_end_planned', 'date_start_actual', 'date_start_planned', 'locations', 'status', 'is_public', 'sectors', 'parent', 'editable', 'recipient_countries', 'restricted', 'roles', 'use_project_roles', 'is_program', 'primary_organisation', 'children_count')
model

alias of Project

get_children_count(obj)[source]
get_editable(obj)[source]

Method used by the editable SerializerMethodField

get_locations(obj)[source]
get_parent(obj)[source]
get_restricted(project)[source]

True if the project is restricted for the user

class akvo.rest.serializers.project.ProjectSerializer(*args, **kwargs)[source]

Bases: BaseRSRSerializer

class Meta[source]

Bases: object

fields = '__all__'
model

alias of Project

create(validated_data)[source]

We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:

return ExampleModel.objects.create(**validated_data)

If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:

example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance

The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.

get_can_edit_access(obj)[source]
get_can_edit_enumerator_access(obj)[source]
get_can_edit_settings(obj)[source]
get_can_publish(obj)[source]
get_created_at(project: Project)[source]

This is a work around to silence the “Invalid datetime for the timezone Europe/Stockholm” which has appeared several times and not yet known why.

TODO: This may no longer necessary as of Django 4.2

get_editable(obj)[source]

Method used by the editable SerializerMethodField

get_iati_profile_url(obj)[source]
get_path(project: Project)[source]
get_program(obj)[source]
update(project: Project, validated_data: dict)[source]
class akvo.rest.serializers.project.ProjectUpSerializer(*args, **kwargs)[source]

Bases: ProjectSerializer

Custom endpoint for RSR Up

class Meta[source]

Bases: Meta

class akvo.rest.serializers.project.TargetsAtField(*args, **kwargs)[source]

Bases: ChoiceField

get_attribute(instance)[source]

Given the outgoing object instance, return the primitive value that should be used for this field.

to_representation(obj)[source]

Transform the outgoing native value into primitive data.

akvo.rest.serializers.project.make_descendants_tree(descendants: List[dict], root: Project)[source]