diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 0fdbd0ceb..533085955 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,9 +1,9 @@ [bumpversion] -current_version = 1.14 +current_version = 1.15 commit = True tag = False allow_dirty = True -parse = (?P\d+)\.(?P\d+)((?P[a-z]+)(?P\d+))? +parse = (?P\d+)\.(?P\d+)\.(?P[a-z]+) serialize = {major}.{minor}{release}{num} {major}.{minor} @@ -21,8 +21,8 @@ serialize = {major}.{minor} [bumpversion:file:docker/Makefile] -serialize = - {major}.{minor}{release}{num} +serialize = + {major}.{minor}{release} [bumpversion:file:src/etools_datamart/__init__.py] serialize = diff --git a/CHANGES b/CHANGES index 929b7fd01..e1ad1ed59 100644 --- a/CHANGES +++ b/CHANGES @@ -1,15 +1,20 @@ +1.15 +---- +* add ability to truncate DataMart tables +* fixes init-setup PeriodicTask creation + 1.14 ---- * Fix loading Intervention * migrations reset -1.14 +1.12 --------- * new endpoint DPIndicator * preload helpers -1.14 +1.11 --------- * add impersonation * fixes schema permission check diff --git a/docker/Makefile b/docker/Makefile index ba6a82310..611eed563 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -4,7 +4,7 @@ DATABASE_URL_ETOOLS?= DEVELOP?=0 DOCKER_PASS?= DOCKER_USER?= -TARGET?=1.14 +TARGET?=1.15 # below vars are used internally BUILD_OPTIONS?=--squash CMD?=datamart diff --git a/src/etools_datamart/__init__.py b/src/etools_datamart/__init__.py index 909cb376b..31249cc06 100644 --- a/src/etools_datamart/__init__.py +++ b/src/etools_datamart/__init__.py @@ -1,7 +1,7 @@ import warnings NAME = 'etools-datamart' -VERSION = __version__ = '1.14' +VERSION = __version__ = '1.15' __author__ = '' # UserWarning: The psycopg2 wheel package will be renamed from release 2.8; diff --git a/src/etools_datamart/apps/data/admin.py b/src/etools_datamart/apps/data/admin.py index c33675266..0a552b33e 100644 --- a/src/etools_datamart/apps/data/admin.py +++ b/src/etools_datamart/apps/data/admin.py @@ -9,7 +9,7 @@ from django.http import HttpResponseRedirect from django.urls import reverse -from admin_extra_urls.extras import ExtraUrlMixin, link +from admin_extra_urls.extras import link from adminactions.mass_update import mass_update from adminfilters.filters import AllValuesComboFilter from crashlog.middleware import process_exception @@ -30,7 +30,7 @@ class DatamartChangeList(ChangeList): pass -class DataModelAdmin(ExtraUrlMixin, ModelAdmin): +class DataModelAdmin(TruncateTableMixin, ModelAdmin): actions = [mass_update, ] def get_list_filter(self, request): diff --git a/src/etools_datamart/apps/data/models/base.py b/src/etools_datamart/apps/data/models/base.py index 8bb4a841f..cda6e37e9 100644 --- a/src/etools_datamart/apps/data/models/base.py +++ b/src/etools_datamart/apps/data/models/base.py @@ -31,7 +31,7 @@ def filter_schemas(self, *schemas): class DataMartManager(BaseManager.from_queryset(DataMartQuerySet)): def truncate(self): - self.raw('TRUNCATE TABLE {0}'.format(self.model._meta.db_table)) + self.raw('TRUNCATE TABLE {0} CASCADE'.format(self.model._meta.db_table)) class DataMartModelBase(ModelBase): diff --git a/src/etools_datamart/apps/init/management/commands/init-setup.py b/src/etools_datamart/apps/init/management/commands/init-setup.py index c3139f0be..3256d40eb 100644 --- a/src/etools_datamart/apps/init/management/commands/init-setup.py +++ b/src/etools_datamart/apps/init/management/commands/init-setup.py @@ -261,9 +261,9 @@ def handle(self, *args, **options): loaders = [] for loadeable in loadeables: model = apps.get_model(loadeable) - loaders.append(loadeable) - __, is_new = PeriodicTask.objects.get_or_create(task=f"ETL {model.loader.task.name}", - defaults={'name': loadeable, + loaders.append(model.loader.task.name) + __, is_new = PeriodicTask.objects.get_or_create(name=f"ETL {model.loader.task.name}", + defaults={'task': model.loader.task.name, 'service': Service.objects.get_for_model(model), 'crontab': midnight}) if is_new: @@ -280,7 +280,7 @@ def handle(self, *args, **options): if is_new: self.stdout.write(f"NEW preload task for '{url}'") - ret = PeriodicTask.objects.filter(name__startswith='data.').exclude(name__in=loaders).delete() + ret = PeriodicTask.objects.filter(task__startswith='load_').exclude(task__in=loaders).delete() counters[False] = ret[0] EtlTask.objects.inspect() diff --git a/src/unicef_rest_framework/admin/base.py b/src/unicef_rest_framework/admin/base.py index 71d814eef..c007411cd 100644 --- a/src/unicef_rest_framework/admin/base.py +++ b/src/unicef_rest_framework/admin/base.py @@ -24,7 +24,7 @@ class TruncateTableMixin(ExtraUrlMixin): def _truncate(self, request): from django.db import connection cursor = connection.cursor() - cursor.execute('TRUNCATE TABLE {0}'.format(self.model._meta.db_table)) + cursor.execute('TRUNCATE TABLE "{0}" CASCADE '.format(self.model._meta.db_table)) @link(label='Truncate', permission=lambda request, obj: request.user.is_superuser) def truncate(self, request):