diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 2caf8fa2..9dc6d345 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -11,6 +11,10 @@ on: schedule: - cron: '0 2 * * *' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: lint: runs-on: ubuntu-latest diff --git a/CHANGES.md b/CHANGES.md index 6d3e87cd..4ee3bed2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ CHANGELOG 8.8.1+dev (XXXX-XX-XX) ----------------------- +**Improvements** + +- Add a get_columns method to change column list dynamically. + 8.8.1 (2024-05-07) ------------------- diff --git a/mapentity/views/base.py b/mapentity/views/base.py index 6e5c0ad5..13027249 100644 --- a/mapentity/views/base.py +++ b/mapentity/views/base.py @@ -131,6 +131,9 @@ def __init__(self, *args, **kwargs): self.columns.remove('id') self.columns.insert(0, 'id') + def get_columns(self): + return self.columns + @view_permission_required() def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) diff --git a/mapentity/views/generic.py b/mapentity/views/generic.py index a0538b79..428e695d 100755 --- a/mapentity/views/generic.py +++ b/mapentity/views/generic.py @@ -76,7 +76,7 @@ def dispatch(self, request, *args, **kwargs): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['filterform'] = self._filterform # From FilterListMixin - context['columns'] = self.columns # From BaseListView + context['columns'] = self.get_columns() # From BaseListView context['unorderable_columns'] = self.unorderable_columns # From BaseListView context['searchable_columns'] = self.searchable_columns # From BaseListView context['create_label'] = self.get_model().get_create_label() @@ -131,14 +131,14 @@ def csv_view(self, request, context, **kwargs): serializer = mapentity_serializers.CSVSerializer() response = HttpResponse(content_type='text/csv') serializer.serialize(queryset=self.get_queryset(), stream=response, - model=self.get_model(), fields=self.columns, ensure_ascii=True) + model=self.get_model(), fields=self.get_columns(), ensure_ascii=True) return response def shape_view(self, request, context, **kwargs): serializer = mapentity_serializers.ZipShapeSerializer() response = HttpResponse(content_type='application/zip') serializer.serialize(queryset=self.get_queryset(), model=self.get_model(), - stream=response, fields=self.columns) + stream=response, fields=self.get_columns()) response['Content-length'] = str(len(response.content)) return response diff --git a/test_project/settings.py b/test_project/settings.py index 0ff4e232..c58502c9 100644 --- a/test_project/settings.py +++ b/test_project/settings.py @@ -68,6 +68,7 @@ 'mapentity.middleware.AutoLoginMiddleware', ) + ROOT_URLCONF = 'test_project.urls' TEMPLATES = [