heroku
This commit is contained in:
parent
8957a71ef9
commit
391ac1beaa
@ -1,4 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from django.db import models
|
||||
from django.utils import timezone
|
||||
@ -23,14 +23,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)
|
||||
|
||||
try: step = (max_font - min_font)/float(max_tag-min_tag)
|
||||
except: step = 1
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user