diff --git a/export/serializers/people.py b/export/serializers/people.py index 15dda49..071cf44 100644 --- a/export/serializers/people.py +++ b/export/serializers/people.py @@ -87,3 +87,55 @@ class RelationshipAnswerSetSerializer(AnswerSetSerializer): 'timestamp', 'replaced_timestamp', ] + + +class OrganisationSerializer(base.FlattenedModelSerializer): + class Meta: + model = models.Organisation + fields = [ + 'id', + 'name', + ] + + +class OrganisationAnswerSetSerializer(AnswerSetSerializer): + question_model = models.OrganisationQuestion + organisation = OrganisationSerializer() + + class Meta: + model = models.OrganisationAnswerSet + fields = [ + 'id', + 'organisation', + 'timestamp', + 'replaced_timestamp', + 'latitude', + 'longitude', + ] + + +class OrganisationRelationshipSerializer(base.FlattenedModelSerializer): + source = OrganisationSerializer() + target = OrganisationSerializer() + + class Meta: + model = models.OrganisationRelationship + fields = [ + 'id', + 'source', + 'target', + ] + + +class OrganisationRelationshipAnswerSetSerializer(AnswerSetSerializer): + question_model = models.OrganisationRelationshipQuestion + relationship = OrganisationRelationshipSerializer() + + class Meta: + model = models.OrganisationRelationshipAnswerSet + fields = [ + 'id', + 'relationship', + 'timestamp', + 'replaced_timestamp', + ] diff --git a/export/templates/export/export.html b/export/templates/export/export.html index 9151025..1eda477 100644 --- a/export/templates/export/export.html +++ b/export/templates/export/export.html @@ -57,6 +57,42 @@ + + Organisation + + + Export + + + + + Organisation Answer Sets + + + Export + + + + + Organisation Relationships + + + Export + + + + + Organisation Relationship Answer Sets + + + Export + + + Activities diff --git a/export/urls.py b/export/urls.py index d60d2b8..24ae2f7 100644 --- a/export/urls.py +++ b/export/urls.py @@ -26,6 +26,22 @@ urlpatterns = [ views.people.RelationshipAnswerSetExportView.as_view(), name='relationship-answer-set'), + path('export/organisation', + views.people.OrganisationExportView.as_view(), + name='organisation'), + + path('export/organisation-answer-sets', + views.people.OrganisationAnswerSetExportView.as_view(), + name='organisation-answer-set'), + + path('export/organisation-relationships', + views.people.OrganisationRelationshipExportView.as_view(), + name='organisation-relationship'), + + path('export/organisation-relationship-answer-sets', + views.people.OrganisationRelationshipAnswerSetExportView.as_view(), + name='organisation-relationship-answer-set'), + path('export/activities', views.activities.ActivityExportView.as_view(), name='activity'), diff --git a/export/views/people.py b/export/views/people.py index f7cea55..39d0fc3 100644 --- a/export/views/people.py +++ b/export/views/people.py @@ -22,3 +22,23 @@ class RelationshipExportView(base.CsvExportView): class RelationshipAnswerSetExportView(base.CsvExportView): model = models.relationship.RelationshipAnswerSet serializer_class = serializers.people.RelationshipAnswerSetSerializer + + +class OrganisationExportView(base.CsvExportView): + model = models.person.Organisation + serializer_class = serializers.people.OrganisationSerializer + + +class OrganisationAnswerSetExportView(base.CsvExportView): + model = models.organisation.OrganisationAnswerSet + serializer_class = serializers.people.OrganisationAnswerSetSerializer + + +class OrganisationRelationshipExportView(base.CsvExportView): + model = models.relationship.OrganisationRelationship + serializer_class = serializers.people.OrganisationRelationshipSerializer + + +class OrganisationRelationshipAnswerSetExportView(base.CsvExportView): + model = models.relationship.OrganisationRelationshipAnswerSet + serializer_class = serializers.people.OrganisationRelationshipAnswerSetSerializer