Skip to content

Commit

Permalink
merge release/1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
CI committed Feb 1, 2019
2 parents 38c5c5e + 099d2d1 commit eb3077f
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[bumpversion]
current_version = 1.14
current_version = 1.15
commit = True
tag = False
allow_dirty = True
parse = (?P<major>\d+)\.(?P<minor>\d+)((?P<release>[a-z]+)(?P<num>\d+))?
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<release>[a-z]+)
serialize =
{major}.{minor}{release}{num}
{major}.{minor}
Expand All @@ -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 =
Expand Down
9 changes: 7 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/etools_datamart/__init__.py
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/etools_datamart/apps/data/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion src/etools_datamart/apps/data/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/unicef_rest_framework/admin/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit eb3077f

Please sign in to comment.