Commits

Anonymous committed 6c626fb Merge

Merge ability to exclude fields, from https://bitbucket.org/stringfellow/django-shapes.

Comments (0)

Files changed (1)

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_fields
+        ]
         return attr
          
     def get_geo_field(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.