Skip to content

Commit

Permalink
Address some PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Charl1996 committed Jan 25, 2024
1 parent 7307fc6 commit 74fbafc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,14 @@
{% if request|toggle_enabled:"SUPPORT_GEO_JSON_EXPORT" %}
<div id="select-geo-property" class="form-group" hidden>
<label class="col-sm-4 col-md-3 col-lg-2 control-label" for="geo-property-select">
Select geo property
{% trans 'Select geo property' %}
</label>
<div class="col-sm-9 col-md-8 col-lg-6">
<select
id="geo-property-select"
class="control form-control"
data-bind="options: $parent.geoProperties,
value: table.selected_geo_property">
>
</select>
</div>
</div>
Expand Down
23 changes: 18 additions & 5 deletions corehq/apps/export/views/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def page_context(self):
number_of_apps_to_process = 0
is_all_case_types_export = (
isinstance(self.export_instance, CaseExportInstance)
and self.export_instance.case_type == ALL_CASE_TYPE_EXPORT
and self._is_bulk_export
)
table_count = 0
if not is_all_case_types_export:
Expand Down Expand Up @@ -162,18 +162,27 @@ def _possible_geo_properties(self):
if self.export_type == FORM_EXPORT:
return []

geo_properties = CaseProperty.objects.filter(
if self._is_bulk_export:
return []

return list(CaseProperty.objects.filter(
case_type__domain=self.domain,
case_type__name=self.export_instance.case_type,
data_type=CaseProperty.DataType.GPS,
).all()
return [prop.name for prop in geo_properties]
).values_list('name', flat=True))

@property
def format_options(self):
format_options = ["xls", "xlsx", "csv"]
if self.export_type == CASE_EXPORT and toggles.SUPPORT_GEO_JSON_EXPORT.enabled(self.domain):

should_support_geojson = (
self.export_type == CASE_EXPORT
and toggles.SUPPORT_GEO_JSON_EXPORT.enabled(self.domain)
and not self._is_bulk_export
)
if should_support_geojson:
format_options.append("geojson")

return format_options

@property
Expand Down Expand Up @@ -299,6 +308,10 @@ def get_export_schema(self, domain, app_id, identifier):
def get_empty_export_schema(self, domain, identifier):
return self.export_schema_cls.generate_empty_schema(domain, identifier)

@property
def _is_bulk_export(self):
return self.export_instance.case_type == ALL_CASE_TYPE_EXPORT


@location_safe
class CreateNewCustomFormExportView(BaseExportView):
Expand Down
4 changes: 2 additions & 2 deletions corehq/toggles/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2711,8 +2711,8 @@ def domain_has_privilege_from_toggle(privilege_slug, domain):

SUPPORT_GEO_JSON_EXPORT = StaticToggle(
slug='support_geo_json_export',
label='Support geo json export in Case Exporter',
label='Support GeoJSON export in Case Exporter',
tag=TAG_SOLUTIONS_CONDITIONAL,
namespaces=[NAMESPACE_DOMAIN],
description='The Case Export page now supports the exporting of geo json data.',
description='The Case Export page now supports the exporting of GeoJSON data.',
)

0 comments on commit 74fbafc

Please sign in to comment.