Commits

stringfellow  committed fae11ca Draft

allow exclusion of fields

  • Participants
  • Parent commits f3c9324

Comments (0)

Files changed (1)

File shapes/views/export.py

 
 
 class ShpResponder(object):
-    def __init__(self, queryset, readme=None, geo_field=None, proj_transform=None, mimetype='application/zip',file_name='shp_download'):
+    def __init__(self, queryset, readme=None, geo_field=None,
+                 proj_transform=None, mimetype='application/zip',
+                 file_name='shp_download', exclude=None):
         self.queryset = queryset
         self.readme = readme
         self.geo_field = geo_field
         self.proj_transform = proj_transform
         self.mimetype = mimetype
         self.file_name = smart_str(file_name)
+        self.exclude_fields = exclude or []
 
 
     def __call__(self, *args, **kwargs):
     def get_attributes(self):
         # Todo: control field order as param
         fields = self.queryset.model._meta.fields
-        attr = [f for f in fields if not isinstance(f, GeometryField)]
+        attr = [
+            f for f in fields
+            if not isinstance(f, GeometryField) and f.name not in self.exclude
+        ]
         return attr
          
     def get_geo_field(self):
         # Cleaning up
         check_err(lgdal.OGR_L_SyncToDisk(layer))
         lgdal.OGR_DS_Destroy(ds)
-        lgdal.OGRCleanupAll()
+        lgdal.OGRCleanupAll()