Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/af export #1426

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/analysis_framework/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class AFRelatedAdmin(JFModelAdmin):
'__str__', linkify('analysis_framework'),
)
autocomplete_fields = ('analysis_framework',)
list_filter = ['analysis_framework']

def get_queryset(self, request):
return super().get_queryset(request).prefetch_related('analysis_framework')
Expand Down
3 changes: 2 additions & 1 deletion apps/analysis_framework/dataloaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def load_widgets(keys, parent, **filters):
**{
f'{parent}__in': keys,
**filters,
}
},
is_deleted=False
).exclude(widget_id__in=Widget.DEPRECATED_TYPES)\
.annotate(conditional_parent_widget_type=models.F('conditional_parent_widget__widget_id'))\
.order_by('order', 'id')
Expand Down
2 changes: 1 addition & 1 deletion apps/analysis_framework/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def export_af_to_csv(af, file):
writer = csv.DictWriter(file, fieldnames=AF_EXPORT_COLUMNS)
writer.writeheader()

for widget in af.widget_set.order_by('widget_id'):
for widget in af.widget_set.filter(is_deleted=False).order_by('widget_id'):
w_type = widget.widget_id
w_title = widget.title

Expand Down
4 changes: 2 additions & 2 deletions apps/analysis_framework/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def perform_nested_delete_or_update(self, pks_to_delete, model_class, instance,
section=self.instance, # NOTE: Adding this additional filter just to make sure
pk__in=pks_to_delete
)
qs.delete()
qs.update(is_deleted=True)

# NOTE: This is a custom function (apps/user_resource/serializers.py::UserResourceSerializer)
# This makes sure only scoped (individual AF) instances (widgets) are updated.
Expand Down Expand Up @@ -560,7 +560,7 @@ def _delete_old_secondary_taggings(self, af, secondary_tagging):
analysis_framework=af,
section__isnull=True, # NOTE: section are null for secondary taggings
).exclude(pk__in=current_ids) # Exclude current provided widgets
qs_to_delete.delete()
qs_to_delete.update(is_deleted=True)

def _save_secondary_taggings(self, af, secondary_tagging):
# Create secondary tagging widgets (Primary/Section widgets are created using WritableNestedModelSerializer)
Expand Down
7 changes: 6 additions & 1 deletion apps/export/tasks/tasks_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from deep.permissions import ProjectPermissions as PP
from deep.filter_set import get_dummy_request
from analysis_framework.models import Exportable
from analysis_framework.models import Exportable, Widget
from entry.models import Entry
from export.models import Export
from export.entries.excel_exporter import ExcelExporter
Expand Down Expand Up @@ -67,9 +67,14 @@ def export_entries(export):
),
),
)
widget = Widget.objects.filter(
analysis_framework__project=project,
is_deleted=False
).values('key')

exportables = Exportable.objects.filter(
analysis_framework__project=project,
widget_key__in=widget
).distinct()
regions = Region.objects.filter(project=project).distinct()

Expand Down
Loading