Skip to content

Commit

Permalink
Merge pull request #350 from datosgobar/342-use-datajsonar-admins
Browse files Browse the repository at this point in the history
342 use datajsonar admins
  • Loading branch information
lucaslavandeira authored Aug 13, 2018
2 parents fe20e28 + ab1f68b commit 79d4dec
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 18 deletions.
3 changes: 1 addition & 2 deletions series_tiempo_ar_api/apps/management/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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',
),
]
11 changes: 0 additions & 11 deletions series_tiempo_ar_api/apps/management/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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'},
),
]
7 changes: 2 additions & 5 deletions series_tiempo_ar_api/libs/indexing/report/report_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79d4dec

Please sign in to comment.