示例#1
0
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)
示例#2
0
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})
示例#3
0
def all_tags(request):
    return render_response(request, "tag/tag_list.html")
示例#4
0
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})
示例#5
0
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})
示例#6
0
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})
示例#7
0
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})
示例#8
0
def faves(request):
    faves = FavoriteList.objects.get(owner='sixminutes').photos.all()
    return render_response(request, 'flickr/photo_faves.html', {'photos': faves})