From 37bd10ec681440d41bb5fd29d8fec01b1c5fa1fc Mon Sep 17 00:00:00 2001 From: Alexander Burdeiny Date: Sun, 14 Aug 2016 13:02:01 +0300 Subject: [PATCH] =?UTF-8?q?1459:=20=D0=AD=D1=82=D0=B0=D0=BF=20=E2=84=965:?= =?UTF-8?q?=20=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B8=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=20-=20=D0=9C=D0=B5=D1=82=D0=B0-=D1=82=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=B4=D0=B0=D1=87=D0=B5:?= =?UTF-8?q?=20=D0=9D=D0=B0=D0=B4=D0=BE=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0?= =?UTF-8?q?=D1=82=D1=8C,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=82=D0=B5=D1=85,=20=D1=83=20=D0=BA=D0=BE=D1=82.=20?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D1=8C=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20-=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=D0=B8=D0=BB?= =?UTF-8?q?=D1=81=D1=8F=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=B0?= =?UTF-8?q?=D0=B1=D0=B7=D0=B0=D1=86=20(=D0=BD=D0=BE=20=D0=BD=D0=B5=20?= =?UTF-8?q?=D0=B1=D0=BE=D0=BB=D0=B5=D0=B5=20200=20=D1=81=D0=B8=D0=BC=D0=B2?= =?UTF-8?q?=D0=BE=D0=BB=D0=BE=D0=B2=20=D1=81=20=D0=BF=D1=80=D0=BE=D0=B1?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BC=D0=B8=20-=20=D0=BC=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D1=82=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D1=82=D0=BE=202=20=D0=BF=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D1=8B=D1=85=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F),=20=D0=B0=20=D1=83=20=D1=81=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=82=D0=B8=D0=B9,=20=D1=83=20=D0=BA=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=8B=D1=85=20=D0=BD=D0=B5=D1=82=20=D0=BE=D0=BF=D0=B8?= =?UTF-8?q?=D1=81=D0=B0=D0=BD=D0=B8=D1=8F=20-=20=D0=B8=D0=B7=20=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20=D1=83=D0=B6=D0=B5=20=D0=BF=D0=BE=20=D1=88?= =?UTF-8?q?=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=D0=B8=D0=B7=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D1=83.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meta/models.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/meta/models.py b/meta/models.py index f93faaec..2b58f938 100644 --- a/meta/models.py +++ b/meta/models.py @@ -1,15 +1,19 @@ # -*- coding: utf-8 -*- import copy + from django.db import models -from django.utils import translation from django.db.models.signals import post_save +from django.utils import translation +from django.utils.html import strip_tags from django.utils.translation import ugettext_lazy as _ from django.conf import settings from django.core.cache import cache -from functions.signal_handlers import post_save_handler + from hvad.models import TranslatableModel, TranslatedFields, TranslationManager from pymorphy.django_conf import default_morph as morph +from functions.signal_handlers import post_save_handler + # additional funcs def get_month_inflect(value, key): @@ -117,6 +121,12 @@ class MetaSetting(TranslatableModel): except: pass + if obj and getattr(obj, 'description', None): + try: + description = strip_tags(obj.description).strip('\n').splitlines()[0][:200] + except (IndexError, ): + pass + return {'title': title, 'description': description, 'keywords': keywords, 'h1': h1} def get_param(self, obj, field):