def tag_detail(request, tag): articles = TaggedItem.objects.get_by_model(Article, tag) links = TaggedItem.objects.get_by_model(Bookmark, tag) videos = TaggedItem.objects.get_by_model(Video, tag) photos = TaggedItem.objects.get_by_model(Photo, tag) quotes = TaggedItem.objects.get_by_model(Quote, tag) count = articles.count() + links.count() + videos.count() + photos.count() + quotes.count() tag_dict = { "tag": tag, "total": count, "articles": articles, "links": links, "videos": videos, "photos": photos, "quotes": quotes, } return render_response(request, "tag/tag_detail.html", tag_dict)
def list(request, app, model, ordering="-pub_date"): ctx = None items = model.objects.all().order_by("%s" % ordering) if model.__name__.lower() == "tumblelogitem": links = Bookmark.objects.count() photos = Photo.sixminutes.all().count() videos = Video.objects.count() tweets = Tweet.objects.count() quotes = Quote.objects.count() ctx = { "total": items.count(), "links": links, "photos": photos, "videos": videos, "tweets": tweets, "quotes": quotes, } page = request.GET.get("page", 1) paginator = DiggPaginator(items, 10, page=page, body=7, tail=2, padding=3) template_name = "%s/%s_list.html" % (app.lower(), model.__name__.lower()) return render_response(request, template_name, {"page": page, "paginator": paginator, "extra": ctx})
def all_tags(request): return render_response(request, "tag/tag_list.html")
def year_group(request, year): date = datetime.strptime(year, "%Y") year = date.year logs = TumblelogItem.objects.filter(pub_date__year=year).order_by('-pub_date') return render_response(request, 'tumblelog/year_group.html', {'entries': logs, 'showing_date': date})
def day_group(request, year, month, day): date = datetime.strptime("%s %s %s" % (year, month, day), "%Y %m %d") month = date.month day = date.day logs = TumblelogItem.objects.filter(pub_date__year=year, pub_date__month=month, pub_date__day=day).order_by('-pub_date') return render_response(request, 'tumblelog/day_group.html', {'entries': logs, 'showing_date': date})
def month_group(request, year, month): date = datetime.strptime("%s %s" % (year, month), "%Y %m") # this is lame... i must be doing something wrong month = date.month logs = TumblelogItem.objects.filter(pub_date__year=year, pub_date__month=month).order_by('-pub_date') return render_response(request, 'tumblelog/month_group.html', {'entries': logs, 'showing_date': date})
def list(request): items = Photo.sixminutes.all() page = request.GET.get('page', 1) paginator = DiggPaginator(items, 10, page=page, body=7, tail=2, padding=3) return render_response(request, 'flickr/photo_list.html', {'page': page, 'paginator': paginator})
def faves(request): faves = FavoriteList.objects.get(owner='sixminutes').photos.all() return render_response(request, 'flickr/photo_faves.html', {'photos': faves})