From c3143027c5163dbfc4febdcbeb6e2e74a6ca3305 Mon Sep 17 00:00:00 2001 From: Slava Kyrachevsky Date: Tue, 27 Jun 2017 16:21:01 +0300 Subject: [PATCH] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D0=B8=D0=B8,?= =?UTF-8?q?=20=D0=B2=D1=81=D1=82=D1=80=D0=BE=D0=B8=D0=BB=20=D1=81=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BE=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/article/models.py | 1 - apps/article/views.py | 3 +- apps/comments/__init__.py | 0 apps/comments/admin.py | 97 --- apps/comments/forms.py | 22 - apps/comments/matfilter.py | 73 --- apps/comments/migrations/0001_initial.py | 452 -------------- apps/comments/migrations/__init__.py | 0 apps/comments/models.py | 37 -- apps/comments/tests.py | 16 - apps/comments/views.py | 55 -- apps/conference/models.py | 2 - apps/conference/views.py | 3 +- apps/exposition/models.py | 2 - apps/exposition/views.py | 3 +- proj/settings.py | 1 - templates/client/article/article.html | 37 +- .../client/exposition/exposition_detail.html | 548 ++++++++++++++++- templates/client/includes/comments.html | 12 + .../conference/conference_partner.html | 38 +- templates/client/includes/event_steps.html | 10 +- .../client/includes/exposition/expo_paid.html | 442 -------------- .../exposition/exposition_object.html | 577 ------------------ 23 files changed, 556 insertions(+), 1875 deletions(-) delete mode 100644 apps/comments/__init__.py delete mode 100644 apps/comments/admin.py delete mode 100644 apps/comments/forms.py delete mode 100644 apps/comments/matfilter.py delete mode 100644 apps/comments/migrations/0001_initial.py delete mode 100644 apps/comments/migrations/__init__.py delete mode 100644 apps/comments/models.py delete mode 100644 apps/comments/tests.py delete mode 100644 apps/comments/views.py create mode 100644 templates/client/includes/comments.html delete mode 100644 templates/client/includes/exposition/expo_paid.html delete mode 100644 templates/client/includes/exposition/exposition_object.html diff --git a/apps/article/models.py b/apps/article/models.py index 3d21ea1c..a53ac99a 100644 --- a/apps/article/models.py +++ b/apps/article/models.py @@ -99,7 +99,6 @@ class Article(TranslatableModel): ) files = generic.GenericRelation('file.FileModel', content_type_field='content_type', object_id_field='object_id') - comments = generic.GenericRelation('comments.Comment') class Meta: ordering = ['-publish_date'] diff --git a/apps/article/views.py b/apps/article/views.py index e6e29a88..3d7fa48d 100644 --- a/apps/article/views.py +++ b/apps/article/views.py @@ -10,7 +10,6 @@ from functions.custom_views import ListView from theme.models import Tag, Theme from meta.views import MetadataMixin -from comments.views import CommentMixin from .models import Article from .forms import BlogFilterForm, NewsFilterForm @@ -149,7 +148,7 @@ class BlogList(MetadataMixin, ListView): return context -class BlogDetail(CommentMixin, MetadataMixin, DetailView): +class BlogDetail(MetadataMixin, DetailView): model = Article slug_field = 'slug' template_name = 'client/article/article.html' diff --git a/apps/comments/__init__.py b/apps/comments/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/apps/comments/admin.py b/apps/comments/admin.py deleted file mode 100644 index 6a3142b3..00000000 --- a/apps/comments/admin.py +++ /dev/null @@ -1,97 +0,0 @@ -# -*- coding: utf-8 -*- -from functools import update_wrapper, partial - -from django.contrib import admin -from django.contrib.admin.util import unquote -from django.conf.urls import patterns, url -from django.core.exceptions import PermissionDenied -from django.core.urlresolvers import reverse_lazy, reverse -from django.http import Http404 -from django.utils.translation import ugettext_lazy as _ -from django.utils.html import escape -from django.utils.encoding import force_text - -from functions.admin import DefaultAdmin -from functions.http import JsonResponse - -from .models import Comment - - -class CommentAdmin(DefaultAdmin): - class Media: - js = ( - "js/jquery.truncator.js", - "admin/js/comments_manage.js", - ) - # css = { - # 'all': ("admin/css/comments_manage.css",), - # } - list_display = ['text', 'ip', 'user', 'hide'] - list_select_related = True - list_filter = ('hidden', ) - date_hierarchy = 'created' - readonly_fields = ['ip', 'created', 'parent', 'user'] - fieldsets = ( - (None, - {'fields': (('created', 'hidden',), - 'ip', - 'user', - 'text', )}), - ) - - def hide(self, obj): - body = u'{alt}' \ - u' {label}' \ - u' | {label2}'\ - .format(**self.get_yesno_image_data(obj)) - return body - hide.short_description = _(u'Модерирование') - hide.allow_tags = True - - def urls(self): - urlpatterns = self.get_urls() - def wrap(view): - def wrapper(*args, **kwargs): - return self.admin_site.admin_view(view)(*args, **kwargs) - return update_wrapper(wrapper, view) - info = self.model._meta.app_label, self.model._meta.module_name - _urlpatterns = patterns('', - url(r'^(?P\d+)/ajax/(?Phide|show|banro|unbanro)/$', - wrap(self.ajax_view), - name='%s_%s_ajax' % info), - ) - return _urlpatterns + urlpatterns - urls = property(urls) - - def get_yesno_image_data(self, obj): - return { - 'url': '/static/admin/img/icon-{0}.gif'.format('no' if obj.hidden else 'yes'), - 'alt': str(not obj.hidden), - 'href': reverse('admin:comments_comment_ajax', args=[obj.id, 'hide' if not obj.hidden else 'show']), - 'label': unicode(_(u'Опубликовать') if obj.hidden else _(u'Скрыть')), - 'href2': reverse('admin:comments_comment_ajax', args=[obj.id, 'banro' if not obj.user.readonly else 'unbanro']), - 'label2': unicode(_(u'Снять RO') if obj.user.readonly else _(u'Наложить RO')), - } - - def ajax_view(self, request, object_id, extra_context=None, *args, **kwargs): - "The 'change' admin view for this model." - action = kwargs.get('action') - model = self.model - opts = model._meta - obj = self.get_object(request, unquote(object_id)) - if not self.has_change_permission(request, obj) or not request.is_ajax(): - raise PermissionDenied - if obj is None: - raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_text(opts.verbose_name), 'key': escape(object_id)}) - - if action in ['hide', 'show']: - obj.hidden = True if action == 'hide' else False - obj.save() - else: - obj.user.readonly = True if action == 'banro' else False - obj.user.save() - - return JsonResponse(dict({'success': True}, **self.get_yesno_image_data(obj))) - ajax_view.csrf_exempt = True - -admin.site.register(Comment, CommentAdmin) diff --git a/apps/comments/forms.py b/apps/comments/forms.py deleted file mode 100644 index 314c1fb4..00000000 --- a/apps/comments/forms.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -from django import forms -from django.utils.translation import ugettext as _ - -from functions.forms import EmptySelect -from .models import Comment - - -class CommentForm(forms.ModelForm): - class Meta: - model = Comment - fields = ['parent', 'text'] - widgets = dict(parent=EmptySelect) - - def save(self, commit=True): - obj = super(CommentForm, self).save(commit=False) - return obj - - def clean(self): - if getattr(self._user, 'readonly', True): - raise forms.ValidationError(_(u'Вы не можете оставлять комментарии. Вам выдано ограничение ReadOnly.')) - return super(CommentForm, self).clean() diff --git a/apps/comments/matfilter.py b/apps/comments/matfilter.py deleted file mode 100644 index 2a10fe89..00000000 --- a/apps/comments/matfilter.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- encoding: utf-8 -*- - -version = "0.0.1" -version_info = (0,0,1) -""" -Модуль для поиска нецензурных слов (мата) в тексте - -Лицензия: LGPL (http://www.opensource.org/licenses/lgpl-2.1.php) - -Пример: - - from matfilter import matfilter - some_data = "любой текст для проверки" - if len(matfilter(some_data)): - print "Пожалуйста, уберите из текста нецензурные выражения." - -Источник: -https://bitbucket.org/spanasik/django-matfilter -""" -import re - -PATTERNS = (ur"(\b[сs]{1}[сsц]{0,1}[uуy](?:[ч4]{0,1}[иаakк][^ц])\w*\b)", - ur"(\b(?!пло|стра|[тл]и)(\w(?!(у|пло)))*[хx][уy](й|йа|[еeё]|и|я|ли|ю)(?!га)\w*\b)", - ur"(\b(п[oо]|[нз][аa])*[хx][eе][рp]\w*\b)", - ur"(\b[мm][уy][дd]([аa][кk]|[oо]|и)\w*\b)", - ur"(\b\w*д[рp](?:[oо][ч4]|[аa][ч4])(?!л)\w*\b)", - ur"(\b(?!(?:кило)?[тм]ет)(?!смо)[а-яa-z]*(? {% endif %} -
-

{% trans 'Комментарии' %}

- {% for comment in comments %} -
-
- {{ comment.user.get_full_name }} -
-
{{ comment.text }}
- {% trans "Ответить на комментарий" %} - - {% for answer in comment.childs %} -
-
- {{ answer.user.get_full_name }} -
-
{{ answer.text }}
-
- {% endfor %} -
- {% endfor %} - - {% if user.is_authenticated %} -
-
- {% csrf_token %} -

- - - -

-
-
- {% else %} - - {% endif %} -
+ {% include 'client/includes/comments.html' %} {% endblock %} diff --git a/templates/client/exposition/exposition_detail.html b/templates/client/exposition/exposition_detail.html index 9842ec58..a2eea247 100644 --- a/templates/client/exposition/exposition_detail.html +++ b/templates/client/exposition/exposition_detail.html @@ -1,5 +1,5 @@ {% extends 'client/base_catalog.html' %} -{% load i18n %} +{% load i18n static %} {% load thumbnail %} {% load template_filters %} @@ -25,17 +25,545 @@ {% endblock %} -{% block page_title %} -{% endblock %} +{% block page_title %}{% endblock %} + +{% block paginator %}{% endblock %} {% block content_list %} - {% if object.paid_new_id and object.paid_new.public %} - {% include 'client/includes/exposition/expo_paid.html' with exposition=object %} - {% else %} - {% include 'client/includes/exposition/exposition_object.html' with exposition=object %} - {% endif %} -{% endblock %} + {% block page_body %} +
+
+ + +
+
+

+ {% if exposition.main_title %} + {{ exposition.name|safe }} - {{ exposition.main_title|lowfirst|safe }} + {% else %} + {{ exposition.name|safe }} + {% endif %} +

+
+ +
+ {% with obj=exposition %} + {% include 'client/includes/show_date_block.html' %} + {% endwith %} + + {% if not request.GET.debug == '1' %} + {% include "client/includes/sharing_block.html" %} + {% endif %} +
+ + {% if exposition.place %} +
+
+
+ {{ exposition.place.country }}, {{ exposition.place.city }}, + {% if exposition.place.web_page %} + {{ exposition.place.name }} + {% else %} + {{ exposition.place.name }} + {% endif %} +
+ {# #} +
+ + + + +
+ {% else %} +
+
+
+ {{ exposition.country.name }}, {{ exposition.city.name }}{% if exposition.place_alt %} , {{ exposition.place_alt }}{% endif %} +
+
+
+ {% endif %} +
+
+ +
+
+
+ {% with event=exposition user=user %} + {% include 'client/includes/visit_button.html' %} + {% endwith %} + + {% include 'client/includes/calendar_button.html' with obj=exposition %} + {% if request.user.is_admin %} + {% trans 'изменить' %} + {% endif %} +
+ + +
+ +
+
+
+ +
+
+ {% with tags=exposition.tags %} + {% for tag in tags %} + {{ tag.name }}{% if forloop.counter != tags|length %},{% endif %} + {% endfor %} + {% endwith %} +
+
+ +
+
+ {% trans 'Посетителю' %} + {% trans 'Экспоненту' %} + {% if object.paid_new_id and object.paid_new.public %} + {% trans 'Официальный сайт' %} + {% endif %} +
+
+ + {# Описание выставки #} +
+

{% trans 'О выставке' %} {{ exposition.name|safe }}

+ + + + + {% if exposition.description %} +
+ {{ exposition.description|safe }} +
+ {% elif default_description %} +
+ {{ default_description|safe }} +
+ {% else %} + {% include "client/includes/exposition/default_description.html" with expo=exposition className="expo_description_detail" %} + {% endif %} +
+ + {% include 'client/includes/banners/expo_detail.html' %} + +
+ + {# Дополнительная информация #} +
+
{% trans 'Дополнительная информация' %}
+ + + +
+ {% if exposition.organiser.all.exists %} +
{% trans 'Организатор' %}:
+
+ {% with organisers=exposition.organiser.all %} + {% for organiser in organisers %} + {{ organiser.name }}
+ {% endfor %} + {% endwith %} +
+ {% else %} + {% if exposition.org %} + {% for item in exposition.org_split %} +
{% if forloop.counter == 1 %}{% trans 'Организатор' %}:{% endif %}
+ +
+ {{ item }} +
+ {% endfor %} + + {% endif %} + {% endif %} + + {% if exposition.web_page %} +
{% trans 'Веб-сайт' %}:
+
+ {{ exposition.web_page }} +
+ {% endif %} + + {% if exposition.get_audience %} +
{% trans 'Аудитория' %}:
+
{{ exposition.get_audience }}
+ {% endif %} + + {% if exposition.get_periodic %} +
{% trans 'Периодичность' %}:
+
{{ exposition.get_periodic }}
+ {% endif %} + + {% if exposition.products %} +
{% trans 'Экспонируемые продукты' %}:
+
{{ exposition.products|safe }}
+ {% endif %} + + {% if exposition.time %} +
{% trans 'Время работы' %}:
+
{{ exposition.time|safe }}
+ {% endif %} +
+
+ +
+ {% include 'client/includes/booking_block.html' with city=exposition.city place=exposition.place event=exposition %} + + {# Планируют быть #} +
+ {% with visitors=exposition.users.all|slice:":17" %} +

{% trans 'Планируют быть на' %} {{ exposition.name }}

+ + + + +

{% trans 'Пока никто не отметился на событии.' %}

+ +

{% trans 'Все посетители' %}

+ {% endwith %} + + {% with event=exposition user=user %} + {% include 'client/includes/visit_button.html' %} + {% endwith %} +
+ + {# Слайдер фото с прошлой выставки #} + {% if exposition.get_photos %} + {% with photos=exposition.get_photos %} +
+

{% trans 'Фотографии с прошлой конференции' %}

+
+ {% for photo in photos %} + {% thumbnail photo.image '936x468' crop="center" as im %} + + {% endthumbnail %} + {% endfor %} +
+ +
+ {% for photo in photos %} + {% thumbnail photo.image '137x95' crop="center" as im %} + + {% endthumbnail %} + {% endfor %} +
+
+ {% endwith %} + {% endif %} + +
+ {% include "client/includes/article/articles_in_event.html" with event=exposition news_list=news %} +
+ + {% if exposition.members or exposition.visitors or exposition.foundation_year or exposition.area %} +
+ {% if exposition.area %} +
+
{% trans 'Общая выставочная площадь' %}
+
+ {{ exposition.area }} {% trans 'м²' %} +
+
+ {% endif %} +
+ {% if exposition.members %} +
{{ exposition.members }} {% trans 'участников' %}
+ {% endif %} + + {% if exposition.visitors %} +
{{ exposition.visitors }} {% trans 'посетителей' %}
+ {% endif %} + + {% if exposition.foundation_year %} +
{% trans 'Основано в' %} {{ exposition.foundation_year }} {% trans 'году' %}
+ {% endif %} +
+
+ {% endif %} + +
+

{% trans 'Комментарии' %}

+ {% include 'client/includes/comments.html' %} +
+
+ +
+ {% include 'client/includes/sharing_block_full.html' %} +
+ + {% include 'client/includes/banners/catalog_inner_2.html' %} + + {% with themes=exposition.themes %} + {% for theme in themes %} +
  • {{ theme.name }} ({{ theme.expositions_number }})
  • + {% endfor %} + {% endwith %} + + {% if exposition.get_nearest_events %} +
    +
    + {% with themes=exposition.themes %} + {% trans 'Ближайшие выставки по тематике' %} «{% for theme in themes %}{{ theme.name }}{% if not forloop.last %}, {% endif %}{% endfor %}» + {% endwith %} +
    + +
    + {% endif %} + + {% include 'client/includes/banners/detail_inner_3.html' %} + + + {% endblock %} + + {% block content_text %} + {% endblock %} + + {% block popup %} + {% include 'client/popups/advertise_member.html' with form=advertising_form %} + {% include 'client/popups/event_news_subscribe.html' %} + {% endblock %} + + {% block scripts %} + {% if request.GET.debug == '1' %} + + {% else %} + + {% endif %} + + + + + {% endblock %} {% endblock %} diff --git a/templates/client/includes/comments.html b/templates/client/includes/comments.html new file mode 100644 index 00000000..c16773f2 --- /dev/null +++ b/templates/client/includes/comments.html @@ -0,0 +1,12 @@ +
    + diff --git a/templates/client/includes/conference/conference_partner.html b/templates/client/includes/conference/conference_partner.html index 25031d4b..c904f107 100644 --- a/templates/client/includes/conference/conference_partner.html +++ b/templates/client/includes/conference/conference_partner.html @@ -431,43 +431,7 @@

    {% trans 'Комментарии' %}

    - - {% for comment in comments %} -
    -
    - {{ comment.user.get_full_name }} -
    -
    {{ comment.text }}
    - {% trans "Ответить на комментарий" %} - - {% for answer in comment.childs %} -
    -
    - {{ answer.user.get_full_name }} -
    -
    {{ answer.text }}
    -
    - {% endfor %} -
    - {% endfor %} - - {% if user.is_authenticated %} -
    -
    - {% csrf_token %} -{# {{ commentform.as_p }}#} -

    {% trans 'Оставьте свой отзыв:' %}

    -

    - - - - -

    -
    -
    - {% else %} - - {% endif %} + {% include 'client/includes/comments.html' %}
    diff --git a/templates/client/includes/event_steps.html b/templates/client/includes/event_steps.html index fc64830d..6adcfe05 100644 --- a/templates/client/includes/event_steps.html +++ b/templates/client/includes/event_steps.html @@ -13,18 +13,10 @@ {% trans 'УЧАСТВОВАТЬ' %} -{% comment %} -
  • -
    {% trans 'Забронируйте площадь по лучшей цене' %}
    - {% trans "Заявка на участие" %} -
  • -{% endcomment %}
  • {% trans 'Забронируйте отель по лучшей цене' %}
    booking.com
  • - -
  • {% trans 'Задайте свой вопрос напрямую организатору' %}
    {% trans 'Запрос организатору' %} @@ -34,7 +26,7 @@ {% else %} {# Непроплаченая конференция #}
    -
    {% if event.catalog == '/expo/' %}{% trans 'Участвовать в выставке' %}{% else %}{% trans 'Посетить конференцию' %}{% endif %}
    +
    {% trans 'Посетить конференцию' %}