@ -7,7 +7,7 @@ from django.contrib.contenttypes.models import ContentType
from django . conf import settings
from django . views . generic import ListView , DetailView
from django . utils . translation import ugettext as _
from django . shortcuts import get_object_or_404
from django . shortcuts import get_object_or_404 , render_to_response
from django . http import Http404
from django . utils import translation
#models
@ -19,7 +19,6 @@ from country.models import Country
from city . models import City
from theme . models import Theme , Tag
from note . models import Note
from functions . custom_views import ExpoSearchView
from functions . search_forms import ExpositionSearchForm
from functions . custom_views import ExpoSearchView
@ -82,10 +81,24 @@ class ExpositionByCity(ExpositionBy):
class ExpositionSearchView ( ExpoSearchView ) :
#paginate_by = 10
template_name = ' exposition/search.html '
template_name = ' client/ exposition/search.html'
search_form = ExpositionSearchForm
model = Exposition
"""
def search_test ( request ) :
if request . GET :
form = ExpositionSearchForm ( request . GET )
if form . is_valid ( ) :
form . data_with_parents = form . get_form_data ( )
object_list = form . search ( )
context = { }
context [ ' object_list ' ] = object_list
context [ ' search_form ' ] = form
return render_to_response ( ' client/exposition/search.html ' , context )
"""
def exposition_add_calendar ( request , id ) :
args = { ' success ' : False }
@ -270,6 +283,8 @@ class ExpoCatalog(ListView):
filter_object = None
year = None
month = None
country = None
city = None
def get_filtered_qs ( self ) :
# diferent for views
@ -282,7 +297,16 @@ class ExpoCatalog(ListView):
if year :
qs = qs . filter ( data_begin__year = year )
# info for breadscrumbs
self . year = { ' text ' : year , ' link ' : ' %s %s / %s / ' % ( self . catalog_url , self . filter_object . url , year ) }
if self . country :
self . year = { ' text ' : year , ' link ' : ' %s %s /country/ %s / %s / ' %
( self . catalog_url , self . filter_object . url , self . country . url , year )
}
elif self . city :
self . year = { ' text ' : year , ' link ' : ' %s %s /city/ %s / %s / ' %
( self . catalog_url , self . filter_object . url , self . city . url , year )
}
else :
self . year = { ' text ' : year , ' link ' : ' %s %s / %s / ' % ( self . catalog_url , self . filter_object . url , year ) }
month = self . kwargs . get ( ' month ' )
@ -294,7 +318,14 @@ class ExpoCatalog(ListView):
' nov ' : { ' value ' : 11 , ' name ' : _ ( u ' Ноябрь ' ) } , ' dec ' : { ' value ' : 12 , ' name ' : _ ( u ' Декабрь ' ) } }
if month and monthes . get ( month ) :
qs = qs . filter ( data_begin__month = monthes [ month ] [ ' value ' ] )
self . month = { ' text ' : monthes [ month ] [ ' name ' ] , ' link ' : ' %s %s / %s / %s / ' % ( self . catalog_url , self . filter_object . url , year , month ) }
if self . country :
self . month = { ' text ' : monthes [ month ] [ ' name ' ] , ' link ' : ' %s %s /country/ %s / %s / %s / ' %
( self . catalog_url , self . filter_object . url , self . country . url , year , month ) }
elif self . city :
self . month = { ' text ' : monthes [ month ] [ ' name ' ] , ' link ' : ' %s %s /city/ %s / %s / %s / ' %
( self . catalog_url , self . filter_object . url , self . city . url , year , month ) }
else :
self . month = { ' text ' : monthes [ month ] [ ' name ' ] , ' link ' : ' %s %s / %s / %s / ' % ( self . catalog_url , self . filter_object . url , year , month ) }
return qs . order_by ( ' data_begin ' )
@ -330,15 +361,40 @@ class ExpoCityCatalog(ExpoCatalog):
class ExpoThemeCatalog ( ExpoCatalog ) :
template_name = ' exposition/catalog_theme.html '
catalog_url = ' /expo/theme/ '
country = None
city = None
def get_filtered_qs ( self ) :
#this method used in parent get_queryset
slug = self . kwargs . get ( ' slug ' )
country_slug = self . kwargs . get ( ' country_slug ' )
city_slug = self . kwargs . get ( ' city_slug ' )
theme = get_object_or_404 ( Theme , url = slug )
qs = self . model . enable . filter ( theme = theme )
if country_slug :
country = get_object_or_404 ( Country , url = country_slug )
self . country = country
qs = qs . filter ( country = country )
if city_slug :
city = get_object_or_404 ( City , url = city_slug )
self . city = city
qs = qs . filter ( city = city )
self . filter_object = theme
return qs
def get_context_data ( self , * * kwargs ) :
context = super ( ExpoThemeCatalog , self ) . get_context_data ( * * kwargs )
if self . country :
context [ ' country ' ] = self . country
if self . city :
context [ ' city ' ] = self . city
return context
class ExpoTagCatalog ( ExpoCatalog ) :
catalog_url = ' /expo/tag/ '