diff --git a/city/models.py b/city/models.py index e006efd3..90a4c7c5 100644 --- a/city/models.py +++ b/city/models.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import date from django.db import models from django.db.models.signals import post_save, pre_save from hvad.models import TranslatableModel, TranslatedFields, TranslationManager @@ -7,6 +8,9 @@ from sorl.thumbnail import ImageField # models from directories.models import Iata from service.models import Service +from exposition.models import Exposition +from place_exposition.models import PlaceExposition +from organiser.models import Organiser # custom functions from functions.db import db_table_exists from functions.signal_handlers import post_save_handler @@ -24,6 +28,8 @@ class City(TranslatableModel): """ objects = ExpoManager() + catalog = '/city/' + services = BitField(flags=flags) url = models.SlugField(unique=True) @@ -54,9 +60,30 @@ class City(TranslatableModel): return self.lazy_translation_getter('name', self.pk) def get_hotels(self): - return self.hotels.all()[:4] + def get_events(self): + now = date.today() + return Exposition.objects.filter(data_begin__gte=now, city=self).order_by('data_begin')[:3] + + def get_places(self): + return PlaceExposition.objects.filter(city=self)[:3] + + def get_organisers(self): + return Organiser.objects.filter(city=self) + + def get_permanent_url(self): + return self.catalog+self.url + + def events_catalog(self): + return Exposition.catalog+'city-%s'%self.url + + def places_catalog(self): + return PlaceExposition.catalog+'city-%s'%self.url + + + + class Hotel(TranslatableModel): url = models.URLField(max_length=255) @@ -71,7 +98,6 @@ class Hotel(TranslatableModel): translations = TranslatedFields( name = models.CharField(max_length=255, blank=True), address = models.CharField(max_length=255, blank=True) - ) post_save.connect(post_save_handler, sender=City) diff --git a/city/urls.py b/city/urls.py new file mode 100644 index 00000000..e9393f57 --- /dev/null +++ b/city/urls.py @@ -0,0 +1,7 @@ +# -*- coding: utf-8 -*- +from django.conf.urls import patterns, url +from views import CityView + +urlpatterns = patterns('', + url(r'(?P.*)', CityView.as_view()), +) diff --git a/city/views.py b/city/views.py new file mode 100644 index 00000000..8035e526 --- /dev/null +++ b/city/views.py @@ -0,0 +1,8 @@ +from django.views.generic import DetailView +from models import City + + +class CityView(DetailView): + model = City + slug_field = 'url' + template_name = 'city/city.html' \ No newline at end of file diff --git a/country/management/__init__.py b/country/management/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/country/management/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/country/management/commands/__init__.py b/country/management/commands/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/country/management/commands/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/country/management/commands/country_coordinates.py b/country/management/commands/country_coordinates.py new file mode 100644 index 00000000..abe3a38d --- /dev/null +++ b/country/management/commands/country_coordinates.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +import MySQLdb +from MySQLdb.cursors import DictCursor +from django.core.management.base import BaseCommand, CommandError +from country.models import Country + + +class Command(BaseCommand): + def handle(self, *args, **options): + # local database(will not work on production) + db = MySQLdb.connect(host="localhost", + user="root", + passwd="qazedc", + db="test", + charset='utf8', + cursorclass=DictCursor) + cursor = db.cursor() + # !!!database can change + sql = "SELECT country_code as code, geo_lat as latitude, geo_lng as longitude FROM test.country_country LEFT JOIN localization.meta_location ON test.country_country.country_code=localization.meta_location.iso COLLATE utf8_unicode_ci WHERE localization.meta_location.type='CO' AND geo_lat IS NOT NULL;" + cursor.execute(sql) + result = cursor.fetchall() + for item in result: + updates = Country.objects.filter(country_code=item['code']).update(latitude=item['latitude'], longitude=item['longitude']) + if updates: + print(item['code']) \ No newline at end of file diff --git a/country/models.py b/country/models.py index 6f1de3f7..68ec685c 100644 --- a/country/models.py +++ b/country/models.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- +from datetime import date from django.db import models from django.utils.translation import ugettext as _ from django.contrib.contenttypes import generic @@ -9,6 +10,9 @@ from bitfield import BitField from directories.models import Language, Currency from city.models import City from service.models import Service +from exposition.models import Exposition +from place_exposition.models import PlaceExposition +from organiser.models import Organiser # func from functions.custom_fields import EnumField from functions.db import db_table_exists @@ -40,6 +44,7 @@ class Area(TranslatableModel): def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk)) + class Country(TranslatableModel): """ Create Country model @@ -49,6 +54,8 @@ class Country(TranslatableModel): """ objects = CountryManager() + catalog = '/country/' + services = BitField(flags=flags) url = models.SlugField(unique=True) # relations @@ -64,6 +71,8 @@ class Country(TranslatableModel): phone_code = models.PositiveIntegerField(blank=True, null=True) time_delivery = models.PositiveSmallIntegerField(blank=True, null=True) + latitude = models.FloatField(blank=True, null=True) + longitude = models.FloatField(blank=True, null=True) # fields saves information about creating and changing model created = models.DateTimeField(auto_now_add=True) @@ -93,4 +102,25 @@ class Country(TranslatableModel): def __unicode__(self): return self.lazy_translation_getter('name', unicode(self.pk)) + def get_events(self): + now = date.today() + return Exposition.objects.filter(data_begin__gte=now, country=self).order_by('data_begin')[:3] + + def get_places(self): + return PlaceExposition.objects.filter(country=self)[:3] + + def get_organisers(self): + return Organiser.objects.filter(country=self) + + def get_permanent_url(self): + return self.catalog+self.url + + def events_catalog(self): + return Exposition.catalog+'country-%s'%self.url + + def places_catalog(self): + return PlaceExposition.catalog+'country-%s'%self.url + + + post_save.connect(post_save_handler, sender=Country) \ No newline at end of file diff --git a/country/urls.py b/country/urls.py new file mode 100644 index 00000000..3d53c33d --- /dev/null +++ b/country/urls.py @@ -0,0 +1,8 @@ +# -*- coding: utf-8 -*- +from django.conf.urls import patterns, url +from views import CountryView + + +urlpatterns = patterns('', + url(r'(?P.*)', CountryView.as_view()), +) diff --git a/country/views.py b/country/views.py new file mode 100644 index 00000000..01300306 --- /dev/null +++ b/country/views.py @@ -0,0 +1,8 @@ +from django.views.generic import DetailView +from models import Country + + +class CountryView(DetailView): + model = Country + slug_field = 'url' + template_name = 'country/country.html' \ No newline at end of file diff --git a/directories/management/__init__.py b/directories/management/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/directories/management/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/directories/management/commands/__init__.py b/directories/management/commands/__init__.py new file mode 100644 index 00000000..13ef41a7 --- /dev/null +++ b/directories/management/commands/__init__.py @@ -0,0 +1 @@ +__author__ = 'kotzilla' diff --git a/directories/management/commands/fill_currencies.py b/directories/management/commands/fill_currencies.py new file mode 100644 index 00000000..6122cee9 --- /dev/null +++ b/directories/management/commands/fill_currencies.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +import MySQLdb +from MySQLdb.cursors import DictCursor +from django.core.management.base import BaseCommand, CommandError +from directories.models import Currency + + +class Command(BaseCommand): + def handle(self, *args, **options): + # local database(will not work on production) + db = MySQLdb.connect(host="localhost", + user="root", + passwd="qazedc", + db="test", + charset='utf8', + cursorclass=DictCursor) + cursor = db.cursor() + # !!!database can change + sql = "SELECT code, name FROM localization.currencies;" + cursor.execute(sql) + result = cursor.fetchall() + for item in result: + try: + currency = Currency.objects.get(code=item['code']) + print('currency with code %s already exist'%currency.code) + continue + except Currency.DoesNotExist: + currency = Currency(code=item['code']) + + currency.translate('ru') + currency.name = item['name'] + currency.save() + currency.translate('en') + currency.name = item['name'] + currency.save() + print(currency.code) \ No newline at end of file diff --git a/directories/management/commands/fill_languages.py b/directories/management/commands/fill_languages.py new file mode 100644 index 00000000..51d1641e --- /dev/null +++ b/directories/management/commands/fill_languages.py @@ -0,0 +1,758 @@ +# -*- coding: utf-8 -*- +from django.core.management.base import BaseCommand, CommandError +from directories.models import Language + +isoLangs = { + "ab":{ + "name":"Abkhaz", + "nativeName":"аҧсуа" + }, + "aa":{ + "name":"Afar", + "nativeName":"Afaraf" + }, + "af":{ + "name":"Afrikaans", + "nativeName":"Afrikaans" + }, + "ak":{ + "name":"Akan", + "nativeName":"Akan" + }, + "sq":{ + "name":"Albanian", + "nativeName":"Shqip" + }, + "am":{ + "name":"Amharic", + "nativeName":"አማርኛ" + }, + "ar":{ + "name":"Arabic", + "nativeName":"العربية" + }, + "an":{ + "name":"Aragonese", + "nativeName":"Aragonés" + }, + "hy":{ + "name":"Armenian", + "nativeName":"Հայերեն" + }, + "as":{ + "name":"Assamese", + "nativeName":"অসমীয়া" + }, + "av":{ + "name":"Avaric", + "nativeName":"авар мацӀ, магӀарул мацӀ" + }, + "ae":{ + "name":"Avestan", + "nativeName":"avesta" + }, + "ay":{ + "name":"Aymara", + "nativeName":"aymar aru" + }, + "az":{ + "name":"Azerbaijani", + "nativeName":"azərbaycan dili" + }, + "bm":{ + "name":"Bambara", + "nativeName":"bamanankan" + }, + "ba":{ + "name":"Bashkir", + "nativeName":"башҡорт теле" + }, + "eu":{ + "name":"Basque", + "nativeName":"euskara, euskera" + }, + "be":{ + "name":"Belarusian", + "nativeName":"Беларуская" + }, + "bn":{ + "name":"Bengali", + "nativeName":"বাংলা" + }, + "bh":{ + "name":"Bihari", + "nativeName":"भोजपुरी" + }, + "bi":{ + "name":"Bislama", + "nativeName":"Bislama" + }, + "bs":{ + "name":"Bosnian", + "nativeName":"bosanski jezik" + }, + "br":{ + "name":"Breton", + "nativeName":"brezhoneg" + }, + "bg":{ + "name":"Bulgarian", + "nativeName":"български език" + }, + "my":{ + "name":"Burmese", + "nativeName":"ဗမာစာ" + }, + "ca":{ + "name":"Catalan; Valencian", + "nativeName":"Català" + }, + "ch":{ + "name":"Chamorro", + "nativeName":"Chamoru" + }, + "ce":{ + "name":"Chechen", + "nativeName":"нохчийн мотт" + }, + "ny":{ + "name":"Chichewa; Chewa; Nyanja", + "nativeName":"chiCheŵa, chinyanja" + }, + "zh":{ + "name":"Chinese", + "nativeName":"中文 (Zhōngwén), 汉语, 漢語" + }, + "cv":{ + "name":"Chuvash", + "nativeName":"чӑваш чӗлхи" + }, + "kw":{ + "name":"Cornish", + "nativeName":"Kernewek" + }, + "co":{ + "name":"Corsican", + "nativeName":"corsu, lingua corsa" + }, + "cr":{ + "name":"Cree", + "nativeName":"ᓀᐦᐃᔭᐍᐏᐣ" + }, + "hr":{ + "name":"Croatian", + "nativeName":"hrvatski" + }, + "cs":{ + "name":"Czech", + "nativeName":"česky, čeština" + }, + "da":{ + "name":"Danish", + "nativeName":"dansk" + }, + "dv":{ + "name":"Divehi; Dhivehi; Maldivian;", + "nativeName":"ދިވެހި" + }, + "nl":{ + "name":"Dutch", + "nativeName":"Nederlands, Vlaams" + }, + "en":{ + "name":"English", + "nativeName":"English" + }, + "eo":{ + "name":"Esperanto", + "nativeName":"Esperanto" + }, + "et":{ + "name":"Estonian", + "nativeName":"eesti, eesti keel" + }, + "ee":{ + "name":"Ewe", + "nativeName":"Eʋegbe" + }, + "fo":{ + "name":"Faroese", + "nativeName":"føroyskt" + }, + "fj":{ + "name":"Fijian", + "nativeName":"vosa Vakaviti" + }, + "fi":{ + "name":"Finnish", + "nativeName":"suomi, suomen kieli" + }, + "fr":{ + "name":"French", + "nativeName":"français, langue française" + }, + "ff":{ + "name":"Fula; Fulah; Pulaar; Pular", + "nativeName":"Fulfulde, Pulaar, Pular" + }, + "gl":{ + "name":"Galician", + "nativeName":"Galego" + }, + "ka":{ + "name":"Georgian", + "nativeName":"ქართული" + }, + "de":{ + "name":"German", + "nativeName":"Deutsch" + }, + "el":{ + "name":"Greek, Modern", + "nativeName":"Ελληνικά" + }, + "gn":{ + "name":"Guaraní", + "nativeName":"Avañeẽ" + }, + "gu":{ + "name":"Gujarati", + "nativeName":"ગુજરાતી" + }, + "ht":{ + "name":"Haitian; Haitian Creole", + "nativeName":"Kreyòl ayisyen" + }, + "ha":{ + "name":"Hausa", + "nativeName":"Hausa, هَوُسَ" + }, + "he":{ + "name":"Hebrew (modern)", + "nativeName":"עברית" + }, + "hz":{ + "name":"Herero", + "nativeName":"Otjiherero" + }, + "hi":{ + "name":"Hindi", + "nativeName":"हिन्दी, हिंदी" + }, + "ho":{ + "name":"Hiri Motu", + "nativeName":"Hiri Motu" + }, + "hu":{ + "name":"Hungarian", + "nativeName":"Magyar" + }, + "ia":{ + "name":"Interlingua", + "nativeName":"Interlingua" + }, + "id":{ + "name":"Indonesian", + "nativeName":"Bahasa Indonesia" + }, + "ie":{ + "name":"Interlingue", + "nativeName":"Originally called Occidental; then Interlingue after WWII" + }, + "ga":{ + "name":"Irish", + "nativeName":"Gaeilge" + }, + "ig":{ + "name":"Igbo", + "nativeName":"Asụsụ Igbo" + }, + "ik":{ + "name":"Inupiaq", + "nativeName":"Iñupiaq, Iñupiatun" + }, + "io":{ + "name":"Ido", + "nativeName":"Ido" + }, + "is":{ + "name":"Icelandic", + "nativeName":"Íslenska" + }, + "it":{ + "name":"Italian", + "nativeName":"Italiano" + }, + "iu":{ + "name":"Inuktitut", + "nativeName":"ᐃᓄᒃᑎᑐᑦ" + }, + "ja":{ + "name":"Japanese", + "nativeName":"日本語 (にほんご/にっぽんご)" + }, + "jv":{ + "name":"Javanese", + "nativeName":"basa Jawa" + }, + "kl":{ + "name":"Kalaallisut, Greenlandic", + "nativeName":"kalaallisut, kalaallit oqaasii" + }, + "kn":{ + "name":"Kannada", + "nativeName":"ಕನ್ನಡ" + }, + "kr":{ + "name":"Kanuri", + "nativeName":"Kanuri" + }, + "ks":{ + "name":"Kashmiri", + "nativeName":"कश्मीरी, كشميري‎" + }, + "kk":{ + "name":"Kazakh", + "nativeName":"Қазақ тілі" + }, + "km":{ + "name":"Khmer", + "nativeName":"ភាសាខ្មែរ" + }, + "ki":{ + "name":"Kikuyu, Gikuyu", + "nativeName":"Gĩkũyũ" + }, + "rw":{ + "name":"Kinyarwanda", + "nativeName":"Ikinyarwanda" + }, + "ky":{ + "name":"Kirghiz, Kyrgyz", + "nativeName":"кыргыз тили" + }, + "kv":{ + "name":"Komi", + "nativeName":"коми кыв" + }, + "kg":{ + "name":"Kongo", + "nativeName":"KiKongo" + }, + "ko":{ + "name":"Korean", + "nativeName":"한국어 (韓國語), 조선말 (朝鮮語)" + }, + "ku":{ + "name":"Kurdish", + "nativeName":"Kurdî, كوردی‎" + }, + "kj":{ + "name":"Kwanyama, Kuanyama", + "nativeName":"Kuanyama" + }, + "la":{ + "name":"Latin", + "nativeName":"latine, lingua latina" + }, + "lb":{ + "name":"Luxembourgish, Letzeburgesch", + "nativeName":"Lëtzebuergesch" + }, + "lg":{ + "name":"Luganda", + "nativeName":"Luganda" + }, + "li":{ + "name":"Limburgish, Limburgan, Limburger", + "nativeName":"Limburgs" + }, + "ln":{ + "name":"Lingala", + "nativeName":"Lingála" + }, + "lo":{ + "name":"Lao", + "nativeName":"ພາສາລາວ" + }, + "lt":{ + "name":"Lithuanian", + "nativeName":"lietuvių kalba" + }, + "lu":{ + "name":"Luba-Katanga", + "nativeName":"" + }, + "lv":{ + "name":"Latvian", + "nativeName":"latviešu valoda" + }, + "gv":{ + "name":"Manx", + "nativeName":"Gaelg, Gailck" + }, + "mk":{ + "name":"Macedonian", + "nativeName":"македонски јазик" + }, + "mg":{ + "name":"Malagasy", + "nativeName":"Malagasy fiteny" + }, + "ms":{ + "name":"Malay", + "nativeName":"bahasa Melayu, بهاس ملايو‎" + }, + "ml":{ + "name":"Malayalam", + "nativeName":"മലയാളം" + }, + "mt":{ + "name":"Maltese", + "nativeName":"Malti" + }, + "mi":{ + "name":"Māori", + "nativeName":"te reo Māori" + }, + "mr":{ + "name":"Marathi (Marāṭhī)", + "nativeName":"मराठी" + }, + "mh":{ + "name":"Marshallese", + "nativeName":"Kajin M̧ajeļ" + }, + "mn":{ + "name":"Mongolian", + "nativeName":"монгол" + }, + "na":{ + "name":"Nauru", + "nativeName":"Ekakairũ Naoero" + }, + "nv":{ + "name":"Navajo, Navaho", + "nativeName":"Diné bizaad, Dinékʼehǰí" + }, + "nb":{ + "name":"Norwegian Bokmål", + "nativeName":"Norsk bokmål" + }, + "nd":{ + "name":"North Ndebele", + "nativeName":"isiNdebele" + }, + "ne":{ + "name":"Nepali", + "nativeName":"नेपाली" + }, + "ng":{ + "name":"Ndonga", + "nativeName":"Owambo" + }, + "nn":{ + "name":"Norwegian Nynorsk", + "nativeName":"Norsk nynorsk" + }, + "no":{ + "name":"Norwegian", + "nativeName":"Norsk" + }, + "ii":{ + "name":"Nuosu", + "nativeName":"ꆈꌠ꒿ Nuosuhxop" + }, + "nr":{ + "name":"South Ndebele", + "nativeName":"isiNdebele" + }, + "oc":{ + "name":"Occitan", + "nativeName":"Occitan" + }, + "oj":{ + "name":"Ojibwe, Ojibwa", + "nativeName":"ᐊᓂᔑᓈᐯᒧᐎᓐ" + }, + "cu":{ + "name":"Old Church Slavonic, Church Slavic, Church Slavonic, Old Bulgarian, Old Slavonic", + "nativeName":"ѩзыкъ словѣньскъ" + }, + "om":{ + "name":"Oromo", + "nativeName":"Afaan Oromoo" + }, + "or":{ + "name":"Oriya", + "nativeName":"ଓଡ଼ିଆ" + }, + "os":{ + "name":"Ossetian, Ossetic", + "nativeName":"ирон æвзаг" + }, + "pa":{ + "name":"Panjabi, Punjabi", + "nativeName":"ਪੰਜਾਬੀ, پنجابی‎" + }, + "pi":{ + "name":"Pāli", + "nativeName":"पाऴि" + }, + "fa":{ + "name":"Persian", + "nativeName":"فارسی" + }, + "pl":{ + "name":"Polish", + "nativeName":"polski" + }, + "ps":{ + "name":"Pashto, Pushto", + "nativeName":"پښتو" + }, + "pt":{ + "name":"Portuguese", + "nativeName":"Português" + }, + "qu":{ + "name":"Quechua", + "nativeName":"Runa Simi, Kichwa" + }, + "rm":{ + "name":"Romansh", + "nativeName":"rumantsch grischun" + }, + "rn":{ + "name":"Kirundi", + "nativeName":"kiRundi" + }, + "ro":{ + "name":"Romanian, Moldavian, Moldovan", + "nativeName":"română" + }, + "ru":{ + "name":"Russian", + "nativeName":"русский язык" + }, + "sa":{ + "name":"Sanskrit (Saṁskṛta)", + "nativeName":"संस्कृतम्" + }, + "sc":{ + "name":"Sardinian", + "nativeName":"sardu" + }, + "sd":{ + "name":"Sindhi", + "nativeName":"सिन्धी, سنڌي، سندھی‎" + }, + "se":{ + "name":"Northern Sami", + "nativeName":"Davvisámegiella" + }, + "sm":{ + "name":"Samoan", + "nativeName":"gagana faa Samoa" + }, + "sg":{ + "name":"Sango", + "nativeName":"yângâ tî sängö" + }, + "sr":{ + "name":"Serbian", + "nativeName":"српски језик" + }, + "gd":{ + "name":"Scottish Gaelic; Gaelic", + "nativeName":"Gàidhlig" + }, + "sn":{ + "name":"Shona", + "nativeName":"chiShona" + }, + "si":{ + "name":"Sinhala, Sinhalese", + "nativeName":"සිංහල" + }, + "sk":{ + "name":"Slovak", + "nativeName":"slovenčina" + }, + "sl":{ + "name":"Slovene", + "nativeName":"slovenščina" + }, + "so":{ + "name":"Somali", + "nativeName":"Soomaaliga, af Soomaali" + }, + "st":{ + "name":"Southern Sotho", + "nativeName":"Sesotho" + }, + "es":{ + "name":"Spanish; Castilian", + "nativeName":"español, castellano" + }, + "su":{ + "name":"Sundanese", + "nativeName":"Basa Sunda" + }, + "sw":{ + "name":"Swahili", + "nativeName":"Kiswahili" + }, + "ss":{ + "name":"Swati", + "nativeName":"SiSwati" + }, + "sv":{ + "name":"Swedish", + "nativeName":"svenska" + }, + "ta":{ + "name":"Tamil", + "nativeName":"தமிழ்" + }, + "te":{ + "name":"Telugu", + "nativeName":"తెలుగు" + }, + "tg":{ + "name":"Tajik", + "nativeName":"тоҷикӣ, toğikī, تاجیکی‎" + }, + "th":{ + "name":"Thai", + "nativeName":"ไทย" + }, + "ti":{ + "name":"Tigrinya", + "nativeName":"ትግርኛ" + }, + "bo":{ + "name":"Tibetan Standard, Tibetan, Central", + "nativeName":"བོད་ཡིག" + }, + "tk":{ + "name":"Turkmen", + "nativeName":"Türkmen, Түркмен" + }, + "tl":{ + "name":"Tagalog", + "nativeName":"Wikang Tagalog, ᜏᜒᜃᜅ᜔ ᜆᜄᜎᜓᜄ᜔" + }, + "tn":{ + "name":"Tswana", + "nativeName":"Setswana" + }, + "to":{ + "name":"Tonga (Tonga Islands)", + "nativeName":"faka Tonga" + }, + "tr":{ + "name":"Turkish", + "nativeName":"Türkçe" + }, + "ts":{ + "name":"Tsonga", + "nativeName":"Xitsonga" + }, + "tt":{ + "name":"Tatar", + "nativeName":"татарча, tatarça, تاتارچا‎" + }, + "tw":{ + "name":"Twi", + "nativeName":"Twi" + }, + "ty":{ + "name":"Tahitian", + "nativeName":"Reo Tahiti" + }, + "ug":{ + "name":"Uighur, Uyghur", + "nativeName":"Uyƣurqə, ئۇيغۇرچە‎" + }, + "uk":{ + "name":"Ukrainian", + "nativeName":"українська" + }, + "ur":{ + "name":"Urdu", + "nativeName":"اردو" + }, + "uz":{ + "name":"Uzbek", + "nativeName":"zbek, Ўзбек, أۇزبېك‎" + }, + "ve":{ + "name":"Venda", + "nativeName":"Tshivenḓa" + }, + "vi":{ + "name":"Vietnamese", + "nativeName":"Tiếng Việt" + }, + "vo":{ + "name":"Volapük", + "nativeName":"Volapük" + }, + "wa":{ + "name":"Walloon", + "nativeName":"Walon" + }, + "cy":{ + "name":"Welsh", + "nativeName":"Cymraeg" + }, + "wo":{ + "name":"Wolof", + "nativeName":"Wollof" + }, + "fy":{ + "name":"Western Frisian", + "nativeName":"Frysk" + }, + "xh":{ + "name":"Xhosa", + "nativeName":"isiXhosa" + }, + "yi":{ + "name":"Yiddish", + "nativeName":"ייִדיש" + }, + "yo":{ + "name":"Yoruba", + "nativeName":"Yorùbá" + }, + "za":{ + "name":"Zhuang, Chuang", + "nativeName":"Saɯ cueŋƅ, Saw cuengh" + } +} + + +class Command(BaseCommand): + def handle(self, *args, **options): + for code, value in isoLangs.iteritems(): + print(code) + try: + language = Language.objects.get(code=code) + print('Language with code %s alredy exist'%language.code) + continue + except Language.DoesNotExist: + language = Language(code=code, language=value['nativeName']) + + language.translate('ru') + language.name = value['name'] + language.save() + language.translate('en') + language.name = value['name'] + language.save() + print(language.code) + + + + diff --git a/directories/models.py b/directories/models.py index dfa1c23c..74b0d266 100644 --- a/directories/models.py +++ b/directories/models.py @@ -1,31 +1,41 @@ # -*- coding: utf-8 -*- from django.db import models +from hvad.models import TranslatableModel, TranslatedFields, TranslationManager -class Language(models.Model): +class Language(TranslatableModel): """ Creates Language model """ - language = models.CharField(max_length=50) + language = models.CharField(max_length=255)# native language name + code = models.CharField(max_length=2) + # name for translations(ex: russian, русский) + translations = TranslatedFields( + name = models.CharField(max_length='255', blank='True') + ) def __unicode__(self): return self.language -class Currency(models.Model): +class Currency(TranslatableModel): """ Creates Currency model """ - currency = models.CharField(max_length=20) + code = models.CharField(max_length=3) + + translations = TranslatedFields( + name = models.CharField(max_length='255', blank='True') + ) def __unicode__(self): - return self.currency + return self.code class Iata (models.Model): """ Creates Iata model """ - airport = models.CharField(max_length=50) - code = models.CharField(max_length=5) + airport = models.CharField(max_length=255) + code = models.CharField(max_length=4) def __unicode__(self): return self.code diff --git a/exposition/models.py b/exposition/models.py index 0993c10b..620593c4 100644 --- a/exposition/models.py +++ b/exposition/models.py @@ -71,6 +71,7 @@ class Exposition(TranslatableModel, EventMixin, ExpoMixin): periodic = models.FloatField(verbose_name='Переодичность', blank=True, null=True) #audience = EnumField(values=AUDIENCE, blank=True) web_page = models.CharField(verbose_name='Вебсайт', max_length=255, blank=True) + registration_link = models.URLField(verbose_name='Ссылка на регистрацию', max_length=255, blank=True) min_area = models.PositiveIntegerField(verbose_name='Минимальная площадь', blank=True, null=True) # currency = EnumField(values=CURRENCY, default='USD') diff --git a/functions/model_mixin.py b/functions/model_mixin.py index fbf59200..ff4a7f0b 100644 --- a/functions/model_mixin.py +++ b/functions/model_mixin.py @@ -1,5 +1,6 @@ -from service.models import Service import calendar as python_calendar +from service.models import Service + class ExpoMixin(object): @@ -85,7 +86,4 @@ class EventMixin(object): if self.data_end.month == month: return self.data_end.day - return 0 - - - + return 0 \ No newline at end of file diff --git a/place_exposition/models.py b/place_exposition/models.py index a639e231..945898a9 100644 --- a/place_exposition/models.py +++ b/place_exposition/models.py @@ -32,6 +32,7 @@ class PlaceExposition(TranslatableModel, ExpoMixin): """ #set manager of this model objects = ExpoManager() + catalog = '/places/' url = models.SlugField(unique=True, max_length=255) country = models.ForeignKey('country.Country', on_delete=models.PROTECT) diff --git a/proj/settings.py b/proj/settings.py index 2d2f69b5..6503f3ec 100644 --- a/proj/settings.py +++ b/proj/settings.py @@ -94,17 +94,17 @@ CKEDITOR_CONFIGS = { }, } -TINYMCE_JS_URL = os.path.join(MEDIA_ROOT, "js/tiny_mce/tiny_mce.js") -TINYMCE_DEFAULT_CONFIG = { - 'plugins': "table,spellchecker,paste,searchreplace", - 'theme': "advanced", - 'cleanup_on_startup': True, - 'custom_undo_redo_levels': 10, - 'width' : 565, - 'height' : 100 -} -TINYMCE_SPELLCHECKER = True -TINYMCE_COMPRESSOR = True +#TINYMCE_JS_URL = os.path.join(MEDIA_ROOT, "js/tiny_mce/tiny_mce.js") +#TINYMCE_DEFAULT_CONFIG = { +# 'plugins': "table,spellchecker,paste,searchreplace", +# 'theme': "advanced", +# 'cleanup_on_startup': True, +# 'custom_undo_redo_levels': 10, +# 'width' : 565, +# 'height' : 100 +#} +#TINYMCE_SPELLCHECKER = True +#TINYMCE_COMPRESSOR = True # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash. @@ -122,12 +122,6 @@ STATIC_ROOT = os.path.join(SITE_ROOT, 'static') STATIC_URL = '/static/' # Additional locations of static files -STATICFILES_DIRS = ( - # Put strings here, like "/home/html/static" or "C:/www/django/static". - # Always use forward slashes, even on Windows. - # Don't forget to use absolute paths, not relative paths. - '',#'/home/kotzilla/Documents/qwer/static', -) # List of finder classes that know how to find static files in # various locations. @@ -174,8 +168,9 @@ MIDDLEWARE_CLASSES = ( 'social.apps.django_app.middleware.SocialAuthExceptionMiddleware', # 'django.middleware.cache.FetchFromCacheMiddleware', # Uncomment the next line for simple clickjacking protection: - # 'django.middleware.clickjacking.XFrameOptionsMiddleware', - #'debug_toolbar.middleware.DebugToolbarMiddleware',#должно быть последним полем + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'debug_toolbar.middleware.DebugToolbarMiddleware',#должно быть последним полем + ) ROOT_URLCONF = 'proj.urls' diff --git a/proj/urls.py b/proj/urls.py index eea51ce2..26f63bb2 100644 --- a/proj/urls.py +++ b/proj/urls.py @@ -15,6 +15,8 @@ urlpatterns = patterns('', url(r'^', include('webinar.urls')), url(r'^', include('company.urls')), url(r'^', include('photoreport.urls')), + url(r'^country/', include('country.urls')), + url(r'^city/', include('city.urls')), url(r'^organiser/', include('organiser.urls')), diff --git a/proj/views.py b/proj/views.py index fafffb3f..9c984579 100644 --- a/proj/views.py +++ b/proj/views.py @@ -61,10 +61,6 @@ def home(request): return render_to_response('index.html', args, context_instance=RequestContext(request)) - - - - class Test(ExpoListView): model = Exposition @@ -74,5 +70,4 @@ class AdvertisingView(TemplateView): template_name = 'simple_pages/advertising.html' class AboutView(TemplateView): - template_name = 'simple_pages/about.html' - + template_name = 'simple_pages/about.html' \ No newline at end of file diff --git a/templates/client/city/city.html b/templates/client/city/city.html new file mode 100644 index 00000000..089da3ea --- /dev/null +++ b/templates/client/city/city.html @@ -0,0 +1,144 @@ +{% extends 'base_catalog.html' %} +{% load static %} +{% load i18n %} + +{% block bread_scrumbs %} + +{% endblock %} + +{% block page_title %} +{% endblock %} + +{% block content_list %} +
+
+ + +
+
+
{{ object.name }}
+
+ + + + + +
+
    + {% if object.population %} +
  • {% trans 'Население' %}:{{ object.population }} {% trans 'человек' %}
  • + {% endif %} + + {% if object.code_IATA %} +
  • Код IATA:{{ object.code_IATA.code }}
  • + {% endif %} + + {% if object.phone_code %} +
  • {% trans 'Телефонный код' %}:+{{ object.phone_code }}
  • + {% endif %} + {% if object.transport %} +
  • {% trans 'Транспорт' %}:{{ object.transport }}
  • + {% endif %} +
+
+ + + +
+
+ + {% if object.famous_places %} + + + + + {% endif %} + {% if object.shoping %} + + + + + {% endif %} +
{% trans 'Должны посетить' %}: + {{ object.famous_places }} +
{% trans 'Шоппинг' %}: + {{ object.shoping }} +
+ + {% if object.description %} +
+
+
Описание
+
+ {{ object.description }} +
+
+ {% endif %} + + {% if object.get_photos %} +
+
Фотогалерея
+ +
+ {% endif %} +
+ +{% if object.get_events %} +
+
+ + {% include 'includes/exposition/exposition_list.html' with object_list=object.get_events %} +
+{% endif %} + +{% if object.get_places %} +
+
+ + {% include 'includes/place/place_list.html' with object_list=object.get_places %} +
+{% endif %} + +{% if object.get_organisers %} +
+
+ + {% include 'includes/organiser/organiser_list.html' with object_list=object.get_organisers %} +
+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/templates/client/country/country.html b/templates/client/country/country.html new file mode 100644 index 00000000..5106b391 --- /dev/null +++ b/templates/client/country/country.html @@ -0,0 +1,181 @@ +{% extends 'base_catalog.html' %} +{% load static %} +{% load i18n %} + +{% block bread_scrumbs %} + +{% endblock %} + +{% block page_title %} +{% endblock %} + +{% block content_list %} +
+
+ +
+
+
{{ object.name }}
+
+ + + + + +
+
    + {% if object.capital %} +
  • {% trans 'Столица' %}:{{ object.capital.name }}
  • + {% endif %} + {% if object.language.all %} +
  • {% trans 'Официальный язык' %}: + {% for lang in object.language.all %} + {{ lang.name }} + {% endfor %} +
  • + {% endif %} + {% if object.timezone %} +
  • {% trans 'Часовая зона' %}:{{ object.timezone }}
  • +
  • {% trans 'Часовые пояса' %}:среднее время по Гринвичу
  • + {% endif %} +
+
+
    + {% if object.population %} +
  • {% trans 'Население' %}:{{ object.population }} {% trans 'человек' %}
  • + {% endif %} + {% if object.phone_code %} +
  • {% trans 'Телефонный код' %}:+ {{ object.phone_code }}
  • + {% endif %} + {% if object.currency.all %} +
  • {% trans 'Валюта' %}: + {% for currency in object.currency.all %} + {{ currency.code }} + {% endfor %} + {% endif %} +
  • +
+
+ {% if object.latitude %} + + +
+ {% endif %} +
+ {% if object.big_cities.all %} +
+

{% trans 'Крупные города' %}:

+ + + + + +
+
    + {% for city in object.big_cities.all %} +
  • {{ city.name }}
  • + {% endfor %} +
+
 
+
+ {% endif %} +
+ {% if object.description %} +
+
{% trans 'Описание' %}
+
+ {{ object.description }} +
+
+ {% endif %} + {% if object.get_photos %} +
+
{% trans 'Фотогалерея' %}
+ +
+
+ {% endif %} + {% if object.rules %} +
+
{% trans 'Визовая информация' %}
+
+ {{ object.rules }} +
+
+ {% endif %} + {% if object.documents or object.consulate %} + + + + + + +
+

{% trans 'Документы' %}

+
    + {{ object.documents }} +
+
  + {{ object.consulate }} +
+ {% endif %} +
+{% if object.get_events %} +
+ +
+ + {% include 'includes/exposition/exposition_list.html' with object_list=object.get_events %} +
+{% endif %} + +{% if object.get_places %} +
+
+ + {% include 'includes/place/place_list.html' with object_list=object.get_places %} +
+{% endif %} + +{% if object.get_organisers %} +
+
+ + {% include 'includes/organiser/organiser_list.html' with object_list=object.get_organisers %} +
+{% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/client/includes/event_list.html b/templates/client/includes/event_list.html index 9f8830c7..4420cf7f 100644 --- a/templates/client/includes/event_list.html +++ b/templates/client/includes/event_list.html @@ -56,10 +56,10 @@ {% if obj.country %} {% endif %} @@ -86,7 +86,7 @@ diff --git a/templates/client/includes/event_object.html b/templates/client/includes/event_object.html index 7f26937f..c89302e1 100644 --- a/templates/client/includes/event_object.html +++ b/templates/client/includes/event_object.html @@ -110,9 +110,8 @@ - {% with event=exposition filter=filter %} - {% include 'includes/event_steps.html' %} - {% endwith %} + {% include 'includes/event_steps.html' with event=exposition filter=filter %} + {% if exposition.get_photos %}
@@ -131,12 +130,14 @@ {% endif %} - + {% if exposition.description %}
+
{% trans 'О выставке' %} {{ exposition.name|safe }}
{{ exposition.description|safe|linebreaks }}

+ {% endif %}
{% trans 'Дополнительная информация' %}
    @@ -291,9 +292,9 @@ {% endwith %}
diff --git a/templates/client/includes/event_steps.html b/templates/client/includes/event_steps.html index de0c08e9..2f2d4ad6 100644 --- a/templates/client/includes/event_steps.html +++ b/templates/client/includes/event_steps.html @@ -7,7 +7,9 @@