remotes/origin/stage6
Alexander Burdeiny 9 years ago
parent 67a758c2bd
commit 2e931e9b00
  1. 14
      conference/views.py
  2. 12
      events/views.py
  3. 18
      exposition/views.py
  4. 52
      functions/custom_views.py
  5. 9
      support/dev/settings.py
  6. 9
      support/prod/settings.py
  7. 7
      templates/client/base_catalog.html
  8. 3
      templates/client/events/filter_listview.html
  9. 5
      templates/client/includes/events/filter_result.html
  10. 5
      templates/client/includes/reverseorder_warning.html

@ -19,7 +19,7 @@ from django.views.generic import DetailView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from functions.cache_mixin import CacheMixin, JitterCacheMixin from functions.cache_mixin import CacheMixin, JitterCacheMixin
from functions.custom_views import ListView from functions.custom_views import ListView, ReverseOrderMixin
from functions.views_help import get_side_items from functions.views_help import get_side_items
from functions.utils import CachedSting from functions.utils import CachedSting
@ -129,7 +129,7 @@ class ConferenceByCity(ConferenceBy):
# .order_by('translations__name').distinct() # .order_by('translations__name').distinct()
class ConferenceCatalog(ConfFilterMixin, ConfSectionKindMixin, JitterCacheMixin, MetadataMixin, ListView): class ConferenceCatalog_(ConfFilterMixin, ConfSectionKindMixin, JitterCacheMixin, MetadataMixin, ListView):
cache_range = settings.CACHE_RANGE cache_range = settings.CACHE_RANGE
model = Conference model = Conference
paginate_by = settings.CLIENT_PAGINATION paginate_by = settings.CLIENT_PAGINATION
@ -201,13 +201,17 @@ class ConferenceCatalog(ConfFilterMixin, ConfSectionKindMixin, JitterCacheMixin,
return qs.order_by('data_begin') return qs.order_by('data_begin')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ConferenceCatalog, self).get_context_data(**kwargs) context = super(ConferenceCatalog_, self).get_context_data(**kwargs)
context['filter_object'] = self.filter_object context['filter_object'] = self.filter_object
context['year'] = self.year context['year'] = self.year
context['month'] = self.month context['month'] = self.month
context['catalog_url'] = self.catalog_url context['catalog_url'] = self.catalog_url
return context return context
class ConferenceCatalog(ReverseOrderMixin, ConferenceCatalog_):
pass
class ConferenceCountryCatalog(ConferenceCatalog): class ConferenceCountryCatalog(ConferenceCatalog):
catalog_url = '/conference/country/' catalog_url = '/conference/country/'
stat_kind = 'country' stat_kind = 'country'
@ -466,7 +470,7 @@ class ConferenceDetail(ObjectStatMixin, JitterCacheMixin, MetadataMixin, DetailV
return context return context
class ConferenceList(ConfFilterMixin, ConfSectionMixin, MetadataMixin, JitterCacheMixin, ListView): class ConferenceList(ReverseOrderMixin, ConfFilterMixin, ConfSectionMixin, MetadataMixin, JitterCacheMixin, ListView):
cache_range = settings.CACHE_RANGE cache_range = settings.CACHE_RANGE
model = Conference model = Conference
paginate_by = settings.CLIENT_PAGINATION paginate_by = settings.CLIENT_PAGINATION
@ -496,6 +500,8 @@ class ConferenceList(ConfFilterMixin, ConfSectionMixin, MetadataMixin, JitterCac
'link': '%s%s/%s/'%(self.catalog_url, year, month), 'link': '%s%s/%s/'%(self.catalog_url, year, month),
'slug': self.kwargs.get('month') 'slug': self.kwargs.get('month')
} }
if not qs.exists():
qs = self.get_reversed_qs(qs)
return qs return qs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):

@ -7,6 +7,7 @@ from django.template import RequestContext
from haystack.query import SearchQuerySet from haystack.query import SearchQuerySet
from functions.custom_views import ContextMixin from functions.custom_views import ContextMixin
from functions.custom_views import ReverseOrderMixin
from functions.custom_views import ListView from functions.custom_views import ListView
from functions.http import JsonResponse from functions.http import JsonResponse
@ -16,7 +17,7 @@ from conference.models import Conference
from .forms import FilterForm from .forms import FilterForm
class FilterListView(ContextMixin, FormMixin, ListView): class FilterListView_(ContextMixin, FormMixin, ListView):
initial_ctx = {'filtering': True} initial_ctx = {'filtering': True}
form_class = FilterForm form_class = FilterForm
paginate_by = settings.CLIENT_PAGINATION paginate_by = settings.CLIENT_PAGINATION
@ -25,7 +26,7 @@ class FilterListView(ContextMixin, FormMixin, ListView):
_ajax_form_template_name = 'includes/events/filter_form.html' _ajax_form_template_name = 'includes/events/filter_form.html'
def get_form_kwargs(self): def get_form_kwargs(self):
kwargs = super(FilterListView, self).get_form_kwargs() kwargs = super(FilterListView_, self).get_form_kwargs()
kwargs.update({'data': self.request.GET}) kwargs.update({'data': self.request.GET})
return kwargs return kwargs
@ -60,13 +61,13 @@ class FilterListView(ContextMixin, FormMixin, ListView):
return JsonResponse(data) return JsonResponse(data)
# usual get # usual get
return super(FilterListView, self).get(request, *args, **kwargs) return super(FilterListView_, self).get(request, *args, **kwargs)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
return self.get(request, *args, **kwargs) return self.get(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(FilterListView, self).get_context_data(**kwargs) context = super(FilterListView_, self).get_context_data(**kwargs)
# get params for paginator # get params for paginator
get = self.form.data.copy() get = self.form.data.copy()
if 'page' in get: if 'page' in get:
@ -74,3 +75,6 @@ class FilterListView(ContextMixin, FormMixin, ListView):
context['GETparams'] = get.urlencode() if hasattr(get, 'urlencode') else '' context['GETparams'] = get.urlencode() if hasattr(get, 'urlencode') else ''
return context return context
class FilterListView(ReverseOrderMixin, FilterListView_):
pass

@ -22,7 +22,7 @@ from django.views.generic import DetailView
from django.views.generic.edit import FormMixin from django.views.generic.edit import FormMixin
from functions.cache_mixin import JitterCacheMixin from functions.cache_mixin import JitterCacheMixin
from functions.custom_views import ExpoSearchView, ListView from functions.custom_views import ExpoSearchView, ListView, ReverseOrderMixin
from functions.search_forms import ExpositionSearchForm from functions.search_forms import ExpositionSearchForm
from functions.views_help import get_side_items from functions.views_help import get_side_items
from functions.utils import CachedSting from functions.utils import CachedSting
@ -132,7 +132,7 @@ class ExpositionByCity(ExpositionBy):
# .order_by('translations__name').distinct() # .order_by('translations__name').distinct()
class ExpositionSearchView(SearchFilterMixin, ExpoSearchView): class ExpositionSearchView(ReverseOrderMixin, SearchFilterMixin, ExpoSearchView):
#paginate_by = 10 #paginate_by = 10
template_name = 'client/exposition/search.html' template_name = 'client/exposition/search.html'
search_form = ExpositionSearchForm search_form = ExpositionSearchForm
@ -350,7 +350,7 @@ class ExpositionServiceView(JitterCacheMixin, MetadataMixin, FormMixin, DetailVi
return self.initial.copy() return self.initial.copy()
class ExpoList(ExpoFilterMixin, ExpoSectionMixin, MetadataMixin, JitterCacheMixin, ListView): class ExpoList_(ExpoFilterMixin, ExpoSectionMixin, MetadataMixin, JitterCacheMixin, ListView):
cache_range = [60*30, 60*60] cache_range = [60*30, 60*60]
model = Exposition model = Exposition
paginate_by = settings.CLIENT_PAGINATION paginate_by = settings.CLIENT_PAGINATION
@ -382,14 +382,17 @@ class ExpoList(ExpoFilterMixin, ExpoSectionMixin, MetadataMixin, JitterCacheMixi
return qs return qs
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ExpoList, self).get_context_data(**kwargs) context = super(ExpoList_, self).get_context_data(**kwargs)
context['catalog_url'] = self.catalog_url context['catalog_url'] = self.catalog_url
context['year'] = self.year context['year'] = self.year
context['month'] = self.month context['month'] = self.month
return context return context
class ExpoList(ReverseOrderMixin, ExpoList_):
pass
class ExpoCatalog(ExpoFilterMixin, ExpoSectionKindMixin, JitterCacheMixin, MetadataMixin, ListView):
class ExpoCatalog_(ExpoFilterMixin, ExpoSectionKindMixin, JitterCacheMixin, MetadataMixin, ListView):
model = Exposition model = Exposition
paginate_by = settings.CLIENT_PAGINATION paginate_by = settings.CLIENT_PAGINATION
template_name = 'client/exposition/catalog.html' template_name = 'client/exposition/catalog.html'
@ -452,7 +455,7 @@ class ExpoCatalog(ExpoFilterMixin, ExpoSectionKindMixin, JitterCacheMixin, Metad
return qs.order_by('data_begin') return qs.order_by('data_begin')
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(ExpoCatalog, self).get_context_data(**kwargs) context = super(ExpoCatalog_, self).get_context_data(**kwargs)
context['filter_object'] = self.filter_object context['filter_object'] = self.filter_object
context['year'] = self.year context['year'] = self.year
context['month'] = self.month context['month'] = self.month
@ -461,6 +464,9 @@ class ExpoCatalog(ExpoFilterMixin, ExpoSectionKindMixin, JitterCacheMixin, Metad
context['tag_for_filter'] = self.kwargs['tag'] context['tag_for_filter'] = self.kwargs['tag']
return context return context
class ExpoCatalog(ReverseOrderMixin, ExpoCatalog_):
pass
class ExpoCountryCatalog(ExpoCatalog): class ExpoCountryCatalog(ExpoCatalog):
catalog_url = '/expo/country/' catalog_url = '/expo/country/'

@ -1,11 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import random import random
from datetime import datetime
from accounts.models import User
from city.models import City
from company.models import Company
from conference.models import Conference
from country.models import Country
from django.conf import settings from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
@ -20,6 +16,7 @@ from django.core.paginator import (
from django.core.urlresolvers import reverse_lazy from django.core.urlresolvers import reverse_lazy
from django.db.models.deletion import ProtectedError from django.db.models.deletion import ProtectedError
from django.db.models.loading import get_model from django.db.models.loading import get_model
from django.db.models.query import QuerySet
from django.http import Http404, HttpResponse, HttpResponseRedirect from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response from django.shortcuts import render_to_response
from django.utils.translation import get_language as lang from django.utils.translation import get_language as lang
@ -31,13 +28,20 @@ from django.views.generic.detail import (
SingleObjectTemplateResponseMixin SingleObjectTemplateResponseMixin
) )
from django.views.generic.edit import ModelFormMixin, ProcessFormView from django.views.generic.edit import ModelFormMixin, ProcessFormView
from accounts.models import User
from city.models import City
from company.models import Company
from conference.models import Conference
from country.models import Country
from exposition.models import Exposition from exposition.models import Exposition
from file.forms import FileModelForm from file.forms import FileModelForm
from file.models import TmpFile from file.models import TmpFile
from functions.forms import AdminSearchForm from functions.forms import AdminSearchForm
from functions.views_help import split_params from functions.views_help import split_params
from functions.http import JsonResponse from functions.http import JsonResponse
from haystack.query import EmptySearchQuerySet from haystack.query import EmptySearchQuerySet, SearchQuerySet
from haystack.backends import SearchNode
from hvad.utils import get_translation_aware_manager from hvad.utils import get_translation_aware_manager
from meta.models import MetaSetting from meta.models import MetaSetting
from meta.views import Meta from meta.views import Meta
@ -547,3 +551,39 @@ class ContextMixin(object):
context = super(ContextMixin, self).get_context_data(**kwargs) context = super(ContextMixin, self).get_context_data(**kwargs)
context.update(self.extra_ctx) context.update(self.extra_ctx)
return context return context
class ReverseOrderMixin(ContextMixin):
def get_reversed_qs(self, qs):
# exclude_fields
ef = ['data_begin', 'data_end']
children = list(filter(lambda x: not set([y[0].col for y in x.children]).intersection(ef), qs.query.where.children))
qs.query.where.children = children
self.extra_ctx['events_reversed'] = True
return qs.filter(data_begin__lte=datetime.now()).order_by('-data_begin')
def get_reversed_sqs(self, qs):
# exclude_fields
ef = ['data_begin']
childrens = []
for children in qs.query.query_filter.children:
if isinstance(children, tuple):
if children[0].startswith('data_begin'):
continue
elif isinstance(children, SearchNode):
node_childrens = list(filter(lambda x: not x[0].startswith('data_begin'), children.children))
if node_childrens:
children.children = node_childrens
childrens.append(children)
qs.query.query_filter.children = childrens
self.extra_ctx['events_reversed'] = True
qs.query.clear_order_by()
return qs.filter(data_begin__lte=datetime.now()).order_by('-data_begin')
def get_queryset(self):
qs = super(ReverseOrderMixin, self).get_queryset()
if isinstance(qs, SearchQuerySet) and qs.count() == 0:
qs = self.get_reversed_sqs(qs)
elif isinstance(qs, QuerySet) and not qs.exists():
qs = self.get_reversed_qs(qs)
return qs

@ -256,9 +256,11 @@ SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True
SOCIAL_AUTH_PIPELINE = ( SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.social_uid',
'functions.pipeline.get_email', # vk
'functions.pipeline.load_user', 'functions.pipeline.load_user',
'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user', 'social.pipeline.social_auth.social_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.get_username', 'social.pipeline.user.get_username',
'functions.pipeline.require_email', 'functions.pipeline.require_email',
#'social.pipeline.mail.mail_validation', #'social.pipeline.mail.mail_validation',
@ -266,7 +268,6 @@ SOCIAL_AUTH_PIPELINE = (
#'social.pipeline.user.create_user', #'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_by_email', 'social.pipeline.social_auth.associate_by_email',
'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details' 'social.pipeline.user.user_details'
) )
@ -513,6 +514,12 @@ C_CITY_CATALOG_KEY = 'conf_city_catalog'
C_COUNTRY_CATALOG_KEY = 'conf_country_catalog' C_COUNTRY_CATALOG_KEY = 'conf_country_catalog'
E_CITY_CATALOG_KEY = 'expo_city_catalog' E_CITY_CATALOG_KEY = 'expo_city_catalog'
E_COUNTRY_CATALOG_KEY = 'expo_country_catalog' E_COUNTRY_CATALOG_KEY = 'expo_country_catalog'
DEFAULT_DESCRIPTION = {
'e_description_ru': 'templates/client/includes/conference/default_description_ru.html',
'e_description_en': 'templates/client/includes/conference/default_description_en.html',
'c_description_ru': 'templates/client/includes/exposition/default_description_ru.html',
'c_description_en': 'templates/client/includes/exposition/default_description_en.html',
}
try: try:
from local import * from local import *

@ -256,9 +256,11 @@ SOCIAL_AUTH_USERNAME_IS_FULL_EMAIL = True
SOCIAL_AUTH_PIPELINE = ( SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details', 'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid', 'social.pipeline.social_auth.social_uid',
'functions.pipeline.get_email', # vk
'functions.pipeline.load_user', 'functions.pipeline.load_user',
'social.pipeline.social_auth.auth_allowed', 'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user', 'social.pipeline.social_auth.social_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.get_username', 'social.pipeline.user.get_username',
'functions.pipeline.require_email', 'functions.pipeline.require_email',
#'social.pipeline.mail.mail_validation', #'social.pipeline.mail.mail_validation',
@ -266,7 +268,6 @@ SOCIAL_AUTH_PIPELINE = (
#'social.pipeline.user.create_user', #'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_by_email', 'social.pipeline.social_auth.associate_by_email',
'social.pipeline.social_auth.associate_user', 'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details' 'social.pipeline.user.user_details'
) )
@ -512,6 +513,12 @@ C_CITY_CATALOG_KEY = 'conf_city_catalog'
C_COUNTRY_CATALOG_KEY = 'conf_country_catalog' C_COUNTRY_CATALOG_KEY = 'conf_country_catalog'
E_CITY_CATALOG_KEY = 'expo_city_catalog' E_CITY_CATALOG_KEY = 'expo_city_catalog'
E_COUNTRY_CATALOG_KEY = 'expo_country_catalog' E_COUNTRY_CATALOG_KEY = 'expo_country_catalog'
DEFAULT_DESCRIPTION = {
'e_description_ru': 'templates/client/includes/conference/default_description_ru.html',
'e_description_en': 'templates/client/includes/conference/default_description_en.html',
'c_description_ru': 'templates/client/includes/exposition/default_description_ru.html',
'c_description_en': 'templates/client/includes/exposition/default_description_en.html',
}
try: try:
from local import * from local import *

@ -86,6 +86,13 @@
{% block page_body %} {% block page_body %}
<div class="page-body clearfix"> <div class="page-body clearfix">
{% block exclude_events_revesred %}
{% if events_reversed %}
{% include "client/includes/reverseorder_warning.html" %}
{% endif %}
{% endblock exclude_events_revesred %}
{% block content_list %} {% block content_list %}
{% endblock %} {% endblock %}

@ -15,6 +15,9 @@
</div> </div>
{% endblock %} {% endblock %}
{% block exclude_events_revesred %}
{% endblock exclude_events_revesred %}
{% block content_list %} {% block content_list %}
{% with query=object_list %} {% with query=object_list %}
{% if query %} {% if query %}

@ -2,6 +2,11 @@
{% load i18n %} {% load i18n %}
{% load template_filters %} {% load template_filters %}
{% if events_reversed %}
{% include "client/includes/reverseorder_warning.html" %}
{% endif %}
<ul class="cat-list cl-exhibitions"> <ul class="cat-list cl-exhibitions">
{# START FOR #} {# START FOR #}

@ -0,0 +1,5 @@
{% load i18n %}
<div class="reversed" style="border-left: 5px solid #ff9900; padding: 8px 12px; background-color: #fff; font-size:17px; text-align: justify; margin-bottom: 10px">{% trans "Выставки по указанным параметрам не найдены. Попробуйте упростить параметры или расширить временные рамки. Также Вы можете посмотреть уже прошедшие события и проверить самостоятельно, будут ли они проходить в будущем." %}</div>
<div class="page-title">
<h2 style="font-size:30px;">{% trans "Прошедшие события" %}</h2>
</div>
Loading…
Cancel
Save