Skip to content

Commit

Permalink
Merge pull request #1528 from the-deep/fix/json-export
Browse files Browse the repository at this point in the history
Fix json export and exportable
  • Loading branch information
AdityaKhatri authored Oct 1, 2024
2 parents 1ad6182 + 123ea80 commit 7e441e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/analysis_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ def update(self, instance, validated_data):
if instance.created_by_id and not instance.members.filter(id=instance.created_by_id).exists():
owner_role = instance.get_or_create_owner_role()
instance.add_member(instance.created_by, owner_role)

ProjectChangeManager.log_framework_update(instance.pk, self.context['request'].user)
self._post_save(instance)
return instance
Expand Down
10 changes: 8 additions & 2 deletions apps/export/entries/json_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ def __init__(self, is_preview=False):
self.is_preview = is_preview
self.data = {}

def load_exportables(self, exportables):
self.exportables = exportables
def load_exportables(self, exportables, analysis_framework):
# get all widget key name in list
widgets_key = Widget.objects.filter(analysis_framework=analysis_framework).values_list(
'key',
flat=True
)
# exclude widgets_key which are not in exportables table
self.exportables = exportables.filter(widget_key__in=widgets_key)
self.widget_ids = []

self.data['widgets'] = []
Expand Down
2 changes: 1 addition & 1 deletion apps/export/tasks/tasks_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def export_entries(export):

elif export_type == Export.ExportType.JSON:
export_data = JsonExporter(is_preview=is_preview)\
.load_exportables(exportables)\
.load_exportables(exportables, project.analysis_framework)\
.add_entries(entries_qs)\
.export()

Expand Down

0 comments on commit 7e441e0

Please sign in to comment.