From 0a4114e33d85509da85eb85ea5ed258e97e55da2 Mon Sep 17 00:00:00 2001 From: Lucas Lavandeira <19612265+lucaslavandeira@users.noreply.github.com> Date: Mon, 13 Aug 2018 15:08:59 -0300 Subject: [PATCH 1/2] Uso datajsonar para obtener admins de nodos --- .../libs/indexing/report/report_generator.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/series_tiempo_ar_api/libs/indexing/report/report_generator.py b/series_tiempo_ar_api/libs/indexing/report/report_generator.py index 22ecc8fa..1adf3ef3 100644 --- a/series_tiempo_ar_api/libs/indexing/report/report_generator.py +++ b/series_tiempo_ar_api/libs/indexing/report/report_generator.py @@ -11,7 +11,7 @@ from django_datajsonar.models import Catalog, Node from series_tiempo_ar_api.apps.analytics.models import Query -from series_tiempo_ar_api.apps.management.models import Indicator, NodeAdmins +from series_tiempo_ar_api.apps.management.models import Indicator from series_tiempo_ar_api.libs.indexing.report import attachments from series_tiempo_ar_api.libs.indexing.report.indicators_generator import IndicatorsGenerator @@ -58,10 +58,7 @@ def send_email(self, context, node=None): if not node: recipients = Group.objects.get(name=settings.READ_DATAJSON_RECIPIENT_GROUP).user_set.all() else: - try: - recipients = NodeAdmins.objects.get(node=node).admins.all() - except NodeAdmins.DoesNotExist: - recipients = [] + recipients = node.admins.all() emails = [user.email for user in recipients] if not emails: # Nothing to do here From ab1f68bc163623a41519aa077ece5b12a453d529 Mon Sep 17 00:00:00 2001 From: Lucas Lavandeira <19612265+lucaslavandeira@users.noreply.github.com> Date: Mon, 13 Aug 2018 15:13:47 -0300 Subject: [PATCH 2/2] Borro modelo NodeAdmins paso a usar el campo admins de los Node de datajsonar, que son equivalentes --- series_tiempo_ar_api/apps/management/admin.py | 3 +-- .../migrations/0005_auto_20180813_1510.py | 26 +++++++++++++++++++ .../apps/management/models.py | 11 -------- .../migrations/0002_auto_20180813_1510.py | 19 ++++++++++++++ 4 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 series_tiempo_ar_api/apps/management/migrations/0005_auto_20180813_1510.py create mode 100644 series_tiempo_ar_api/apps/metadata/migrations/0002_auto_20180813_1510.py diff --git a/series_tiempo_ar_api/apps/management/admin.py b/series_tiempo_ar_api/apps/management/admin.py index e3d58a38..0f3eb4fc 100644 --- a/series_tiempo_ar_api/apps/management/admin.py +++ b/series_tiempo_ar_api/apps/management/admin.py @@ -3,7 +3,7 @@ from django.contrib import admin from .tasks import read_datajson -from .models import IndexingTaskCron, ReadDataJsonTask, NodeAdmins +from .models import IndexingTaskCron, ReadDataJsonTask class NodeAdmin(admin.ModelAdmin): @@ -65,6 +65,5 @@ def save_model(self, request, obj, form, change): read_datajson.delay(obj, force=force) # Ejecuta indexación -admin.site.register(NodeAdmins) admin.site.register(IndexingTaskCron, IndexingTaskAdmin) admin.site.register(ReadDataJsonTask, DataJsonAdmin) diff --git a/series_tiempo_ar_api/apps/management/migrations/0005_auto_20180813_1510.py b/series_tiempo_ar_api/apps/management/migrations/0005_auto_20180813_1510.py new file mode 100644 index 00000000..7f5e5f2e --- /dev/null +++ b/series_tiempo_ar_api/apps/management/migrations/0005_auto_20180813_1510.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2018-08-13 18:10 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('management', '0004_readdatajsontask_indexing_mode'), + ] + + operations = [ + migrations.RemoveField( + model_name='nodeadmins', + name='admins', + ), + migrations.RemoveField( + model_name='nodeadmins', + name='node', + ), + migrations.DeleteModel( + name='NodeAdmins', + ), + ] diff --git a/series_tiempo_ar_api/apps/management/models.py b/series_tiempo_ar_api/apps/management/models.py index eea21196..da5cf09a 100644 --- a/series_tiempo_ar_api/apps/management/models.py +++ b/series_tiempo_ar_api/apps/management/models.py @@ -115,14 +115,3 @@ class Meta: value = models.FloatField(default=0) node = models.ForeignKey(to=djar_models.Node, on_delete=models.CASCADE) task = models.ForeignKey(to=ReadDataJsonTask, on_delete=models.CASCADE) - - -class NodeAdmins(models.Model): - class Meta: - verbose_name_plural = 'Node admins' - - node = models.OneToOneField(to=djar_models.Node) - admins = models.ManyToManyField(to=User) - - def __str__(self): - return "Admins de {}".format(self.node.catalog_id) diff --git a/series_tiempo_ar_api/apps/metadata/migrations/0002_auto_20180813_1510.py b/series_tiempo_ar_api/apps/metadata/migrations/0002_auto_20180813_1510.py new file mode 100644 index 00000000..05cc7308 --- /dev/null +++ b/series_tiempo_ar_api/apps/metadata/migrations/0002_auto_20180813_1510.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2018-08-13 18:10 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('metadata', '0001_auto_20180810_1220_squashed_0002_auto_20180810_1229'), + ] + + operations = [ + migrations.AlterModelOptions( + name='catalogalias', + options={'verbose_name_plural': 'Catalog Aliases'}, + ), + ]