def mytags(request): tags_podcast = {} tags_tag = defaultdict(list) for podcast_id, taglist in tags_for_user(request.user).items(): podcast = podcast_by_id(podcast_id) tags_podcast[podcast] = taglist for tag in taglist: tags_tag[ tag ].append(podcast) return render(request, 'mytags.html', { 'tags_podcast': tags_podcast, 'tags_tag': dict(tags_tag.items()), })
def get_tags(podcast, user): tags = {} for t in tags_for_podcast(podcast): tag_str = t.lower() tags[tag_str] = False if not user.is_anonymous(): users_tags = tags_for_user(user, podcast.get_id()) for t in users_tags.get(podcast.get_id(), []): tag_str = t.lower() tags[tag_str] = True tag_list = [{'tag': key, 'is_own': value} for key, value in tags.iteritems()] tag_list.sort(key=lambda x: x['tag']) if len(tag_list) > MAX_TAGS_ON_PAGE: tag_list = filter(lambda x: x['is_own'], tag_list) tag_list.append({'tag': '...', 'is_own': False}) has_own = any(t['is_own'] for t in tag_list) return tag_list, has_own
def dashboard(request, episode_count=10): subscribed_podcasts = list(request.user.get_subscribed_podcasts()) site = RequestSite(request) checklist = [] if request.user.devices: checklist.append('devices') if subscribed_podcasts: checklist.append('subscriptions') if favorite_episode_ids_for_user(request.user): checklist.append('favorites') if not request.user.get_token('subscriptions_token'): checklist.append('share') if not request.user.get_token('favorite_feeds_token'): checklist.append('share-favorites') if not request.user.get_token('userpage_token'): checklist.append('userpage') if tags_for_user(request.user): checklist.append('tags') # TODO add podcastlist_count_for_user if podcastlists_for_user(request.user._id): checklist.append('lists') if request.user.published_objects: checklist.append('publish') if request.user.get_wksetting(FLATTR_TOKEN): checklist.append('flattr') if request.user.get_wksetting(FLATTR_AUTO): checklist.append('auto-flattr') tomorrow = datetime.today() + timedelta(days=1) podcasts = PodcastSet(subscribed_podcasts) newest_episodes = podcasts.get_newest_episodes(tomorrow, episode_count) def get_random_podcasts(): random_podcast = next(random_podcasts(), None) if random_podcast: yield random_podcast.get_podcast() # we only show the "install reader" link in firefox, because we don't know # yet how/if this works in other browsers. # hints appreciated at https://bugs.gpodder.org/show_bug.cgi?id=58 show_install_reader = \ 'firefox' in request.META.get('HTTP_USER_AGENT', '').lower() return render(request, 'dashboard.html', { 'user': request.user, 'subscribed_podcasts': subscribed_podcasts, 'newest_episodes': list(newest_episodes), 'random_podcasts': get_random_podcasts(), 'checklist': checklist, 'site': site, 'show_install_reader': show_install_reader, })