本文整理汇总了Python中mygpo.core.models.Podcast.for_oldid方法的典型用法代码示例。如果您正苦于以下问题:Python Podcast.for_oldid方法的具体用法?Python Podcast.for_oldid怎么用?Python Podcast.for_oldid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mygpo.core.models.Podcast
的用法示例。
在下文中一共展示了Podcast.for_oldid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _decorator
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import for_oldid [as 别名]
def _decorator(request, pid, *args, **kwargs):
try:
pid = int(pid)
except (TypeError, ValueError):
raise Http404
podcast = Podcast.for_oldid(pid)
if not podcast:
raise Http404
return f(request, podcast, *args, **kwargs)
示例2: blacklist
# 需要导入模块: from mygpo.core.models import Podcast [as 别名]
# 或者: from mygpo.core.models.Podcast import for_oldid [as 别名]
def blacklist(request, podcast_id):
podcast_id = int(podcast_id)
blacklisted_podcast = Podcast.for_oldid(podcast_id)
suggestion = Suggestions.for_user(request.user)
@repeat_on_conflict(['suggestion'])
def _update(suggestion, podcast_id):
suggestion.blacklist.append(podcast_id)
suggestion.save()
_update(suggestion=suggestion, podcast_id=blacklisted_podcast.get_id())
request.user.suggestions_up_to_date = False
request.user.save()
return HttpResponseRedirect(reverse('suggestions'))