From 9006ec552cf33086f1c014dbabe92c01471d6b00 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Thu, 26 Jun 2014 18:09:30 +0200 Subject: [PATCH] [Models] move SubscriptionException to mygpo.users --- mygpo/api/legacy.py | 2 +- mygpo/core/models.py | 4 ---- mygpo/db/couchdb/podcast_state.py | 2 +- mygpo/users/models.py | 4 ++++ mygpo/users/sync.py | 2 +- mygpo/users/tasks.py | 2 +- mygpo/web/views/podcast.py | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mygpo/api/legacy.py b/mygpo/api/legacy.py index d7cd83dd..5c5e5c7d 100644 --- a/mygpo/api/legacy.py +++ b/mygpo/api/legacy.py @@ -25,7 +25,7 @@ from django.views.decorators.cache import never_cache from mygpo.podcasts.models import Podcast from mygpo.users.models import User from mygpo.api.opml import Importer, Exporter -from mygpo.core.models import SubscriptionException +from mygpo.users.models import SubscriptionException from mygpo.api.backend import get_device from mygpo.utils import normalize_feed_url from mygpo.db.couchdb.podcast_state import subscribe, unsubscribe diff --git a/mygpo/core/models.py b/mygpo/core/models.py index 4a80adeb..6345a98f 100644 --- a/mygpo/core/models.py +++ b/mygpo/core/models.py @@ -27,10 +27,6 @@ MIN_UPDATE_INTERVAL = 5 MAX_UPDATE_INTERVAL = 24 * 30 -class SubscriptionException(Exception): - pass - - class MergedIdException(Exception): """ raised when an object is accessed through one of its merged_ids """ diff --git a/mygpo/db/couchdb/podcast_state.py b/mygpo/db/couchdb/podcast_state.py index 7ad68bda..0bd2e875 100644 --- a/mygpo/db/couchdb/podcast_state.py +++ b/mygpo/db/couchdb/podcast_state.py @@ -1,4 +1,4 @@ -from mygpo.users.models import PodcastUserState +from mygpo.users.models import PodcastUserState, SubscriptionException from mygpo.users.settings import PUBLIC_SUB_PODCAST, PUBLIC_SUB_USER from mygpo.db.couchdb import get_userdata_database, get_single_result from mygpo.cache import cache_result diff --git a/mygpo/users/models.py b/mygpo/users/models.py index 498a98ba..f9f73d7d 100644 --- a/mygpo/users/models.py +++ b/mygpo/users/models.py @@ -36,6 +36,10 @@ class InvalidEpisodeActionAttributes(ValueError): """ raised when the attribues of an episode action fail validation """ +class SubscriptionException(Exception): + """ raised when a subscription can not be modified """ + + class DeviceUIDException(Exception): pass diff --git a/mygpo/users/sync.py b/mygpo/users/sync.py index 6ac85b2a..f780b4da 100644 --- a/mygpo/users/sync.py +++ b/mygpo/users/sync.py @@ -3,7 +3,6 @@ from collections import namedtuple from couchdbkit.ext.django.schema import * from mygpo.podcasts.models import Podcast -from mygpo.core.models import SubscriptionException import logging logger = logging.getLogger(__name__) @@ -162,6 +161,7 @@ class SyncedDevicesMixin(DocumentSchema): """ Applies the sync-actions to the device """ from mygpo.db.couchdb.podcast_state import subscribe, unsubscribe + from mygpo.users.models import SubscriptionException add, rem = sync_actions podcasts = Podcast.objects.filter(id__in=(add+rem)) diff --git a/mygpo/users/tasks.py b/mygpo/users/tasks.py index f005d885..c6576912 100644 --- a/mygpo/users/tasks.py +++ b/mygpo/users/tasks.py @@ -4,7 +4,6 @@ from collections import Counter from couchdbkit import ResourceConflict -from mygpo.core.models import SubscriptionException from mygpo.cel import celery from mygpo.db.couchdb.user import (suggestions_for_user, update_device_state, update_suggestions, ) @@ -17,6 +16,7 @@ logger = get_task_logger(__name__) @celery.task(max_retries=5, default_retry_delay=60) def sync_user(user): """ Syncs all of the user's device groups """ + from mygpo.users.models import SubscriptionException for group in user.get_grouped_devices(): if not group.is_synced: diff --git a/mygpo/web/views/podcast.py b/mygpo/web/views/podcast.py index 913468df..cb359416 100644 --- a/mygpo/web/views/podcast.py +++ b/mygpo/web/views/podcast.py @@ -12,7 +12,7 @@ from django.views.decorators.cache import never_cache, cache_control from django.shortcuts import get_object_or_404 from mygpo.podcasts.models import Podcast, PodcastGroup -from mygpo.core.models import SubscriptionException +from mygpo.users.models import SubscriptionException from mygpo.core.proxy import proxy_object from mygpo.core.tasks import flattr_thing from mygpo.utils import normalize_feed_url -- 2.11.4.GIT