def list_favorites(request): user = request.user site = RequestSite(request) favorites = FavoriteEpisode.episodes_for_user(user) recently_listened = last_played_episodes(user) favfeed = FavoriteFeed(user) feed_url = favfeed.get_public_url(site.domain) podcast = Podcast.objects.filter(urls__url=feed_url).first() token = request.user.profile.favorite_feeds_token return render( request, 'favorites.html', { 'episodes': favorites, 'feed_token': token, 'site': site, 'podcast': podcast, 'recently_listened': recently_listened, }, )
def get(self, request, username): User = get_user_model() user = User.objects.get(username=username) month_ago = datetime.today() - timedelta(days=31) site = RequestSite(request) context = { "page_user": user, "site": site.domain, "subscriptions_token": user.profile.get_token("subscriptions_token"), "favorite_feeds_token": user.profile.get_token("favorite_feeds_token"), "lists": self.get_podcast_lists(user), "subscriptions": self.get_subscriptions(user), "recent_episodes": last_played_episodes(user), "seconds_played_total": seconds_played(user), "seconds_played_month": seconds_played(user, month_ago), "favorite_episodes": FavoriteEpisode.episodes_for_user(user), "num_played_episodes_total": num_played_episodes(user), "num_played_episodes_month": num_played_episodes(user, month_ago), } return render(request, "userpage.html", context)
def get(self, request, username): User = get_user_model() user = User.objects.get(username=username) month_ago = datetime.today() - timedelta(days=31) site = RequestSite(request) context = { 'page_user': user, 'flattr_username': user.profile.settings.get_wksetting(FLATTR_USERNAME), 'site': site.domain, 'subscriptions_token': user.profile.get_token('subscriptions_token'), 'favorite_feeds_token': user.profile.get_token('favorite_feeds_token'), 'lists': self.get_podcast_lists(user), 'subscriptions': self.get_subscriptions(user), 'recent_episodes': last_played_episodes(user), 'seconds_played_total': seconds_played(user), 'seconds_played_month': seconds_played(user, month_ago), 'favorite_episodes': FavoriteEpisode.episodes_for_user(user), 'num_played_episodes_total': num_played_episodes(user), 'num_played_episodes_month': num_played_episodes(user, month_ago), } return render(request, 'userpage.html', context)
def list_favorites(request): user = request.user site = RequestSite(request) favorites = FavoriteEpisode.episodes_for_user(user) recently_listened = last_played_episodes(user) favfeed = FavoriteFeed(user) feed_url = favfeed.get_public_url(site.domain) podcast = Podcast.objects.filter(urls__url=feed_url).first() token = request.user.profile.favorite_feeds_token return render( request, "favorites.html", { "episodes": favorites, "feed_token": token, "site": site, "podcast": podcast, "recently_listened": recently_listened, }, )
def get(self, request, username): User = get_user_model() user = User.objects.get(username=username) month_ago = datetime.today() - timedelta(days=31) site = RequestSite(request) context = { 'page_user': user, 'site': site.domain, 'subscriptions_token': user.profile.get_token('subscriptions_token'), 'favorite_feeds_token': user.profile.get_token('favorite_feeds_token'), 'lists': self.get_podcast_lists(user), 'subscriptions': self.get_subscriptions(user), 'recent_episodes': last_played_episodes(user), 'seconds_played_total': seconds_played(user), 'seconds_played_month': seconds_played(user, month_ago), 'favorite_episodes': FavoriteEpisode.episodes_for_user(user), 'num_played_episodes_total': num_played_episodes(user), 'num_played_episodes_month': num_played_episodes(user, month_ago), } return render(request, 'userpage.html', context)
def favorites(request, username): favorites = FavoriteEpisode.episodes_for_user(request.user) domain = RequestSite(request).domain e_data = lambda e: episode_data(e, domain) ret = list(map(e_data, favorites)) return JsonResponse(ret)
def get_episodes(self): return FavoriteEpisode.episodes_for_user(self.user)