mirror of
https://github.com/Southampton-RSG/breccia-mapper.git
synced 2026-03-03 19:37:06 +00:00
feat!: Add answer sets to CSV export
BREAKING CHANGE: Change format of Relationship CSV export BREAKING CHANGE: Use 'id' for id field in CSV exports Add RelationshipAnswerSet CSV export
This commit is contained in:
@@ -11,7 +11,7 @@ class SimplePersonSerializer(serializers.ModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = models.Person
|
model = models.Person
|
||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class PersonSerializer(base.FlattenedModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = models.Person
|
model = models.Person
|
||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'id',
|
||||||
'name',
|
'name',
|
||||||
'core_member',
|
'core_member',
|
||||||
'gender',
|
'gender',
|
||||||
@@ -37,11 +37,24 @@ class RelationshipSerializer(base.FlattenedModelSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = models.Relationship
|
model = models.Relationship
|
||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'id',
|
||||||
'source',
|
'source',
|
||||||
'target',
|
'target',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class RelationshipAnswerSetSerializer(base.FlattenedModelSerializer):
|
||||||
|
relationship = RelationshipSerializer()
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = models.RelationshipAnswerSet
|
||||||
|
fields = [
|
||||||
|
'id',
|
||||||
|
'relationship',
|
||||||
|
'timestamp',
|
||||||
|
'replaced_timestamp',
|
||||||
|
]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def column_headers(self) -> typing.List[str]:
|
def column_headers(self) -> typing.List[str]:
|
||||||
headers = super().column_headers
|
headers = super().column_headers
|
||||||
@@ -57,7 +70,7 @@ class RelationshipSerializer(base.FlattenedModelSerializer):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Add relationship question answers to data
|
# Add relationship question answers to data
|
||||||
for answer in instance.current_answers.question_answers.all():
|
for answer in instance.question_answers.all():
|
||||||
rep[answer.question.slug.replace('-', '_')] = answer.slug.replace('-', '_')
|
rep[answer.question.slug.replace('-', '_')] = answer.slug.replace('-', '_')
|
||||||
|
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|||||||
@@ -39,6 +39,15 @@
|
|||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Relationship Answer Sets</td>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-info"
|
||||||
|
href="{% url 'export:relationship-answer-set' %}">Export</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Activities</td>
|
<td>Activities</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ urlpatterns = [
|
|||||||
views.people.RelationshipExportView.as_view(),
|
views.people.RelationshipExportView.as_view(),
|
||||||
name='relationship'),
|
name='relationship'),
|
||||||
|
|
||||||
|
path('export/relationship-answer-sets',
|
||||||
|
views.people.RelationshipAnswerSetExportView.as_view(),
|
||||||
|
name='relationship-answer-set'),
|
||||||
|
|
||||||
path('export/activities',
|
path('export/activities',
|
||||||
views.activities.ActivityExportView.as_view(),
|
views.activities.ActivityExportView.as_view(),
|
||||||
name='activity'),
|
name='activity'),
|
||||||
|
|||||||
@@ -12,3 +12,8 @@ class PersonExportView(base.CsvExportView):
|
|||||||
class RelationshipExportView(base.CsvExportView):
|
class RelationshipExportView(base.CsvExportView):
|
||||||
model = models.relationship.Relationship
|
model = models.relationship.Relationship
|
||||||
serializer_class = serializers.people.RelationshipSerializer
|
serializer_class = serializers.people.RelationshipSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class RelationshipAnswerSetExportView(base.CsvExportView):
|
||||||
|
model = models.relationship.RelationshipAnswerSet
|
||||||
|
serializer_class = serializers.people.RelationshipAnswerSetSerializer
|
||||||
|
|||||||
Reference in New Issue
Block a user