From 9285f9bc3da478144b30ac7a0cd3185f2e03d723 Mon Sep 17 00:00:00 2001 From: Tasos Katsoulas Date: Wed, 14 Jan 2015 17:19:34 +0200 Subject: [PATCH] [bug 1121868] Fix circular dependencies in dasboard and remozilla apps. --- remo/dashboard/models.py | 4 ++-- .../admin/import_export/change_list_export.html | 2 +- remo/remozilla/models.py | 10 +++++++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/remo/dashboard/models.py b/remo/dashboard/models.py index 2ba36e396..afd117a51 100644 --- a/remo/dashboard/models.py +++ b/remo/dashboard/models.py @@ -6,6 +6,8 @@ from django.db import models from django.db.models.signals import post_save +from remo.remozilla.models import Bug + Item = namedtuple('Item', ['name', 'user', 'priority', 'due_date']) @@ -90,7 +92,5 @@ def resolve(instance, user, name): action_items.update(completed=True, resolved=True) -from remo.remozilla.models import Bug - post_save.connect(ActionItem.create, sender=Bug, dispatch_uid='create_action_items_bugzilla_sig') diff --git a/remo/profiles/templates/admin/import_export/change_list_export.html b/remo/profiles/templates/admin/import_export/change_list_export.html index 2211b64a1..b3e25c004 100644 --- a/remo/profiles/templates/admin/import_export/change_list_export.html +++ b/remo/profiles/templates/admin/import_export/change_list_export.html @@ -3,7 +3,7 @@ {% block object-tools-items %}
  • - + Check Celery
  • diff --git a/remo/remozilla/models.py b/remo/remozilla/models.py index 7299cef5d..f75d63761 100644 --- a/remo/remozilla/models.py +++ b/remo/remozilla/models.py @@ -1,5 +1,6 @@ from datetime import datetime +from django.db.models.loading import get_model from django.contrib.auth.models import User from django.contrib.contenttypes import generic from django.contrib.contenttypes.models import ContentType @@ -10,8 +11,6 @@ import caching.base -from remo.dashboard.models import ActionItem, Item - ADD_RECEIPTS_ACTION = u'Add receipts for' ADD_REPORT_ACTION = u'Add report for' @@ -54,7 +53,7 @@ class Bug(caching.base.CachingMixin, models.Model): council_member_assigned = models.BooleanField(default=False) pending_mentor_validation = models.BooleanField(default=False) budget_needinfo = models.ManyToManyField(User) - action_items = generic.GenericRelation(ActionItem) + action_items = generic.GenericRelation('dashboard.ActionItem') objects = caching.base.CachingManager() @@ -80,6 +79,8 @@ def waiting_photos(self): def get_action_items(self): # Avoid circular dependency from remo.base.helpers import user_is_rep + from remo.dashboard.models import Item + ActionItem = get_model('dashboard', 'ActionItem') if not self.assigned_to or not user_is_rep(self.assigned_to): return [] @@ -123,6 +124,7 @@ def get_action_items(self): def save(self, *args, **kwargs): # Avoid circular dependency from remo.base.helpers import user_is_rep + ActionItem = get_model('dashboard', 'ActionItem') # Update action items action_model = ContentType.objects.get_for_model(self) @@ -197,6 +199,8 @@ def set_uppercase_pre_save(sender, instance, **kwargs): def update_budget_needinfo_action_items(sender, instance, action, pk_set, **kwargs): """Update ActionItem objects on needinfo change.""" + + ActionItem = get_model('dashboard', 'ActionItem') name = '{0} {1}'.format(NEEDINFO_ACTION, instance.summary) if action == 'post_remove': for pk in pk_set: