From 716c3665b15e641103ba36a42d36dc98b4e3bc0e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Thu, 26 Jun 2014 17:36:43 +0200 Subject: [PATCH] [Migration] remove/rewrite imports of CouchDB models --- mygpo/api/advanced/lists.py | 5 ++--- mygpo/data/management/commands/tag-downloader.py | 1 - mygpo/shell.py | 2 +- mygpo/users/sync.py | 3 ++- mygpo/web/templatetags/episodes.py | 1 - mygpo/web/templatetags/podcasts.py | 4 ++-- mygpo/web/templatetags/youtube.py | 1 - mygpo/web/views/podcast.py | 6 +++--- 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/mygpo/api/advanced/lists.py b/mygpo/api/advanced/lists.py index 0a1b5ef6..1e9553d6 100644 --- a/mygpo/api/advanced/lists.py +++ b/mygpo/api/advanced/lists.py @@ -34,7 +34,6 @@ from mygpo.api.advanced.directory import podcast_data from mygpo.api.httpresponse import JsonResponse from mygpo.share.models import PodcastList from mygpo.api.basic_auth import require_valid_user, check_username -from mygpo.core.models import Podcast as P from mygpo.decorators import allowed_methods, repeat_on_conflict, cors_origin from mygpo.api.simple import parse_subscription, format_podcast_list, \ check_format @@ -72,7 +71,7 @@ def create(request, username, format): urls = parse_subscription(request.body, format) podcasts = [Podcast.objects.get_or_create_for_url(url) for url in urls] - podcast_ids = map(P.get_id, podcasts) + podcast_ids = [podcast.id.hex for podcast in podcasts] plist = PodcastList() plist.created_timestamp = get_timestamp(datetime.utcnow()) @@ -174,7 +173,7 @@ def update_list(request, plist, owner, format): urls = parse_subscription(request.body, format) podcasts = [Podcast.objects.get_or_create_for_url(url) for url in urls] - podcast_ids = map(P.get_id, podcasts) + podcast_ids = [podcast.id.hex for podcast in podcasts] @repeat_on_conflict(['podcast_ids']) def _update(plist, podcast_ids): diff --git a/mygpo/data/management/commands/tag-downloader.py b/mygpo/data/management/commands/tag-downloader.py index 93461687..b55dbe09 100644 --- a/mygpo/data/management/commands/tag-downloader.py +++ b/mygpo/data/management/commands/tag-downloader.py @@ -3,7 +3,6 @@ import urllib2 from optparse import make_option from mygpo.decorators import repeat_on_conflict -from mygpo.core.models import Podcast from mygpo.data import delicious from mygpo.maintenance.management.podcastcmd import PodcastCommand diff --git a/mygpo/shell.py b/mygpo/shell.py index d0517ffa..70a5f6fd 100644 --- a/mygpo/shell.py +++ b/mygpo/shell.py @@ -8,7 +8,7 @@ # to get all relevant classes, and an instantiated db object. # -from mygpo.core.models import * +from mygpo.podcasts.models import * from mygpo.users.models import * from mygpo.directory.models import * from mygpo.share.models import * diff --git a/mygpo/users/sync.py b/mygpo/users/sync.py index 2a3fa2ca..6ac85b2a 100644 --- a/mygpo/users/sync.py +++ b/mygpo/users/sync.py @@ -2,7 +2,8 @@ from collections import namedtuple from couchdbkit.ext.django.schema import * -from mygpo.core.models import Podcast, SubscriptionException +from mygpo.podcasts.models import Podcast +from mygpo.core.models import SubscriptionException import logging logger = logging.getLogger(__name__) diff --git a/mygpo/web/templatetags/episodes.py b/mygpo/web/templatetags/episodes.py index 1262ed32..4e25f1c0 100644 --- a/mygpo/web/templatetags/episodes.py +++ b/mygpo/web/templatetags/episodes.py @@ -4,7 +4,6 @@ from django.utils.translation import ugettext as _ from django.utils.html import strip_tags from django.contrib.staticfiles.storage import staticfiles_storage -from mygpo.core.models import Episode from mygpo import utils from mygpo.data.mimetype import get_type, get_mimetype from mygpo.web.utils import get_episode_link_target diff --git a/mygpo/web/templatetags/podcasts.py b/mygpo/web/templatetags/podcasts.py index e8f54c7a..06ddc9a2 100644 --- a/mygpo/web/templatetags/podcasts.py +++ b/mygpo/web/templatetags/podcasts.py @@ -47,7 +47,7 @@ def podcast_status_icon(action): @register.filter def is_podcast(podcast): """ Returns True if the argument is a podcast (esp not a PodcastGroup) """ - from mygpo.core.models import Podcast + from mygpo.podcasts.models import Podcast return isinstance(podcast, Podcast) @@ -127,7 +127,7 @@ def podcast_group_link(podcast, title=None): automatically distringuishes between relational Podcast/PodcastGroup objects and CouchDB-based Podcast/PodcastGroup objects """ - from mygpo.core.models import PodcastGroup + from mygpo.podcasts.models import PodcastGroup if isinstance(podcast, PodcastGroup): podcasts = list(podcast.podcasts) diff --git a/mygpo/web/templatetags/youtube.py b/mygpo/web/templatetags/youtube.py index 45fe725f..9d6f171f 100644 --- a/mygpo/web/templatetags/youtube.py +++ b/mygpo/web/templatetags/youtube.py @@ -1,7 +1,6 @@ from django import template from django.utils.safestring import mark_safe -from mygpo.core.models import Podcast from mygpo.data import youtube diff --git a/mygpo/web/views/podcast.py b/mygpo/web/views/podcast.py index ab001209..913468df 100644 --- a/mygpo/web/views/podcast.py +++ b/mygpo/web/views/podcast.py @@ -11,8 +11,8 @@ from django.views.decorators.vary import vary_on_cookie from django.views.decorators.cache import never_cache, cache_control from django.shortcuts import get_object_or_404 -from mygpo.podcasts.models import Podcast -from mygpo.core.models import PodcastGroup, SubscriptionException +from mygpo.podcasts.models import Podcast, PodcastGroup +from mygpo.core.models import SubscriptionException from mygpo.core.proxy import proxy_object from mygpo.core.tasks import flattr_thing from mygpo.utils import normalize_feed_url @@ -59,7 +59,7 @@ def show(request, podcast): episodes = episodes[1:] if podcast.group: - group = PodcastGroup.get(podcast.group) + group = podcast.group rel_podcasts = filter(lambda x: x != podcast, group.podcasts) else: rel_podcasts = [] -- 2.11.4.GIT