From 925e62be0cd2a02361d01c8297c748e7bbd875d7 Mon Sep 17 00:00:00 2001 From: Anna Date: Tue, 21 Nov 2017 15:02:43 +0300 Subject: [PATCH] upd --- blog/models.py | 15 +++++++++++++++ blog/static/css/new.css | 13 ++++++------- blog/templates/blog/base.html | 19 ++++++++++--------- blog/templatetags/pagination_filters.py | 5 ++--- blog/views.py | 7 ++++++- 5 files changed, 39 insertions(+), 20 deletions(-) diff --git a/blog/models.py b/blog/models.py index ba56b64..63970c6 100644 --- a/blog/models.py +++ b/blog/models.py @@ -4,6 +4,8 @@ from django.db import models from django.utils import timezone from tinymce.models import HTMLField from taggit.managers import TaggableManager +from taggit.models import Tag +from django.db.models import Count, Max, Min class Post(models.Model): author = models.ForeignKey('auth.User') @@ -22,3 +24,16 @@ class Post(models.Model): def __unicode__(self): return self.title + +def font_size(self): + min_font = 12 + max_font = 28 + v = Tag.objects.all().annotate(c = Count('post')).filter(c__gt = 0).aggregate(Min('c'), Max('c')) + max_tag, min_tag = v["c__max"], v["c__min"] + step = (max_font - min_font)/float(max_tag-min_tag) + tag_count = Post.objects.filter(tags__name=self.name).count() + #print Tag.objects.filter(name=self.name).annotate(c = Count('post')) + font = int(min_font + (tag_count-min_tag)*step) + return font + +Tag.f = font_size diff --git a/blog/static/css/new.css b/blog/static/css/new.css index 4187179..7ba10b5 100644 --- a/blog/static/css/new.css +++ b/blog/static/css/new.css @@ -136,16 +136,17 @@ display: inline; margin-right: 10px; } - .paginator { - font-size: 20px; + #pagination { + font-size: 16px; list-style: none; - text-align: center; + //text-align: center; } - .paginator a { + #pagination a { display: inline-block; padding: 2 1; text-decoration:none; - text-align: center; + //text-align: center; } + div.post { font-size: 16px;} .post { box-shadow: 0 0.005em 0.01em 0 rgba(0, 0, 0, 0.12), 0 2px 10px 0 rgba(0, 0, 0, 0.12); box-sizing: border-box; @@ -153,8 +154,6 @@ color: #1a1a1a; display: block; font-family: 'Open Sans' - font-size: 14px; - font-weight: 300; line-height: 26px; margin: 0 0 10px 0; diff --git a/blog/templates/blog/base.html b/blog/templates/blog/base.html index 299f49a..2e217cd 100644 --- a/blog/templates/blog/base.html +++ b/blog/templates/blog/base.html @@ -5,7 +5,7 @@ BLOG - + @@ -48,7 +48,7 @@

Теги

{% for tag in cloud %} - {{ tag.name }}({{ tag.c }}) + {{ tag.name }} {% endfor %} @@ -57,18 +57,18 @@