|
|
|
|
@ -52,18 +52,56 @@ class Service(TranslatableModel): |
|
|
|
|
uses for control form |
|
|
|
|
:return: |
|
|
|
|
""" |
|
|
|
|
state = {'event_type':[1, 2], |
|
|
|
|
'region': [], |
|
|
|
|
'country':[], |
|
|
|
|
'country_all': True, |
|
|
|
|
'expositions': [], |
|
|
|
|
'conferences': []} |
|
|
|
|
from country.models import Country |
|
|
|
|
country_all = False |
|
|
|
|
country = [] |
|
|
|
|
region = [] |
|
|
|
|
expositions = [] |
|
|
|
|
conferences = [] |
|
|
|
|
service = self.url |
|
|
|
|
event_type = [key for key, value in self.type.iteritems() if value] |
|
|
|
|
if not event_type: |
|
|
|
|
return {'event_type': event_type, |
|
|
|
|
'region': region, |
|
|
|
|
'country': country, |
|
|
|
|
'country_all': country_all, |
|
|
|
|
'expositions': expositions, |
|
|
|
|
'conferences': conferences} |
|
|
|
|
|
|
|
|
|
count1 = Country.objects.filter().count() |
|
|
|
|
count2 = Country.objects.filter(services=getattr(Country.services, service)).count() |
|
|
|
|
country_all = count1 == count2 |
|
|
|
|
if not country_all: |
|
|
|
|
from exposition.models import Exposition |
|
|
|
|
from conference.models import Conference |
|
|
|
|
from country.models import Area |
|
|
|
|
from django.utils.translation import get_language |
|
|
|
|
lang = get_language() |
|
|
|
|
|
|
|
|
|
countries = list(Country.objects.language(lang).filter(services=getattr(Country.services, service))) |
|
|
|
|
|
|
|
|
|
expositions = [(item.id, item.name) for item in Exposition.enable.upcoming().exclude(country__in=countries, services=getattr(Exposition.services, service))] |
|
|
|
|
conferences = [(item.id, item.name) for item in Conference.enable.upcoming().exclude(country__in=countries, services=getattr(Conference.services, service))] |
|
|
|
|
|
|
|
|
|
region = [] |
|
|
|
|
countries = set(countries) |
|
|
|
|
for item in list(Area.objects.language(lang).all()): |
|
|
|
|
print(item) |
|
|
|
|
area_countries = item.countries() |
|
|
|
|
if set(area_countries).issubset(countries): |
|
|
|
|
region.append((item.id, item.name)) |
|
|
|
|
countries = countries - set(area_countries) |
|
|
|
|
|
|
|
|
|
country = [(item.id, item.name) for item in list(countries)] |
|
|
|
|
|
|
|
|
|
state = {'event_type': event_type, |
|
|
|
|
'region': region, |
|
|
|
|
'country': country, |
|
|
|
|
'country_all': country_all, |
|
|
|
|
'expositions': expositions, |
|
|
|
|
'conferences': conferences} |
|
|
|
|
return state |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.db.models.signals import post_save |
|
|
|
|
from functions.signal_handlers import post_save_handler |
|
|
|
|
|
|
|
|
|
@ -118,6 +156,7 @@ class Translation(AbstractOrder): |
|
|
|
|
languages = models.TextField(blank=True) |
|
|
|
|
themes = models.TextField(blank=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Visit(AbstractOrder): |
|
|
|
|
fr = models.DateField() |
|
|
|
|
to = models.DateField() |
|
|
|
|
|