diff --git a/mygpo/administration/tasks.py b/mygpo/administration/tasks.py index 80b3d498b..bdf7f9993 100644 --- a/mygpo/administration/tasks.py +++ b/mygpo/administration/tasks.py @@ -4,7 +4,6 @@ from django_db_geventpool.utils import close_connection from mygpo.podcasts.models import Podcast -from mygpo.celery import celery from mygpo.maintenance.merge import PodcastMerger from celery.utils.log import get_task_logger diff --git a/mygpo/administration/tests.py b/mygpo/administration/tests.py index cab3224a5..a89a856e3 100644 --- a/mygpo/administration/tests.py +++ b/mygpo/administration/tests.py @@ -67,8 +67,8 @@ def test_merge(self): subscribe(p1.pk, user.pk, device1.uid) subscribe(p2.pk, user.pk, device2.uid) - action1 = EpisodeHistoryEntry.create_entry(user, e1, EpisodeHistoryEntry.PLAY) - action3 = EpisodeHistoryEntry.create_entry(user, e3, EpisodeHistoryEntry.PLAY) + EpisodeHistoryEntry.create_entry(user, e1, EpisodeHistoryEntry.PLAY) + EpisodeHistoryEntry.create_entry(user, e3, EpisodeHistoryEntry.PLAY) # we need that for later e3_id = e3.pk diff --git a/mygpo/administration/views.py b/mygpo/administration/views.py index dcd4a0cfd..aba6ba119 100644 --- a/mygpo/administration/views.py +++ b/mygpo/administration/views.py @@ -1,7 +1,6 @@ import re import socket -from itertools import count, chain -from collections import Counter +from itertools import count from datetime import datetime import redis @@ -14,7 +13,6 @@ from django.core.cache import cache from django.http import HttpResponseRedirect from django.template.loader import render_to_string -from django.template import RequestContext from django.utils.translation import gettext as _ from django.contrib.sites.requests import RequestSite from django.views.generic import TemplateView @@ -25,7 +23,7 @@ from mygpo.podcasts.models import Podcast, Episode from mygpo.administration.auth import require_staff from mygpo.administration.group import PodcastGrouper -from mygpo.maintenance.merge import PodcastMerger, IncorrectMergeException +from mygpo.maintenance.merge import IncorrectMergeException from mygpo.administration.clients import UserAgentStats, ClientStats from mygpo.users.views.registration import send_activation_email from mygpo.administration.tasks import merge_podcasts diff --git a/mygpo/api/advanced/__init__.py b/mygpo/api/advanced/__init__.py index 08d5b760e..5c36cc2ea 100644 --- a/mygpo/api/advanced/__init__.py +++ b/mygpo/api/advanced/__init__.py @@ -1,6 +1,3 @@ -from functools import partial - -from collections import defaultdict from datetime import datetime from importlib import import_module @@ -9,7 +6,6 @@ from django.http import ( HttpResponse, HttpResponseBadRequest, - Http404, HttpResponseNotFound, ) from django.core.exceptions import ValidationError @@ -307,7 +303,7 @@ def device(request, username, device_uid, version=None): try: data = parse_request_body(request) - except (UnicodeDecodeError, ValueError) as e: + except (UnicodeDecodeError, ValueError): msg = ("Could not decode device update POST data for " + "user %s: %s") % ( username, request.body.decode("ascii", errors="replace"), diff --git a/mygpo/api/advanced/episode.py b/mygpo/api/advanced/episode.py index ea417c894..bbc78cc61 100644 --- a/mygpo/api/advanced/episode.py +++ b/mygpo/api/advanced/episode.py @@ -3,7 +3,7 @@ from mygpo.api import APIView, RequestException from mygpo.api.httpresponse import JsonResponse from mygpo.api.exceptions import ParameterMissing -from mygpo.chapters.models import Chapter +from mygpo.chapters.models import Chapter, Episode, Podcast from mygpo.utils import parse_time, normalize_feed_url, get_timestamp diff --git a/mygpo/api/advanced/lists.py b/mygpo/api/advanced/lists.py index 8724dd7ce..a36382347 100644 --- a/mygpo/api/advanced/lists.py +++ b/mygpo/api/advanced/lists.py @@ -2,7 +2,7 @@ from functools import partial from datetime import datetime -from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden +from django.http import HttpResponse, HttpResponseBadRequest from django.views.decorators.csrf import csrf_exempt from django.urls import reverse from django.contrib.sites.requests import RequestSite @@ -10,10 +10,8 @@ from django.utils.text import slugify from django.views.decorators.cache import never_cache from django.http import Http404 -from django.shortcuts import get_object_or_404 from mygpo.podcasts.models import Podcast -from mygpo.utils import get_timestamp from mygpo.api.advanced.directory import podcast_data from mygpo.api.httpresponse import JsonResponse from mygpo.podcastlists.models import PodcastList diff --git a/mygpo/api/advanced/settings.py b/mygpo/api/advanced/settings.py index fb589f977..43831bdbf 100644 --- a/mygpo/api/advanced/settings.py +++ b/mygpo/api/advanced/settings.py @@ -1,5 +1,3 @@ -import json - from django.shortcuts import get_object_or_404 from mygpo.api import APIView, RequestException diff --git a/mygpo/api/advanced/updates.py b/mygpo/api/advanced/updates.py index e5e41d2f6..702e4d9fa 100644 --- a/mygpo/api/advanced/updates.py +++ b/mygpo/api/advanced/updates.py @@ -1,4 +1,3 @@ -from itertools import chain from datetime import datetime from django.http import HttpResponseBadRequest, HttpResponseNotFound @@ -16,7 +15,6 @@ from mygpo.subscriptions import get_subscription_history, subscription_diff from mygpo.users.models import Client from mygpo.episodestates.models import EpisodeState -from mygpo.users.subscriptions import subscription_changes, podcasts_for_states from mygpo.api.basic_auth import require_valid_user, check_username from mygpo.decorators import cors_origin @@ -42,7 +40,6 @@ class DeviceUpdates(View): def get(self, request, username, device_uid): now = datetime.utcnow() - now_ = get_timestamp(now) user = request.user diff --git a/mygpo/api/subscriptions.py b/mygpo/api/subscriptions.py index 27f5f094e..9ee91cb18 100644 --- a/mygpo/api/subscriptions.py +++ b/mygpo/api/subscriptions.py @@ -10,7 +10,6 @@ from mygpo.users.models import Client from mygpo.subscriptions.tasks import subscribe, unsubscribe from mygpo.subscriptions import get_subscription_history, subscription_diff -from mygpo.api.basic_auth import require_valid_user, check_username import logging diff --git a/mygpo/api/tasks.py b/mygpo/api/tasks.py index 65cd63ede..27246a14b 100644 --- a/mygpo/api/tasks.py +++ b/mygpo/api/tasks.py @@ -3,7 +3,6 @@ from django_db_geventpool.utils import close_connection -from mygpo.celery import celery from mygpo.api.advanced import update_episodes logger = get_task_logger(__name__) diff --git a/mygpo/api/tests.py b/mygpo/api/tests.py index 5acee547d..4c60fd3a3 100644 --- a/mygpo/api/tests.py +++ b/mygpo/api/tests.py @@ -13,7 +13,6 @@ from django.test.utils import override_settings from openapi_spec_validator import validate_spec_url -from jsonschema import ValidationError from mygpo.podcasts.models import Podcast, Episode from mygpo.api.advanced import episodes diff --git a/mygpo/celery.py b/mygpo/celery.py index 86634da78..bc389779f 100644 --- a/mygpo/celery.py +++ b/mygpo/celery.py @@ -1,7 +1,5 @@ import os -from django.conf import settings - from celery import Celery os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mygpo.settings") diff --git a/mygpo/chapters/models.py b/mygpo/chapters/models.py index d4323f4fe..13a7299a0 100644 --- a/mygpo/chapters/models.py +++ b/mygpo/chapters/models.py @@ -2,7 +2,7 @@ from django.conf import settings from mygpo.core.models import UpdateInfoModel -from mygpo.podcasts.models import Episode +from mygpo.podcasts.models import Episode, Podcast class Chapter(UpdateInfoModel): diff --git a/mygpo/data/feeddownloader.py b/mygpo/data/feeddownloader.py index 000a80744..524511134 100755 --- a/mygpo/data/feeddownloader.py +++ b/mygpo/data/feeddownloader.py @@ -2,10 +2,7 @@ # -*- coding: utf-8 -*- import os.path -import urllib.request -import urllib.error from urllib.parse import urljoin -import hashlib from datetime import datetime, timedelta from itertools import chain, islice import requests @@ -65,7 +62,7 @@ def update_podcasts(queue): except NoPodcastCreated as npc: logger.info("No podcast created: %s", npc) - except NoEpisodesException as nee: + except NoEpisodesException: logger.info(f"No episodes found when parsing {podcast_url}") continue @@ -339,9 +336,6 @@ def __init__(self, podcast, update_result): self.max_episode_order = None def update_episodes(self, parsed_episodes): - - pid = self.podcast.get_id() - episodes_to_update = list(islice(parsed_episodes, 0, MAX_EPISODES_UPDATE)) logger.info( "Parsed %d (%d) episodes", len(parsed_episodes), len(episodes_to_update) diff --git a/mygpo/data/flickr.py b/mygpo/data/flickr.py index 1e05e3ae3..76a179f7e 100644 --- a/mygpo/data/flickr.py +++ b/mygpo/data/flickr.py @@ -35,7 +35,7 @@ def get_photo_sizes(photo_id): try: resp_obj = resp.json() - except json.JSONDecodeError as jde: + except json.JSONDecodeError: return [] try: diff --git a/mygpo/data/management/commands/feed-downloader.py b/mygpo/data/management/commands/feed-downloader.py index ce2302917..8fcacb75d 100644 --- a/mygpo/data/management/commands/feed-downloader.py +++ b/mygpo/data/management/commands/feed-downloader.py @@ -1,6 +1,4 @@ from itertools import islice -import traceback -from optparse import make_option from mygpo.maintenance.management.podcastcmd import PodcastCommand from mygpo.data.feeddownloader import update_podcasts diff --git a/mygpo/data/management/commands/tag-downloader.py b/mygpo/data/management/commands/tag-downloader.py index c08e58623..9f314e9b5 100644 --- a/mygpo/data/management/commands/tag-downloader.py +++ b/mygpo/data/management/commands/tag-downloader.py @@ -1,6 +1,5 @@ import time import urllib.request, urllib.error, urllib.parse -from optparse import make_option from mygpo.data import delicious from mygpo.maintenance.management.podcastcmd import PodcastCommand diff --git a/mygpo/data/podcast.py b/mygpo/data/podcast.py index ff464167e..91b045ec9 100644 --- a/mygpo/data/podcast.py +++ b/mygpo/data/podcast.py @@ -40,13 +40,12 @@ def calc_similar_podcasts(podcast, num=20, user_sample=100): # get other podcasts that the user sample subscribes to podcasts = Counter() - for user_id in user_ids: - subscriptions = ( - Podcast.objects.filter(subscription__user__id__in=user_ids) - .distinct("pk") - .exclude(pk=podcast.pk) - ) - podcasts.update(Counter(subscriptions)) + subscriptions = ( + Podcast.objects.filter(subscription__user__id__in=user_ids) + .distinct("pk") + .exclude(pk=podcast.pk) + ) + podcasts.update(Counter(subscriptions)) logger.info( "Found {num_podcasts}, returning top {num_results}".format( num_podcasts=len(podcasts), num_results=num diff --git a/mygpo/directory/management/commands/category-merge-spellings.py b/mygpo/directory/management/commands/category-merge-spellings.py index b3ca3728a..dfcc197b1 100644 --- a/mygpo/directory/management/commands/category-merge-spellings.py +++ b/mygpo/directory/management/commands/category-merge-spellings.py @@ -1,5 +1,3 @@ -from datetime import datetime - from django.core.management.base import BaseCommand from django.utils.text import slugify @@ -20,7 +18,6 @@ def handle(self, *args, **options): ) return - start_time = datetime.utcnow() cat_name = args[0] spellings = args[1:] diff --git a/mygpo/directory/management/commands/update-toplist.py b/mygpo/directory/management/commands/update-toplist.py index 6753de36d..f4eab842f 100644 --- a/mygpo/directory/management/commands/update-toplist.py +++ b/mygpo/directory/management/commands/update-toplist.py @@ -1,5 +1,3 @@ -from optparse import make_option - from django.core.management.base import BaseCommand from mygpo.podcasts.models import Podcast diff --git a/mygpo/directory/search.py b/mygpo/directory/search.py index 48d01c15c..ae6673c8c 100644 --- a/mygpo/directory/search.py +++ b/mygpo/directory/search.py @@ -19,7 +19,7 @@ def search_podcasts(q): if not podcast or not podcast.title: try: updater.update_podcast() - except NoPodcastCreated as npc: + except NoPodcastCreated: return [] try: diff --git a/mygpo/directory/tasks.py b/mygpo/directory/tasks.py index 089c62a1a..d81fb431a 100644 --- a/mygpo/directory/tasks.py +++ b/mygpo/directory/tasks.py @@ -3,7 +3,6 @@ from mygpo.podcasts.models import Podcast from mygpo.subscriptions.models import Subscription -from mygpo.celery import celery @shared_task(max_retries=5) diff --git a/mygpo/directory/tests.py b/mygpo/directory/tests.py index d7470b562..fde138339 100644 --- a/mygpo/directory/tests.py +++ b/mygpo/directory/tests.py @@ -1,9 +1,7 @@ import unittest -import doctest import uuid from datetime import datetime -from django.test import TestCase from mygpo.podcasts.models import Podcast from mygpo.directory.views import ToplistView diff --git a/mygpo/directory/views.py b/mygpo/directory/views.py index 7046f7ea3..c7a2e12b0 100644 --- a/mygpo/directory/views.py +++ b/mygpo/directory/views.py @@ -16,7 +16,6 @@ from django.contrib.auth.decorators import login_required from django.contrib import messages from django.utils.translation import gettext as _ -from django.contrib.auth import get_user_model from mygpo.podcasts.models import Podcast, Episode from mygpo.directory.search import search_podcasts @@ -24,7 +23,6 @@ process_lang_params, get_language_names, get_page_list, - get_podcast_link_target, sanitize_language_codes, ) from mygpo.directory.tags import Topics @@ -335,7 +333,7 @@ def get(self, request, task_id): except (UpdatePodcastException, NoEpisodesException) as ex: messages.error(request, str(ex)) - podcast = None + podcasts = [] return self.render_to_response({"ready": True, "podcasts": podcasts}) diff --git a/mygpo/episodestates/tasks.py b/mygpo/episodestates/tasks.py index ece5f1ea2..878d0116f 100644 --- a/mygpo/episodestates/tasks.py +++ b/mygpo/episodestates/tasks.py @@ -2,7 +2,6 @@ from django_db_geventpool.utils import close_connection from celery import shared_task -from mygpo.celery import celery from mygpo.history.models import EpisodeHistoryEntry from mygpo.episodestates.models import EpisodeState @@ -31,7 +30,7 @@ def update_episode_state(historyentry_pk): ) ) - state = EpisodeState.objects.update_or_create( + EpisodeState.objects.update_or_create( user=user, episode=episode, defaults={"action": historyentry.action, "timestamp": historyentry.timestamp}, diff --git a/mygpo/favorites/migrations/0002_unique.py b/mygpo/favorites/migrations/0002_unique.py index 96d894aa4..8f15ca947 100644 --- a/mygpo/favorites/migrations/0002_unique.py +++ b/mygpo/favorites/migrations/0002_unique.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/migrations/0002_pluralname.py b/mygpo/history/migrations/0002_pluralname.py index 66337eb71..7063e8e88 100644 --- a/mygpo/history/migrations/0002_pluralname.py +++ b/mygpo/history/migrations/0002_pluralname.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/migrations/0006_episodehistory_index.py b/mygpo/history/migrations/0006_episodehistory_index.py index 097063985..3e3e86242 100644 --- a/mygpo/history/migrations/0006_episodehistory_index.py +++ b/mygpo/history/migrations/0006_episodehistory_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/migrations/0007_episodehistory_index.py b/mygpo/history/migrations/0007_episodehistory_index.py index b8c39d0a2..85fdad777 100644 --- a/mygpo/history/migrations/0007_episodehistory_index.py +++ b/mygpo/history/migrations/0007_episodehistory_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/migrations/0008_episodehistory_index.py b/mygpo/history/migrations/0008_episodehistory_index.py index 40168c40d..5aaac003f 100644 --- a/mygpo/history/migrations/0008_episodehistory_index.py +++ b/mygpo/history/migrations/0008_episodehistory_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/migrations/0010_episode_history_index.py b/mygpo/history/migrations/0010_episode_history_index.py index be552ecad..89aeb0a40 100644 --- a/mygpo/history/migrations/0010_episode_history_index.py +++ b/mygpo/history/migrations/0010_episode_history_index.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/history/models.py b/mygpo/history/models.py index 01350a7a2..0e1cea843 100644 --- a/mygpo/history/models.py +++ b/mygpo/history/models.py @@ -1,4 +1,3 @@ -from collections import Counter from datetime import datetime from django.db import models diff --git a/mygpo/history/views.py b/mygpo/history/views.py index 5116034c3..d42314c61 100644 --- a/mygpo/history/views.py +++ b/mygpo/history/views.py @@ -3,6 +3,7 @@ from django.views.decorators.cache import never_cache, cache_control from django.views.decorators.vary import vary_on_cookie from django.contrib.auth.decorators import login_required +from django.contrib import messages from mygpo.users.models import Client from mygpo.history.models import HistoryEntry @@ -55,7 +56,6 @@ def history(request, count=15, uid=None): def podcast_history(request, podcast): """shows the subscription history of the user""" - user = request.user history = HistoryEntry.objects.filter(user=request.user, podcast=podcast) return render( diff --git a/mygpo/maintenance/management/podcastcmd.py b/mygpo/maintenance/management/podcastcmd.py index a17dff936..5f8d19be4 100644 --- a/mygpo/maintenance/management/podcastcmd.py +++ b/mygpo/maintenance/management/podcastcmd.py @@ -1,5 +1,4 @@ -from itertools import islice, chain -from optparse import make_option +from itertools import chain import random from django.core.management.base import BaseCommand diff --git a/mygpo/maintenance/merge.py b/mygpo/maintenance/merge.py index 3dfcc76e5..024a3122c 100644 --- a/mygpo/maintenance/merge.py +++ b/mygpo/maintenance/merge.py @@ -1,5 +1,3 @@ -import collections - from django.db import transaction, IntegrityError from django.contrib.contenttypes.models import ContentType from django.db.models import Model @@ -8,18 +6,12 @@ from mygpo.podcasts.models import ( MergedUUID, - ScopedModel, - OrderedModel, - Slug, - Tag, URL, MergedUUID, Podcast, Episode, ) -from mygpo import utils from mygpo.history.models import HistoryEntry, EpisodeHistoryEntry -from mygpo.publisher.models import PublishedPodcast from mygpo.subscriptions.models import Subscription import logging diff --git a/mygpo/maintenance/tests.py b/mygpo/maintenance/tests.py index 1438b547a..508f664f6 100644 --- a/mygpo/maintenance/tests.py +++ b/mygpo/maintenance/tests.py @@ -1,6 +1,4 @@ import uuid -from datetime import datetime -import unittest from collections import Counter from django.test import TestCase, TransactionTestCase diff --git a/mygpo/podcastlists/migrations/0003_entries_ordering.py b/mygpo/podcastlists/migrations/0003_entries_ordering.py index 76ac3e00c..13098c229 100644 --- a/mygpo/podcastlists/migrations/0003_entries_ordering.py +++ b/mygpo/podcastlists/migrations/0003_entries_ordering.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcastlists/models.py b/mygpo/podcastlists/models.py index 979cd09b6..64d3e9bf3 100644 --- a/mygpo/podcastlists/models.py +++ b/mygpo/podcastlists/models.py @@ -1,11 +1,9 @@ from django.db import models -from django.urls import reverse from django.conf import settings from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey from mygpo.core.models import UpdateInfoModel, OrderedModel, UUIDModel -from mygpo.podcasts.models import Podcast from mygpo.votes.models import VoteMixin from mygpo.utils import set_ordered_entries @@ -37,7 +35,7 @@ def num_entries(self): return self.entries.count() def add_entry(self, obj): - entry, created = PodcastListEntry.objects.get_or_create( + PodcastListEntry.objects.get_or_create( podcastlist=self, content_type=ContentType.objects.get_for_model(obj), object_id=obj.id, diff --git a/mygpo/podcastlists/views.py b/mygpo/podcastlists/views.py index 06c02de98..5b6861bd9 100644 --- a/mygpo/podcastlists/views.py +++ b/mygpo/podcastlists/views.py @@ -1,6 +1,5 @@ import uuid from functools import wraps -from datetime import datetime from django.urls import reverse from django.http import Http404, HttpResponseRedirect, HttpResponseForbidden @@ -12,7 +11,6 @@ from django.contrib import messages from django.contrib.contenttypes.models import ContentType from django.utils.translation import gettext as _ -from django.views import View from mygpo.podcasts.models import Podcast, PodcastGroup from mygpo.podcastlists.models import PodcastList, PodcastListEntry @@ -109,7 +107,7 @@ def create_list(request): messages.error(request, _('"{title}" is not a valid title').format(title=title)) return HttpResponseRedirect(reverse("lists-overview")) - plist, created = PodcastList.objects.get_or_create( + PodcastList.objects.get_or_create( user=request.user, slug=slug, defaults={"id": uuid.uuid1(), "title": title} ) @@ -152,9 +150,7 @@ def delete_list(request, plist, owner): @login_required @list_decorator(must_own=False) def rate_list(request, plist, owner): - now = datetime.utcnow() - - vote, created = Vote.objects.get_or_create( + Vote.objects.get_or_create( user=request.user, content_type=ContentType.objects.get_for_model(plist), object_id=plist.id, diff --git a/mygpo/podcasts/migrations/0021_meta.py b/mygpo/podcasts/migrations/0021_meta.py index 62ed9ec4c..5907bde5a 100644 --- a/mygpo/podcasts/migrations/0021_meta.py +++ b/mygpo/podcasts/migrations/0021_meta.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcasts/migrations/0025_episode_index.py b/mygpo/podcasts/migrations/0025_episode_index.py index 7f071082d..ad710dfa7 100644 --- a/mygpo/podcasts/migrations/0025_episode_index.py +++ b/mygpo/podcasts/migrations/0025_episode_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcasts/migrations/0026_slug_index.py b/mygpo/podcasts/migrations/0026_slug_index.py index 9d6360d21..c1e4e33d9 100644 --- a/mygpo/podcasts/migrations/0026_slug_index.py +++ b/mygpo/podcasts/migrations/0026_slug_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcasts/migrations/0027_episode_index.py b/mygpo/podcasts/migrations/0027_episode_index.py index d46740d3b..65c60c1d6 100644 --- a/mygpo/podcasts/migrations/0027_episode_index.py +++ b/mygpo/podcasts/migrations/0027_episode_index.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcasts/migrations/0029_episode_index_toplist.py b/mygpo/podcasts/migrations/0029_episode_index_toplist.py index f3f124a0d..39981d16d 100644 --- a/mygpo/podcasts/migrations/0029_episode_index_toplist.py +++ b/mygpo/podcasts/migrations/0029_episode_index_toplist.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/podcasts/migrations/0038_podcast_search_vector.py b/mygpo/podcasts/migrations/0038_podcast_search_vector.py index 986883f23..d73eda318 100644 --- a/mygpo/podcasts/migrations/0038_podcast_search_vector.py +++ b/mygpo/podcasts/migrations/0038_podcast_search_vector.py @@ -2,7 +2,7 @@ # Generated by Django 1.10.7 on 2017-06-24 02:07 from __future__ import unicode_literals -from django.contrib.postgres.search import SearchVector, SearchVectorField +from django.contrib.postgres.search import SearchVectorField from django.db import migrations diff --git a/mygpo/publisher/migrations/0002_auto_20140718_1457.py b/mygpo/publisher/migrations/0002_auto_20140718_1457.py index ed766799c..312ecf078 100644 --- a/mygpo/publisher/migrations/0002_auto_20140718_1457.py +++ b/mygpo/publisher/migrations/0002_auto_20140718_1457.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/publisher/utils.py b/mygpo/publisher/utils.py index 2bfa2f53e..76479a525 100644 --- a/mygpo/publisher/utils.py +++ b/mygpo/publisher/utils.py @@ -1,5 +1,5 @@ from collections import namedtuple, defaultdict -from datetime import timedelta, datetime, time +from datetime import timedelta, datetime from mygpo.podcasts.models import Episode from mygpo.utils import daterange diff --git a/mygpo/publisher/views.py b/mygpo/publisher/views.py index dc1b4ff94..031aa2dd7 100644 --- a/mygpo/publisher/views.py +++ b/mygpo/publisher/views.py @@ -6,7 +6,6 @@ HttpResponse, HttpResponseRedirect, HttpResponseForbidden, - Http404, ) from django.core.cache import cache from django.views.decorators.cache import never_cache, cache_control diff --git a/mygpo/search/tasks.py b/mygpo/search/tasks.py index 5b46c2055..d339ed50a 100644 --- a/mygpo/search/tasks.py +++ b/mygpo/search/tasks.py @@ -5,7 +5,6 @@ from celery import shared_task from django_db_geventpool.utils import close_connection -from django.db import transaction from django.contrib.postgres.search import SearchVector from mygpo.podcasts.models import Podcast diff --git a/mygpo/search/tests.py b/mygpo/search/tests.py index 418b7f920..3806630c3 100644 --- a/mygpo/search/tests.py +++ b/mygpo/search/tests.py @@ -1,7 +1,6 @@ import uuid from mygpo.podcasts.models import Podcast -from django.contrib.postgres.search import SearchVector from django.test import TransactionTestCase from django.test.utils import override_settings diff --git a/mygpo/share/userpage.py b/mygpo/share/userpage.py index f1d16ee7e..de040853b 100644 --- a/mygpo/share/userpage.py +++ b/mygpo/share/userpage.py @@ -6,8 +6,6 @@ from django.contrib.sites.requests import RequestSite from django.contrib.auth import get_user_model -from mygpo.podcasts.models import Episode -from mygpo.users.models import HistoryEntry from mygpo.subscriptions import get_subscribed_podcasts from mygpo.decorators import requires_token from mygpo.podcastlists.models import PodcastList diff --git a/mygpo/subscriptions/migrations/0002_unique_constraint.py b/mygpo/subscriptions/migrations/0002_unique_constraint.py index 06b415b31..35b8005fc 100644 --- a/mygpo/subscriptions/migrations/0002_unique_constraint.py +++ b/mygpo/subscriptions/migrations/0002_unique_constraint.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/subscriptions/migrations/0003_remove_podcastconfig.py b/mygpo/subscriptions/migrations/0003_remove_podcastconfig.py index 7481de1da..5da2c99d1 100644 --- a/mygpo/subscriptions/migrations/0003_remove_podcastconfig.py +++ b/mygpo/subscriptions/migrations/0003_remove_podcastconfig.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/subscriptions/migrations/0004_subscription_index.py b/mygpo/subscriptions/migrations/0004_subscription_index.py index d372330cc..40349abe7 100644 --- a/mygpo/subscriptions/migrations/0004_subscription_index.py +++ b/mygpo/subscriptions/migrations/0004_subscription_index.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from django.db import models, migrations +from django.db import migrations class Migration(migrations.Migration): diff --git a/mygpo/subscriptions/models.py b/mygpo/subscriptions/models.py index 4baa4f5af..342106763 100644 --- a/mygpo/subscriptions/models.py +++ b/mygpo/subscriptions/models.py @@ -3,9 +3,8 @@ from django.db import models from django.conf import settings -from mygpo.core.models import UpdateInfoModel, DeleteableModel +from mygpo.core.models import DeleteableModel from mygpo.users.models import Client -from mygpo.users.settings import PUBLIC_SUB_PODCAST from mygpo.podcasts.models import Podcast diff --git a/mygpo/subscriptions/tests.py b/mygpo/subscriptions/tests.py index 5579b09f2..f73721eb5 100644 --- a/mygpo/subscriptions/tests.py +++ b/mygpo/subscriptions/tests.py @@ -1,5 +1,4 @@ import uuid -import unittest from datetime import datetime from django.contrib.auth import get_user_model diff --git a/mygpo/subscriptions/views.py b/mygpo/subscriptions/views.py index e1b6d63fb..ef57b653e 100644 --- a/mygpo/subscriptions/views.py +++ b/mygpo/subscriptions/views.py @@ -13,11 +13,9 @@ from mygpo.podcasts.models import Podcast from mygpo.subscriptions.models import Subscription -from mygpo.users.settings import PUBLIC_SUB_PODCAST from mygpo.api import simple from mygpo.subscriptions import get_subscribed_podcasts from mygpo.decorators import requires_token -from mygpo.users.models import HistoryEntry from mygpo.subscriptions import ( get_subscribed_podcasts, get_subscription_change_history, diff --git a/mygpo/suggestions/apps.py b/mygpo/suggestions/apps.py index 52b78bffb..32f8266c7 100644 --- a/mygpo/suggestions/apps.py +++ b/mygpo/suggestions/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig, apps -from django.db.models.signals import post_save from mygpo.subscriptions.signals import subscription_changed diff --git a/mygpo/suggestions/tasks.py b/mygpo/suggestions/tasks.py index 7fc6631f0..43d3d2ab2 100644 --- a/mygpo/suggestions/tasks.py +++ b/mygpo/suggestions/tasks.py @@ -7,7 +7,6 @@ from celery import shared_task -from mygpo.celery import celery from mygpo.subscriptions import get_subscribed_podcasts from mygpo.suggestions.models import PodcastSuggestion diff --git a/mygpo/suggestions/views.py b/mygpo/suggestions/views.py index 8a5cbc51a..7f0c11e68 100644 --- a/mygpo/suggestions/views.py +++ b/mygpo/suggestions/views.py @@ -26,7 +26,7 @@ def blacklist(request, blacklisted_podcast): ) ) - suggestion = PodcastSuggestion.objects.filter( + PodcastSuggestion.objects.filter( suggested_to=user, podcast=blacklisted_podcast ).update(deleted=True) return HttpResponseRedirect(reverse("suggestions")) diff --git a/mygpo/userfeeds/auth.py b/mygpo/userfeeds/auth.py index ea7e1a597..11dc8c1b9 100644 --- a/mygpo/userfeeds/auth.py +++ b/mygpo/userfeeds/auth.py @@ -1,6 +1,6 @@ from functools import wraps -from django.http import HttpResponse, HttpResponseBadRequest, Http404 +from django.http import HttpResponse from django.shortcuts import get_object_or_404 from django.contrib.auth import get_user_model diff --git a/mygpo/userfeeds/views.py b/mygpo/userfeeds/views.py index fb557a47d..1f780ab0b 100644 --- a/mygpo/userfeeds/views.py +++ b/mygpo/userfeeds/views.py @@ -1,7 +1,6 @@ from django.shortcuts import render, get_object_or_404 from django.contrib.sites.requests import RequestSite from django.contrib.auth import get_user_model -from django.http import Http404 from mygpo.userfeeds.auth import require_token_auth from mygpo.userfeeds.feeds import FavoriteFeed diff --git a/mygpo/users/tasks.py b/mygpo/users/tasks.py index eef2b5c73..f1f328f5a 100644 --- a/mygpo/users/tasks.py +++ b/mygpo/users/tasks.py @@ -7,7 +7,6 @@ from django.contrib.auth import get_user_model from django.conf import settings -from mygpo.celery import celery from . import models from celery.utils.log import get_task_logger @@ -34,7 +33,7 @@ def sync_user(user_pk): # no need to retry on SubscriptionException pass - except Exception as e: + except Exception: logger.exception("retrying task") raise sync_user.retry() diff --git a/mygpo/users/tests.py b/mygpo/users/tests.py index c2861260e..7d8d9c6b3 100644 --- a/mygpo/users/tests.py +++ b/mygpo/users/tests.py @@ -12,7 +12,7 @@ from mygpo.podcasts.models import Podcast from mygpo.maintenance.merge import PodcastMerger from mygpo.api.backend import get_device -from mygpo.users.models import Client, SyncGroup, UserProxy +from mygpo.users.models import Client, UserProxy from mygpo.subscriptions.tasks import subscribe, unsubscribe diff --git a/mygpo/users/urls.py b/mygpo/users/urls.py index 97916885b..85707a699 100644 --- a/mygpo/users/urls.py +++ b/mygpo/users/urls.py @@ -1,6 +1,5 @@ from django.urls import path, register_converter from django.contrib.auth.views import LogoutView -from django.views.generic.base import TemplateView from .views import registration, settings, device, user from mygpo.users import converters diff --git a/mygpo/users/views/registration.py b/mygpo/users/views/registration.py index 6b47348a2..f62a77284 100644 --- a/mygpo/users/views/registration.py +++ b/mygpo/users/views/registration.py @@ -10,7 +10,6 @@ from django.template.loader import render_to_string from django.urls import reverse, reverse_lazy from django.views.generic import TemplateView -from django.views import View from django.contrib import messages from django.contrib.auth import get_user_model from django.contrib.sites.requests import RequestSite @@ -141,8 +140,6 @@ class ActivationView(TemplateView): template_name = "registration/activation_failed.html" def get(self, request, activation_key): - User = get_user_model() - try: user = UserProxy.objects.get( profile__activation_key=activation_key, is_active=False diff --git a/mygpo/users/views/settings.py b/mygpo/users/views/settings.py index d16d51360..f42e6949c 100644 --- a/mygpo/users/views/settings.py +++ b/mygpo/users/views/settings.py @@ -95,8 +95,6 @@ class ProfileView(View): """Updates the public profile and redirects back to the account view""" def post(self, request): - user = request.user - form = ProfileForm(request.POST) if not form.is_valid(): diff --git a/mygpo/users/views/user.py b/mygpo/users/views/user.py index 7d733f9a1..124d96b87 100644 --- a/mygpo/users/views/user.py +++ b/mygpo/users/views/user.py @@ -1,13 +1,8 @@ -import string -import random - from django.shortcuts import render from django.http import HttpResponseRedirect from django.contrib.auth import authenticate, get_user_model -from django.contrib.auth.decorators import login_required from django.contrib import messages from django.contrib.sites.requests import RequestSite -from django.conf import settings from django.utils.translation import gettext as _ from django.views.decorators.cache import never_cache from django.template.loader import render_to_string @@ -20,9 +15,7 @@ import requests from oauth2client.client import FlowExchangeError -from mygpo.decorators import allowed_methods from mygpo.web.forms import RestorePasswordForm -from mygpo.web.forms import ResendActivationForm from mygpo.constants import DEFAULT_LOGIN_REDIRECT from mygpo.web.auth import get_google_oauth_flow from mygpo.users.models import UserProxy diff --git a/mygpo/usersettings/tests.py b/mygpo/usersettings/tests.py index 817584659..8360cc530 100644 --- a/mygpo/usersettings/tests.py +++ b/mygpo/usersettings/tests.py @@ -7,8 +7,6 @@ from django.test import TestCase from mygpo.test import create_auth_string, create_user -from mygpo.api.advanced import settings as views -from mygpo.usersettings.models import UserSettings from mygpo.podcasts.models import Podcast, Episode from mygpo.users.models import Client diff --git a/mygpo/utils.py b/mygpo/utils.py index 6529bfd1d..bd7504e9a 100644 --- a/mygpo/utils.py +++ b/mygpo/utils.py @@ -1,15 +1,9 @@ # -*- coding: utf-8 -*- import json -import functools -import types import subprocess -import os -import operator import sys import re -import collections -import itertools from datetime import datetime, timedelta, date import time import hashlib @@ -17,7 +11,6 @@ import urllib.request, urllib.parse, urllib.error import urllib.request, urllib.error, urllib.parse import zlib -import shlex from django.db import transaction, IntegrityError from django.conf import settings diff --git a/mygpo/web/forms.py b/mygpo/web/forms.py index f603ff646..2b5d76b9c 100644 --- a/mygpo/web/forms.py +++ b/mygpo/web/forms.py @@ -1,5 +1,3 @@ -import re - from django import forms from django.utils.translation import gettext as _ diff --git a/mygpo/web/logo.py b/mygpo/web/logo.py index 74ad072b0..5b7628191 100644 --- a/mygpo/web/logo.py +++ b/mygpo/web/logo.py @@ -5,7 +5,7 @@ import socket import struct -from PIL import Image, ImageDraw +from PIL import Image from django.urls import reverse from django.conf import settings @@ -59,7 +59,6 @@ def get(self, request, size, prefix, filename): logger.warning("Original cover {} not found".format(original)) raise Http404("Cover Art not available" + original) - target_dir = self.get_dir(filename) try: fp = self.storage.open(original, "rb") im = Image.open(fp) @@ -134,7 +133,6 @@ def save_podcast_logo(cls, cover_art_url): prefix = get_prefix(image_sha1) filename = cls.get_original_path(prefix, image_sha1) - dirname = cls.get_dir(filename) # get hash of existing file if LOGO_STORAGE.exists(filename): @@ -157,7 +155,7 @@ def save_podcast_logo(cls, cover_art_url): # remove thumbnails if cover changed if old_hash != new_hash: logger.info("Removing thumbnails") - thumbnails = cls.remove_existing_thumbnails(prefix, filename) + cls.remove_existing_thumbnails(prefix, filename) return cover_art_url diff --git a/mygpo/web/templatetags/charts.py b/mygpo/web/templatetags/charts.py index 774b742f6..04b465058 100644 --- a/mygpo/web/templatetags/charts.py +++ b/mygpo/web/templatetags/charts.py @@ -2,7 +2,6 @@ from django.utils.safestring import mark_safe from django.utils.html import format_html from django.utils.safestring import mark_safe -from django.contrib.staticfiles.storage import staticfiles_storage register = template.Library() diff --git a/mygpo/web/templatetags/episodes.py b/mygpo/web/templatetags/episodes.py index 9ef7e08ee..281e19a25 100644 --- a/mygpo/web/templatetags/episodes.py +++ b/mygpo/web/templatetags/episodes.py @@ -5,7 +5,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage from mygpo import utils -from mygpo.data.mimetype import get_type, get_mimetype +from mygpo.data.mimetype import get_type from mygpo.web.utils import get_episode_link_target diff --git a/mygpo/web/templatetags/facebook.py b/mygpo/web/templatetags/facebook.py index 31d5d9ee3..f96220f4c 100644 --- a/mygpo/web/templatetags/facebook.py +++ b/mygpo/web/templatetags/facebook.py @@ -1,12 +1,8 @@ -import hashlib - from django import template from django.utils.safestring import mark_safe -from django.utils.translation import gettext as _ from mygpo.web.logo import get_logo_url from mygpo.constants import PODCAST_LOGO_BIG_SIZE -from mygpo.web.templatetags.podcasts import create_podcast_logo from mygpo.web.utils import get_episode_link_target, get_podcast_link_target diff --git a/mygpo/web/templatetags/podcasts.py b/mygpo/web/templatetags/podcasts.py index d04f5f329..23815d3ba 100644 --- a/mygpo/web/templatetags/podcasts.py +++ b/mygpo/web/templatetags/podcasts.py @@ -1,8 +1,5 @@ -import hashlib - from django import template from django.utils.safestring import mark_safe -from django.utils.translation import gettext as _ from django.utils.html import strip_tags, format_html from django.contrib.staticfiles.storage import staticfiles_storage diff --git a/mygpo/web/tests.py b/mygpo/web/tests.py index 10277dfa0..dda79335e 100644 --- a/mygpo/web/tests.py +++ b/mygpo/web/tests.py @@ -1,5 +1,3 @@ -import unittest -import doctest import uuid import os.path @@ -7,13 +5,12 @@ import responses from django.conf import settings -from django.test import TestCase, Client, override_settings +from django.test import TestCase, Client from django.urls import reverse from django.core.files.storage import FileSystemStorage from django.contrib.auth import get_user_model from mygpo.podcasts.models import Podcast, Episode, Slug -import mygpo.web.utils from mygpo.web.logo import CoverArt, get_logo_url from mygpo.test import create_auth_string, anon_request @@ -247,7 +244,7 @@ def test_new_logo(self): content_type="image/png", ) - logo_url = get_logo_url(self.podcast, 32) + get_logo_url(self.podcast, 32) # first request CoverArt.save_podcast_logo(self.URL) diff --git a/mygpo/web/urls.py b/mygpo/web/urls.py index f8fabdba5..1c612995b 100644 --- a/mygpo/web/urls.py +++ b/mygpo/web/urls.py @@ -1,5 +1,3 @@ -import re - from django.urls import path from django.conf import settings from django.views.generic.base import TemplateView, RedirectView diff --git a/mygpo/web/utils.py b/mygpo/web/utils.py index 599800b10..03c90a6f5 100644 --- a/mygpo/web/utils.py +++ b/mygpo/web/utils.py @@ -2,7 +2,6 @@ import math import string import collections -from datetime import datetime from django.utils.translation import ngettext from django.views.decorators.cache import never_cache @@ -13,8 +12,6 @@ from babel import Locale, UnknownLocaleError -from mygpo.podcasts.models import Podcast - def get_accepted_lang(request): """returns a list of language codes accepted by the HTTP request""" diff --git a/mygpo/web/views.py b/mygpo/web/views.py index e6630b858..4bcf2aa17 100644 --- a/mygpo/web/views.py +++ b/mygpo/web/views.py @@ -1,23 +1,15 @@ -import sys from collections import defaultdict -from datetime import datetime, timedelta -from django.urls import reverse -from django.http import HttpResponseRedirect -from django.contrib import messages from django.utils.translation import gettext as _ from django.contrib.auth.decorators import login_required from django.shortcuts import render from django.contrib.sites.requests import RequestSite -from django.views import View from django.views.decorators.vary import vary_on_cookie from django.views.decorators.cache import never_cache, cache_control -from mygpo.podcasts.models import Podcast, Episode, Tag -from mygpo.users.models import HistoryEntry, Client +from mygpo.podcasts.models import Podcast, Tag from mygpo.subscriptions import get_subscribed_podcasts from mygpo.web.utils import process_lang_params -from mygpo.utils import parse_range from mygpo.podcastlists.models import PodcastList from mygpo.favorites.models import FavoriteEpisode @@ -87,16 +79,6 @@ def dashboard(request, episode_count=10): if PublishedPodcast.objects.filter(publisher=request.user).exists(): checklist.append("publish") - tomorrow = datetime.today() + timedelta(days=1) - - # newest_episodes = Episode.objects.filter(podcast__in=subscribed_podcasts, - # released__lt=tomorrow).\ - # select_related('podcast').\ - # prefetch_related('slugs', - # 'podcast__slugs').\ - # order_by('-released')[:episode_count] - # - newest_episodes = [] # we only show the "install reader" link in firefox, because we don't know