commit
dffbacddc7
68 changed files with 2213 additions and 296 deletions
@ -0,0 +1,218 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
import os |
||||||
|
import MySQLdb |
||||||
|
from MySQLdb.cursors import DictCursor |
||||||
|
from django.core.management.base import BaseCommand |
||||||
|
from django.conf import settings |
||||||
|
from conference.models import Conference |
||||||
|
from django.core.files import File |
||||||
|
from functions.translate import fill_with_signal |
||||||
|
from country.models import Country |
||||||
|
from city.models import City |
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
def handle(self, *args, **options): |
||||||
|
db = MySQLdb.connect(host="localhost", |
||||||
|
user="expomap", |
||||||
|
passwd="7FbLtAGjse", |
||||||
|
db="old_db", |
||||||
|
charset='utf8', |
||||||
|
cursorclass=DictCursor) |
||||||
|
cursor = db.cursor() |
||||||
|
sql = """ |
||||||
|
SELECT products.products_id as id, products_date_added as created, products_last_modified as modified, |
||||||
|
discount, expohit, ufi, products_name as name, products_description as description, |
||||||
|
products_short_description as main_title, products_viewed as viewed, products_period as period, |
||||||
|
products_org as organiser,products_products as products, products_official as web_page, |
||||||
|
products_img1 as logo, products_startdate as data_begin, products_enddate as data_end, |
||||||
|
url as old_url, places_id |
||||||
|
FROM `products` |
||||||
|
LEFT JOIN `products_description` ON products.products_id=products_description.products_id |
||||||
|
WHERE `products_status` =1 |
||||||
|
AND `conference` =1 AND places_id >0 |
||||||
|
""" |
||||||
|
cursor.execute(sql) |
||||||
|
result = cursor.fetchall() |
||||||
|
|
||||||
|
names = [item['name'] for item in result] |
||||||
|
media = settings.MEDIA_ROOT.replace('media/', '') |
||||||
|
for i, item in enumerate(result): |
||||||
|
name = item['name'] |
||||||
|
print('number: %d, name: %s'%(i, name.encode('utf8'))) |
||||||
|
if Conference.objects.filter(translations__name=name).exists(): |
||||||
|
continue |
||||||
|
|
||||||
|
data_begin = item['data_begin'] |
||||||
|
data_end= item['data_end'] |
||||||
|
|
||||||
|
|
||||||
|
place_id = item['places_id'] # convert to country and city |
||||||
|
country, city = get_places(place_id) |
||||||
|
#if isinstance(city, unicode): |
||||||
|
#print(city.encode('utf8')) |
||||||
|
# value = bad_cities.get(city) |
||||||
|
# if value: |
||||||
|
# bad_cities[city] = value + 1 |
||||||
|
# else: |
||||||
|
# bad_cities[city] = 1 |
||||||
|
|
||||||
|
# counter += 1 |
||||||
|
# continue |
||||||
|
|
||||||
|
if not country or not city: |
||||||
|
continue |
||||||
|
|
||||||
|
old_url = item['old_url'] |
||||||
|
periodic = item['period'] |
||||||
|
periodic = get_periodic(periodic) |
||||||
|
web_page = item['web_page'] |
||||||
|
currency = 'USD' |
||||||
|
expohit = item['expohit'] |
||||||
|
ufi = item['ufi'] |
||||||
|
if ufi: |
||||||
|
ufi = 1 |
||||||
|
else: |
||||||
|
ufi = 0 |
||||||
|
|
||||||
|
created = item['created'] |
||||||
|
modified = item['modified'] |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
data = {'name_ru': name, 'main_title_ru': item['main_title'], 'description_ru': item['description'], |
||||||
|
'main_themes_ru': item['products'], 'time_ru': '', 'discount_description_ru': '', 'title_ru': '', |
||||||
|
'descriptions_ru': '', 'keywords_ru': ''} |
||||||
|
|
||||||
|
conference = Conference(data_begin=data_begin, data_end=data_end, city=city, country=country, |
||||||
|
web_page=web_page, old_url=old_url, periodic=periodic, currency=currency, |
||||||
|
expohit=expohit, created=created, modified=modified) |
||||||
|
try: |
||||||
|
fill_with_signal(Conference, conference, data) |
||||||
|
except: |
||||||
|
continue |
||||||
|
print('conference: %s'%str(conference)) |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#print(len(bad_cities.keys())) |
||||||
|
#print(len(result)) |
||||||
|
#print(Conference.objects.filter().count()) |
||||||
|
#print(Conference.objects.exclude(translations__name__in=names).count()) |
||||||
|
|
||||||
|
|
||||||
|
def get_periodic(value): |
||||||
|
PERIODIC = {u'Ежегодно': 1.0, u'Раз в 2 года': 0.5, u'2 раза в год': 2.0, u'4 раза в год': 4.0, |
||||||
|
u'3 раза в год': 3.0, u'Раз в 3 года': 0.33, u'Раз в 4 года': 0.25, u'5 раз в год': 5.0, |
||||||
|
u'Раз в два года': 0.5, u'Три раза в год': 3.0} |
||||||
|
return PERIODIC.get(value, 0) |
||||||
|
|
||||||
|
def get_logo(value): |
||||||
|
if not value: |
||||||
|
return None |
||||||
|
if value.startswith('..'): |
||||||
|
value = value.replace('..', 'media') |
||||||
|
elif value.startswith('/'): |
||||||
|
value = 'media'+value |
||||||
|
|
||||||
|
return value |
||||||
|
|
||||||
|
def get_places(place_id): |
||||||
|
db = MySQLdb.connect(host="localhost", |
||||||
|
user="expomap", |
||||||
|
passwd="7FbLtAGjse", |
||||||
|
db="old_db", |
||||||
|
charset='utf8', |
||||||
|
cursorclass=DictCursor) |
||||||
|
cursor = db.cursor() |
||||||
|
sql_city = """ |
||||||
|
SELECT title as city_name, url as city_old_url, inflect as city_inflect, parent_id as country_id |
||||||
|
FROM `products_places` |
||||||
|
WHERE `places_id` =%s |
||||||
|
"""%place_id |
||||||
|
|
||||||
|
cursor.execute(sql_city) |
||||||
|
result = cursor.fetchone() |
||||||
|
city_name, city_old_url, city_inflect = result['city_name'], result['city_old_url'], result['city_inflect'] |
||||||
|
country_id = result['country_id'] |
||||||
|
if city_name: |
||||||
|
city_name = city_name.strip() |
||||||
|
if city_name==u'Гонконг': |
||||||
|
country = Country.objects.get(id=76) |
||||||
|
city = City.objects.get(url='hong-kong') |
||||||
|
return (country, city) |
||||||
|
|
||||||
|
sql_country = """ |
||||||
|
SELECT title as country_name, url as country_old_url, inflect as country_inflect |
||||||
|
FROM `products_places` |
||||||
|
WHERE `places_id` =%s |
||||||
|
"""%country_id |
||||||
|
|
||||||
|
cursor.execute(sql_country) |
||||||
|
result = cursor.fetchone() |
||||||
|
country_name, country_old_url, country_inflect = result['country_name'], result['country_old_url'], result['country_inflect'] |
||||||
|
country_name = filter_country(country_name) |
||||||
|
try: |
||||||
|
country = Country.objects.get(translations__name=country_name) |
||||||
|
except Country.DoesNotExist: |
||||||
|
country = None |
||||||
|
except Country.MultipleObjectsReturned: |
||||||
|
country = Country.objects.filter(translations__name=country_name)[0] |
||||||
|
|
||||||
|
city_name = filter_city(city_name) |
||||||
|
try: |
||||||
|
city = City.objects.get(translations__name=city_name, country=country) |
||||||
|
except City.DoesNotExist: |
||||||
|
#city = city_name |
||||||
|
city = None |
||||||
|
#print(city_name.encode('utf8')) |
||||||
|
except City.MultipleObjectsReturned: |
||||||
|
city = City.objects.filter(translations__name=city_name, country=country)[0] |
||||||
|
#print('----------------') |
||||||
|
#print(city_name.encode('utf8')) |
||||||
|
#print('----------------') |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (country, city) |
||||||
|
|
||||||
|
def filter_country(name): |
||||||
|
if name == u'ЮАР': |
||||||
|
name = u'Южно-Африканская Республика' |
||||||
|
elif name == u'Танзания': |
||||||
|
name = u'Объединенная Республика Танзания' |
||||||
|
elif name == u'Гавайи': |
||||||
|
name = u'США' |
||||||
|
elif name == u'Бирма': |
||||||
|
name = u'Мьянма' |
||||||
|
elif name == u'Босния и Герцоговина': |
||||||
|
name = u'Босния и Герцеговина' |
||||||
|
|
||||||
|
return name |
||||||
|
|
||||||
|
def filter_city(name): |
||||||
|
cities = {u'Дели': u'Нью-Дели', u'Дэли': u'Нью-Дели', u'Пуна': u'Пуне', u'Лонг-Бич': u'Лонг Бич', |
||||||
|
u'Калифорния': u'Лос-Анджелес', u'Санта-Клара': u'Санта Клара', u'Скотсдейл': u'Скоттсдейл', |
||||||
|
u'Пенанг': u'Пинанг', u'Лейк Буэна Виста': u'Лейк-Буэна-Виста', u'Лиллестрём': u'Лиллештром', |
||||||
|
u'Хертогенбош': u'Ден Бош', u'Марбелла': u'Марбелья', u'Лилль': u'Лилль', u'Ла Рош-сюр-Форон': u'Ла-Рош-сюр-Форон', |
||||||
|
u'Эль-Кувейт': u'Кувейт', u'Харрогит': u'Харрогейт', u'Иокогама': u'Йокогама', u'Палм Бич': u'Палм-Бич', |
||||||
|
u'Фрайбург': u'Фрейбург в Брейсгау', u'Колмар': u'Кольмар', u'Мускат': u'Маскат', u'Бад Зальцуфлен': u'Бад-Зальцуфлен'} |
||||||
|
new_name = cities.get(name) |
||||||
|
if new_name: |
||||||
|
return new_name |
||||||
|
else: |
||||||
|
return name |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
""" |
||||||
|
# convert logo |
||||||
|
logo = item['logo'] |
||||||
|
logo = get_logo(logo) |
||||||
|
if logo and logo.startswith('media/images'): |
||||||
|
file = media + logo |
||||||
|
if os.path.isfile(file): |
||||||
|
f = open('mytest.pdf') |
||||||
|
else: |
||||||
|
logo = None |
||||||
|
""" |
||||||
@ -0,0 +1,103 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
import os |
||||||
|
import MySQLdb |
||||||
|
from MySQLdb.cursors import DictCursor |
||||||
|
from django.core.management.base import BaseCommand |
||||||
|
from django.conf import settings |
||||||
|
from exposition.models import Exposition |
||||||
|
from conference.management.commands.conf_old import filter_city, filter_country, get_periodic, get_logo, get_places |
||||||
|
from django.core.files import File |
||||||
|
from functions.translate import fill_with_signal |
||||||
|
from country.models import Country |
||||||
|
from city.models import City |
||||||
|
|
||||||
|
file_path = settings.MEDIA_ROOT + 'exposition/bad_expos.txt' |
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
def handle(self, *args, **options): |
||||||
|
db = MySQLdb.connect(host="localhost", |
||||||
|
user="expomap", |
||||||
|
passwd="7FbLtAGjse", |
||||||
|
db="old_db", |
||||||
|
charset='utf8', |
||||||
|
cursorclass=DictCursor) |
||||||
|
cursor = db.cursor() |
||||||
|
sql = """ |
||||||
|
SELECT products.products_id as id, products_date_added as created, products_last_modified as modified, |
||||||
|
discount, expohit, ufi, products_name as name, products_description as description, |
||||||
|
products_short_description as main_title, products_viewed as viewed, products_period as period, |
||||||
|
products_org as organiser,products_products as products, products_official as web_page, |
||||||
|
products_img1 as logo, products_startdate as data_begin, products_enddate as data_end, |
||||||
|
url as old_url, places_id |
||||||
|
FROM `products` |
||||||
|
LEFT JOIN `products_description` ON products.products_id=products_description.products_id |
||||||
|
WHERE `products_status` =1 |
||||||
|
AND `conference` =0 AND places_id >0 |
||||||
|
""" |
||||||
|
|
||||||
|
cursor.execute(sql) |
||||||
|
result = cursor.fetchall() |
||||||
|
|
||||||
|
names = [item['name'] for item in result] |
||||||
|
#media = settings.MEDIA_ROOT.replace('media/', '') |
||||||
|
#counter = 0 |
||||||
|
#bad_cities = {} |
||||||
|
|
||||||
|
bad_expos = [] |
||||||
|
for i, item in enumerate(result): |
||||||
|
|
||||||
|
print('number: %d, errors: %d'%(i, len(bad_expos))) |
||||||
|
name = item['name'] |
||||||
|
if Exposition.objects.filter(translations__name=name).exists(): |
||||||
|
msg = u'%s|||%s|||%s'%(name, item['old_url'], 'already exist') |
||||||
|
bad_expos.append(msg) |
||||||
|
continue |
||||||
|
|
||||||
|
data_begin = item['data_begin'] |
||||||
|
data_end= item['data_end'] |
||||||
|
|
||||||
|
|
||||||
|
place_id = item['places_id'] # convert to country and city |
||||||
|
country, city = get_places(place_id) |
||||||
|
|
||||||
|
if not country or not city: |
||||||
|
msg = u'%s|||%s|||%s'%(name, item['old_url'], 'bad country or city') |
||||||
|
bad_expos.append(msg) |
||||||
|
continue |
||||||
|
old_url = item['old_url'] |
||||||
|
periodic = item['period'] |
||||||
|
periodic = get_periodic(periodic) |
||||||
|
web_page = item['web_page'] |
||||||
|
currency = 'USD' |
||||||
|
expohit = item['expohit'] |
||||||
|
ufi = item['ufi'] |
||||||
|
if ufi: |
||||||
|
ufi = 1 |
||||||
|
else: |
||||||
|
ufi = 0 |
||||||
|
|
||||||
|
created = item['created'] |
||||||
|
modified = item['modified'] |
||||||
|
|
||||||
|
data = {'name_ru': name, 'main_title_ru': item['main_title'], 'description_ru': item['description'], |
||||||
|
'products_ru': item['products'], 'discount_description_ru': '', 'time_ru': '', 'price_day_ru':'', |
||||||
|
'price_all_ru': '', 'price_day_bar_ru': '', 'price_all_bar_ru': '', 'stat_countries_ru': '', |
||||||
|
'pre_condition_ru':'', 'stand_condition_ru': '', 'visit_note_ru': '', 'participation_note_ru': '', |
||||||
|
'title_ru': '', 'descriptions_ru': '', 'keywords_ru': ''} |
||||||
|
|
||||||
|
exposition = Exposition(data_begin=data_begin, data_end=data_end, city=city, country=country, |
||||||
|
web_page=web_page, old_url=old_url, periodic=periodic, currency=currency, |
||||||
|
expohit=expohit, created=created, modified=modified, quality_label=ufi) |
||||||
|
|
||||||
|
try: |
||||||
|
fill_with_signal(Exposition, exposition, data) |
||||||
|
except Exception as e: |
||||||
|
msg = u'%s|||%s|||%s'%(name, item['old_url'], str(e)) |
||||||
|
bad_expos.append(msg) |
||||||
|
continue |
||||||
|
|
||||||
|
print('saving file') |
||||||
|
file = open(file_path, 'w') |
||||||
|
for item in bad_expos: |
||||||
|
file.write("%s\n" % item) |
||||||
|
file.close() |
||||||
@ -0,0 +1,20 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
from django.core.management.base import BaseCommand |
||||||
|
from meta.models import MetaSetting |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
def handle(self, *args, **options): |
||||||
|
a = MetaSetting.objects.filter(translations__h1__contains='«').count() |
||||||
|
qs = MetaSetting.objects.language('ru').all() |
||||||
|
for item in qs: |
||||||
|
item.title = item.title.replace(u'«', u'').replace(u'»', u'') |
||||||
|
item.description = item.title.replace(u'«', u'').replace(u'»', u'') |
||||||
|
item.h1 = item.h1.replace(u'«', u'').replace(u'»', u'') |
||||||
|
#item.save() |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,50 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
import random |
||||||
|
from django.contrib.auth.decorators import login_required |
||||||
|
from django.utils.cache import patch_response_headers |
||||||
|
from django.utils.decorators import method_decorator |
||||||
|
from django.views.decorators.cache import cache_page, never_cache |
||||||
|
from django.views.decorators.csrf import csrf_exempt |
||||||
|
|
||||||
|
class NeverCacheMixin(object): |
||||||
|
@method_decorator(never_cache) |
||||||
|
def dispatch(self, *args, **kwargs): |
||||||
|
return super(NeverCacheMixin, self).dispatch(*args, **kwargs) |
||||||
|
|
||||||
|
|
||||||
|
class LoginRequiredMixin(object): |
||||||
|
@method_decorator(login_required) |
||||||
|
def dispatch(self, *args, **kwargs): |
||||||
|
return super(LoginRequiredMixin, self).dispatch(*args, **kwargs) |
||||||
|
|
||||||
|
|
||||||
|
class CacheMixin(object): |
||||||
|
cache_timeout = 60 |
||||||
|
|
||||||
|
def get_cache_timeout(self): |
||||||
|
return self.cache_timeout |
||||||
|
|
||||||
|
def dispatch(self, *args, **kwargs): |
||||||
|
return cache_page(self.get_cache_timeout())(super(CacheMixin, self).dispatch)(*args, **kwargs) |
||||||
|
|
||||||
|
|
||||||
|
class CacheControlMixin(object): |
||||||
|
cache_timeout = 60 |
||||||
|
|
||||||
|
def get_cache_timeout(self): |
||||||
|
return self.cache_timeout |
||||||
|
|
||||||
|
def dispatch(self, *args, **kwargs): |
||||||
|
response = super(CacheControlMixin, self).dispatch(*args, **kwargs) |
||||||
|
patch_response_headers(response, self.get_cache_timeout()) |
||||||
|
return response |
||||||
|
|
||||||
|
|
||||||
|
class JitterCacheMixin(CacheControlMixin): |
||||||
|
cache_range = [60, 120] |
||||||
|
|
||||||
|
def get_cache_range(self): |
||||||
|
return self.cache_range |
||||||
|
|
||||||
|
def get_cache_timeout(self): |
||||||
|
return random.randint(*self.get_cache_range()) |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
from django.conf.urls import patterns, include, url |
||||||
|
from django.http import HttpResponse |
||||||
|
from django.views.decorators.cache import cache_page |
||||||
|
from redirect_views import old_redirect, old_profile |
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = patterns('', |
||||||
|
url(r'/rubricator.php?result_type=conference$', old_redirect, {'redirect_url': '/conference/'}), #??? |
||||||
|
# city |
||||||
|
url(r'^conference/city-(?P<city>.*)/year-(?P<year>\d+)/month-(?P<month>.*)$', old_redirect, {'redirect_url': '/conference/city/{city}/{year}/{month}/'}), |
||||||
|
url(r'^conference/city-(?P<city>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/conference/city/{city}/{year}/'}), |
||||||
|
url(r'^conference/city-(?P<city>.*)/$', old_redirect, {'redirect_url': '/conference/city/{city}/'}), |
||||||
|
#url(r'^conference/(?P<city>.*)/$', old_redirect, {'redirect_url': '/conference/city/{city}/'}), # перенести |
||||||
|
# country |
||||||
|
url(r'^conference/country-(?P<country>.*)/year-(?P<year>\d+)/month-(?P<month>.*)$', old_redirect, {'redirect_url': '/conference/country/{country}/{year}/{month}/'}), |
||||||
|
url(r'^conference/country-(?P<country>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/conference/country/{country}/{year}/'}), |
||||||
|
url(r'^conference/country-(?P<country>.*)/$', old_redirect, {'redirect_url': '/conference/country/{country}/'}), |
||||||
|
#url(r'/conference/(?P<country>.*)/$', old_redirect, {'redirect_url': '/conference/country/{country}/'}), # перенести |
||||||
|
# theme |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/{year}/{month}/'}), |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/{year}/'}), |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/city-(?P<city>.*)/year-(?P<year>\d+)/month-/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/city-(?P<city>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/city-(?P<city>.*)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/city/{city}/'}), |
||||||
|
#url(r'^conference/theme/(?P<theme>.*)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/'}), # перенести |
||||||
|
url(r'^conference/theme-(?P<theme>.*)/$', old_redirect, {'redirect_url': '/conference/theme/{theme}/'}), |
||||||
|
) |
||||||
@ -0,0 +1 @@ |
|||||||
|
__author__ = 'root' |
||||||
@ -0,0 +1 @@ |
|||||||
|
__author__ = 'root' |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
from django.core.management.base import BaseCommand, CommandError |
||||||
|
from django.test.client import RequestFactory |
||||||
|
from django.utils import translation |
||||||
|
from django.conf import settings |
||||||
|
from exposition.views import ExpositionByCity |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
def handle(self, *args, **options): |
||||||
|
langs = [code for code, name in settings.LANGUAGES] |
||||||
|
|
||||||
|
print(langs) |
||||||
|
|
||||||
|
#request = RequestFactory().get('/expo/city/') |
||||||
|
#view = ExpositionByCity.as_view() |
||||||
|
#response = view(request, name='bob') |
||||||
|
|
||||||
|
|
||||||
|
print('success') |
||||||
@ -0,0 +1,79 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
from django.conf.urls import patterns, include, url |
||||||
|
from django.http import HttpResponse |
||||||
|
from django.views.decorators.cache import cache_page |
||||||
|
from redirect_views import old_redirect, old_profile |
||||||
|
def test(request): |
||||||
|
return HttpResponse('test') |
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = patterns('', |
||||||
|
# service |
||||||
|
url(r'^rubricator.php/?result_type=expo$', old_redirect, {'redirect_url': '/expo/'}), #??? |
||||||
|
url(r'^serv-zaoch-info.php$', old_redirect, {'redirect_url': '/service/remote/'}), |
||||||
|
url(r'^serv-visit-info.php$', old_redirect, {'redirect_url': '/service/visit/'}), |
||||||
|
url(r'^serv-bilet-info.php$', old_redirect, {'redirect_url': '/service/tickets/'}), |
||||||
|
url(r'^serv-translator-info.php$', old_redirect, {'redirect_url': '/service/translator/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/buildstand.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/buildstand/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/bilet.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/tickets/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/zaoch.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/remote/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/translator.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/translator/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/visit.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/visit/'}), |
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*)/uchastie.html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/service/participation/'}), |
||||||
|
# company |
||||||
|
url(r'^company/(?P<company>.*)$', old_redirect, {'redirect_url': '/members/{company}/'}), |
||||||
|
# articles and news |
||||||
|
url(r'^articles.php$', old_redirect, {'redirect_url': '/blogs/'}), |
||||||
|
url(r'^news.php$', old_redirect, {'redirect_url': '/news/'}), |
||||||
|
url(r'^news.php/news/archive/', old_redirect, {'redirect_url': '/news/'}), |
||||||
|
url(r'^article_info.php/articles_id/(?P<article>\d+)/(?P<some>.*)$', old_redirect, {'redirect_url': '/blogs/{article}/'}), |
||||||
|
url(r'^news.php/news_id/(?P<article>\d+)/(?P<some>.*)$', old_redirect, {'redirect_url': '/news/{article}/'}), |
||||||
|
# users |
||||||
|
url(r'^users/(?P<user>.*)$', old_redirect, {'redirect_url': '/{user}/'}), |
||||||
|
url(r'^account_edit.php$', old_profile), |
||||||
|
url(r'^myexpo.php$', old_redirect, {'redirect_url': '/profile/calendar/'}), |
||||||
|
url(r'^newsletter2.php?email=(?P<some>.*)$', old_redirect, {'redirect_url': '/profile/settings/'}), |
||||||
|
url(r'^account_password.php$', old_redirect, {'redirect_url': '/profile/settings/'}), |
||||||
|
#url(r'^serv-personal-info.php$', old_redirect, {'redirect_url': '/service/staff/'}), |
||||||
|
# EXPO |
||||||
|
# city |
||||||
|
url(r'^catalog/city-(?P<city>)/theme-(?P<theme>.*)/year-(?P<year>\d+)/month-/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^catalog/city-(?P<city>.*)/theme-(?P<theme>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^catalog/city-(?P<city>.*)/theme-(?P<theme>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/'}), |
||||||
|
url(r'^catalog/city-(?P<city>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/expo/city/{city}/{year}/{month}'}), |
||||||
|
url(r'^catalog/city/(?P<city>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/expo/city/{city}/{year}/{month}'}), |
||||||
|
url(r'^catalog/city-(?P<city>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/city/{city}/{year}'}), |
||||||
|
url(r'^catalog/city/(?P<city>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/city/{city}/{year}'}), |
||||||
|
url(r'^catalog/city-(?P<city>.*)/$', old_redirect, {'redirect_url': '/expo/city/{city}/'}), |
||||||
|
# country |
||||||
|
url(r'^catalog/country-(?P<country>)/theme-(?P<theme>.*)/year-(?P<year>\d+)/month-/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/country-(?P<country>.*)/theme-(?P<theme>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/country-(?P<country>.*)/theme-(?P<theme>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/'}), |
||||||
|
url(r'^catalog/country-(?P<country>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/expo/country/{country}/{year}/{month}/'}), |
||||||
|
url(r'^catalog/country/(?P<country>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/expo/country/{country}/{year}/{month}/'}), |
||||||
|
url(r'^catalog/country-(?P<country>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/country/(?P<country>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/country/(?P<country>.*)/$', old_redirect, {'redirect_url': '/expo/country/{country}/'}), |
||||||
|
url(r'^catalog/country-(?P<country>.*)/$', old_redirect, {'redirect_url': '/expo/country/{country}/'}), |
||||||
|
url(r'^catalog/country/$', old_redirect, {'redirect_url': '/expo/country/'}), |
||||||
|
# theme |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/year-(?P<year>\d+)/month-(?P<month>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/{year}/{month}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/{year}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/city-(?P<city>)/year-(?P<year>\d+)/month-/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/city-(?P<city>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/{year}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/city-(?P<city>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/city/{city}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/country-(?P<country>)/year-(?P<year>\d+)/month-/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/country-(?P<country>.*)/year-(?P<year>\d+)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/{year}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/country-(?P<country>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/country/{country}/'}), |
||||||
|
url(r'^catalog/theme/(?P<theme>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/'}), |
||||||
|
url(r'^catalog/theme-(?P<theme>.*)/$', old_redirect, {'redirect_url': '/expo/theme/{theme}/'}), |
||||||
|
url(r'^catalog/theme/$', old_redirect, {'redirect_url': '/expo/theme/'}), |
||||||
|
# tag |
||||||
|
url(r'^tag/(?P<tag>.*)/$', old_redirect, {'redirect_url': '/expo/tag/{tag}/'}), |
||||||
|
|
||||||
|
url(r'^catalog/(?P<city>.*)/$', old_redirect, {'redirect_url': '/expo/city/{city}/'}), |
||||||
|
url(r'^catalog/$', old_redirect, {'redirect_url': '/expo/city/'}), |
||||||
|
# tag |
||||||
|
|
||||||
|
url(r'^(?P<some>.*)/(?P<event>.*).html$', old_redirect, {'redirect_url': '{event_catalog}{event_url}/'}), |
||||||
|
) |
||||||
@ -0,0 +1,97 @@ |
|||||||
|
from django.http import HttpResponseRedirect, HttpResponse, Http404, HttpResponsePermanentRedirect |
||||||
|
from django.shortcuts import get_object_or_404 |
||||||
|
from city.models import City |
||||||
|
from country.models import Country |
||||||
|
from theme.models import Theme, Tag |
||||||
|
from exposition.models import Exposition |
||||||
|
from conference.models import Conference |
||||||
|
from company.models import Company |
||||||
|
from article.models import Article |
||||||
|
from accounts.models import User |
||||||
|
|
||||||
|
|
||||||
|
class RedirectMixin(object): |
||||||
|
model = None |
||||||
|
|
||||||
|
def get_object_url(self, key, value): |
||||||
|
Model = self.model |
||||||
|
|
||||||
|
try: |
||||||
|
obj = Model.objects.get(old_url=value) |
||||||
|
except: |
||||||
|
obj = get_object_or_404(Model, url=value) |
||||||
|
if obj: |
||||||
|
return {key: obj.url} |
||||||
|
else: |
||||||
|
raise Http404 |
||||||
|
|
||||||
|
class CityRedirect(RedirectMixin): |
||||||
|
model = City |
||||||
|
|
||||||
|
class CountryRedirect(RedirectMixin): |
||||||
|
model = Country |
||||||
|
|
||||||
|
class ThemeRedirect(RedirectMixin): |
||||||
|
model = Theme |
||||||
|
|
||||||
|
class TagRedirect(RedirectMixin): |
||||||
|
model = Tag |
||||||
|
|
||||||
|
class CompanyRedirect(RedirectMixin): |
||||||
|
model = Company |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class EventRedirect(object): |
||||||
|
|
||||||
|
def get_object_url(self,key, value): |
||||||
|
|
||||||
|
try: |
||||||
|
obj = Exposition.objects.get(old_url=value) |
||||||
|
except Exposition.DoesNotExist: |
||||||
|
obj = Exposition.objects.safe_get(url=value) |
||||||
|
|
||||||
|
if not obj: |
||||||
|
try: |
||||||
|
obj = Conference.objects.get(old_url=value) |
||||||
|
except Conference.DoesNotExist: |
||||||
|
obj = Conference.objects.safe_get(url=value) |
||||||
|
if obj: |
||||||
|
return {'event_url': obj.url, 'event_catalog': obj.catalog} |
||||||
|
else: |
||||||
|
raise Http404 |
||||||
|
|
||||||
|
class ArticleRedirect(object): |
||||||
|
def get_object_url(self,key, value): |
||||||
|
obj = get_object_or_404(Article, id=value) |
||||||
|
return {key: obj.slug} |
||||||
|
|
||||||
|
class UserRedirect(object): |
||||||
|
def get_object_url(self,key, value): |
||||||
|
obj = get_object_or_404(User, url=value) |
||||||
|
return {key: obj.url} |
||||||
|
|
||||||
|
|
||||||
|
old_params = {'city': CityRedirect, 'country': CountryRedirect, 'theme': ThemeRedirect, 'tag': TagRedirect, |
||||||
|
'event': EventRedirect, 'company': Company, 'article': ArticleRedirect, 'user': UserRedirect} |
||||||
|
|
||||||
|
def old_redirect(request, *args, **kwargs): |
||||||
|
redirect = kwargs.get('redirect_url') |
||||||
|
params = dict(kwargs) |
||||||
|
updates = {} |
||||||
|
for key, value in params.iteritems(): |
||||||
|
if key in old_params: |
||||||
|
redirect_obj = old_params[key]() |
||||||
|
updates.update(redirect_obj.get_object_url(key, value)) |
||||||
|
|
||||||
|
|
||||||
|
params.update(updates) |
||||||
|
redirect = redirect.format(**params) |
||||||
|
return HttpResponsePermanentRedirect(redirect) |
||||||
|
|
||||||
|
def old_profile(request): |
||||||
|
user = request.user |
||||||
|
if user.is_authenticated(): |
||||||
|
return HttpResponseRedirect('/%s/'%user.url) |
||||||
|
else: |
||||||
|
raise Http404 |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
{% load i18n %} |
||||||
|
|
||||||
|
<div class="i-sub-articles"> |
||||||
|
<ul> |
||||||
|
<li> |
||||||
|
<a href="{{ event.get_permanent_url }}service/translator/">{% trans 'Устный переводчик' %}</a> |
||||||
|
</li> |
||||||
|
<li> |
||||||
|
<a href="{{ event.get_permanent_url }}service/visit/">{% trans 'Бизнес-тур "под ключ"' %}</a> |
||||||
|
</li> |
||||||
|
</ul> |
||||||
|
</div> |
||||||
@ -0,0 +1,199 @@ |
|||||||
|
{% extends 'base_catalog.html' %} |
||||||
|
{% load static %} |
||||||
|
{% load i18n %} |
||||||
|
|
||||||
|
{% block bread_scrumbs %} |
||||||
|
<div class="bread-crumbs"> |
||||||
|
{% if object %} |
||||||
|
<a href="/">{% trans 'Главная страница' %}</a> |
||||||
|
<a href="{{ object.catalog }}">{{ object.catalog_name }}</a> |
||||||
|
<a href="{{ object.catalog }}country/{{ object.country.url }}/">{{ object.country }}</a> |
||||||
|
<a href="{{ object.catalog }}city/{{ object.city.url }}/">{{ object.city }}</a> |
||||||
|
<a href="{{ object.get_permanent_url }}">{{ object.name }}</a> |
||||||
|
<strong>{% trans 'Строительство стенда' %}</strong> |
||||||
|
{% else %} |
||||||
|
<a href="/">{% trans 'Главная страница' %}</a> |
||||||
|
<strong>{% trans 'Строительство стенда' %}</strong> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% block page_title %} |
||||||
|
<div class="page-title"> |
||||||
|
<h1>{% if meta %}{{ meta.h1 }}{% else %}{% trans 'Строительство стенда' %} {% if object %}{% trans 'на' %} {{ object.name }} {% endif %}{% endif %}</h1> |
||||||
|
</div> |
||||||
|
{% endblock %} |
||||||
|
|
||||||
|
{% block page_body %} |
||||||
|
|
||||||
|
<div class="page-body clearfix request-form rq-catalog"> |
||||||
|
|
||||||
|
<div class="m-article"> |
||||||
|
|
||||||
|
<div class="rq-info clearfix"> |
||||||
|
|
||||||
|
<div class="rqi-pict"><img src="{% static 'client/img/_del-temp/request-catalog.png' %}" alt="" /></div> |
||||||
|
|
||||||
|
|
||||||
|
<div class="rqi-body"> |
||||||
|
<h2>{% trans 'Предлагаем Вам заказать печатный каталог выставки' %}{% if object %} {{ object.name }} {% endif %}</h2> |
||||||
|
|
||||||
|
<div class="rqi-cols"> |
||||||
|
<ul> |
||||||
|
<li>{% trans 'вся информация о выставке' %}</li> |
||||||
|
<li>{% trans 'экономия времени' %}</li> |
||||||
|
<li>{% trans 'все потенциальные контакты' %}</li> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<ul> |
||||||
|
<li>{% trans 'вся информация о выставке' %}</li> |
||||||
|
<li>{% trans 'экономия времени' %}</li> |
||||||
|
<li>{% trans 'все потенциальные контакты' %}</li> |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="rq-form" {% if form.errors %}style="display:block"{% endif %}> |
||||||
|
<form action="#" method="post">{% csrf_token %} |
||||||
|
|
||||||
|
<hr /> |
||||||
|
|
||||||
|
<div class="rq-form-sect rq-contacts-data"> |
||||||
|
|
||||||
|
<div class="rqf-title">{% trans 'Ваши контактные данные' %}</div> |
||||||
|
|
||||||
|
<div class="mf-line rq-person"> |
||||||
|
<div class="mf-field"> |
||||||
|
{{ form.person_inf }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="mf-line rq-person"> |
||||||
|
<div class="mf-field error"> |
||||||
|
{{ form.person_inf.errors }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mf-line cols-2 rq-place"> |
||||||
|
<div class="mf-field rq-country"> |
||||||
|
{{ form.country }} |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mf-field rq-city"> |
||||||
|
{{ form.city }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="mf-line cols-2 rq-place"> |
||||||
|
<div class="mf-field rq-country error"> |
||||||
|
{{ form.country.errors }} |
||||||
|
</div> |
||||||
|
<div class="mf-field rq-city error"> |
||||||
|
{{ form.city.errors }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mf-line cols-2 rq-contacts"> |
||||||
|
<div class="mf-field rq-tel"> |
||||||
|
{{ form.phone }} |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="mf-field rq-mail"> |
||||||
|
{{ form.person }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="mf-line cols-2 rq-contacts"> |
||||||
|
<div class="mf-field rq-tel error"> |
||||||
|
{{ form.phone.errors }} |
||||||
|
</div> |
||||||
|
<div class="mf-field rq-mail error"> |
||||||
|
{{ form.person.errors }} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<hr /> |
||||||
|
|
||||||
|
<div class="rq-btn-wrap"> |
||||||
|
|
||||||
|
<div class="rq-order-button"> |
||||||
|
<div class="rqob-wrap"> |
||||||
|
<div class="rqob-price">{{ service.price }} {{ service.currency }} + {% trans 'стоимость каталога' %}</div> |
||||||
|
<div class="rqob-button"> |
||||||
|
{% if service.price %} |
||||||
|
<input id="id_price" name="price" type="hidden" value="{{ service.price }}"/> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if service.price %} |
||||||
|
<input id="id_currency" name="currency" type="hidden" value="{{ service.currency }}"/> |
||||||
|
{% endif %} |
||||||
|
<button type="submit">{% trans 'Сделать запрос' %}</button> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="ob-descr">{% trans 'Стоимость каталога оплачивается c учетом доставки, которую обозначают организаторы выставки (в среднем от 0 до 50 евро).' %}</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
</form> |
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="rq-btn-wrap rq-btn-to-hide"> |
||||||
|
|
||||||
|
<div class="rq-order-button"> |
||||||
|
<div class="rqob-wrap"> |
||||||
|
<div class="rqob-price">{{ service.price }} {{ service.currency }} + {% trans 'стоимость каталога' %}</div> |
||||||
|
<div class="rqob-button"> |
||||||
|
<a class="ob-text" href="#">{% trans 'Сделать запрос' %}</a> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
<div class="ob-descr">{% trans 'Стоимость каталога оплачивается c учетом доставки, которую обозначают организаторы выставки (в среднем от 0 до 50 евро).' %}</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
{% if messages %} |
||||||
|
<div class="alert-message"> |
||||||
|
<ul> |
||||||
|
{% for message in messages %} |
||||||
|
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}> |
||||||
|
{{ message }} |
||||||
|
</li> |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
|
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
<hr /> |
||||||
|
<div class="rq-note"> |
||||||
|
{% trans '<p><b>Внимание!</b> Мы не можем гарантировать то, что все организаторы предоставляют возможность заказа печатного каталога выставки. Получая Ваш запрос, мы персонально связываемся с организатором конкретного события и уточняем информацию об условиях приобретения. Только после этого мы подтверждаем Вам возможность заказа.</p>' %} |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
<div class="rq-to-hide"> |
||||||
|
|
||||||
|
<div class="i-sub-articles"> |
||||||
|
<ul> |
||||||
|
{% if object %} |
||||||
|
<li><a href="{{ object.get_permanent_url }}service/visit/">{% trans 'Бизнес-тур «под ключ' %}»</a></li> |
||||||
|
<li><a href="{{ object.get_permanent_url }}service/translator/">{% trans 'Устный переводчик' %}</a></li> |
||||||
|
<li><a href="{{ object.get_permanent_url }}service/participation/">{% trans 'Участие в выставке' %}</a></li> |
||||||
|
<li><a href="{{ object.get_permanent_url }}service/remote/">{% trans 'Заочное посещение' %}</a></li> |
||||||
|
{% else %} |
||||||
|
<li><a href="/service/visit/">{% trans 'Бизнес-тур «под ключ' %}»</a></li> |
||||||
|
<li><a href="/service/translator/">{% trans 'Устный переводчик' %}</a></li> |
||||||
|
<li><a href="/service/participation/">{% trans 'Участие в выставке' %}</a></li> |
||||||
|
<li><a href="/service/remote/">{% trans 'Заочное посещение' %}</a></li> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
|
||||||
|
</div> |
||||||
|
{% endblock %} |
||||||
@ -0,0 +1,70 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %}{% load url from future %} |
||||||
|
<style type="text/css"> |
||||||
|
@media print { #djDebug {display:none;}} |
||||||
|
</style> |
||||||
|
<link rel="stylesheet" href="{% static 'debug_toolbar/css/toolbar.css' %}" type="text/css" /> |
||||||
|
{% if toolbar.config.JQUERY_URL %} |
||||||
|
<!-- Prevent our copy of jQuery from registering as an AMD module on sites that use RequireJS. --> |
||||||
|
<script>var _djdt_define_backup = window.define; window.define = undefined;</script> |
||||||
|
<script src="{{ toolbar.config.JQUERY_URL }}"></script> |
||||||
|
<script>var djdt = {jQuery: jQuery.noConflict(true)}; window.define = _djdt_define_backup;</script> |
||||||
|
{% else %} |
||||||
|
<script>var djdt = {jQuery: jQuery};</script> |
||||||
|
{% endif %} |
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script> |
||||||
|
<div id="djDebug" style="display:none;" dir="ltr" |
||||||
|
data-store-id="{{ toolbar.store_id }}" data-render-panel-url="{% url 'djdt:render_panel' %}" |
||||||
|
{{ toolbar.config.ROOT_TAG_EXTRA_ATTRS|safe }}> |
||||||
|
<div style="display:none;" id="djDebugToolbar"> |
||||||
|
<ul id="djDebugPanelList"> |
||||||
|
{% if toolbar.panels %} |
||||||
|
<li><a id="djHideToolBarButton" href="#" title="{% trans "Hide toolbar" %}">{% trans "Hide" %} »</a></li> |
||||||
|
{% else %} |
||||||
|
<li id="djDebugButton">DEBUG</li> |
||||||
|
{% endif %} |
||||||
|
{% for panel in toolbar.panels %} |
||||||
|
<li class="djDebugPanelButton"> |
||||||
|
<input type="checkbox" data-cookie="djdt{{ panel.panel_id }}" {% if panel.enabled %}checked="checked" title="{% trans "Disable for next and successive requests" %}"{% else %}title="{% trans "Enable for next and successive requests" %}"{% endif %} /> |
||||||
|
{% if panel.has_content and panel.enabled %} |
||||||
|
<a href="#" title="{{ panel.title }}" class="{{ panel.panel_id }}"> |
||||||
|
{% else %} |
||||||
|
<div class="djdt-contentless{% if not panel.enabled %} djdt-disabled{% endif %}"> |
||||||
|
{% endif %} |
||||||
|
{{ panel.nav_title }} |
||||||
|
{% if panel.enabled %} |
||||||
|
{% with panel.nav_subtitle as subtitle %} |
||||||
|
{% if subtitle %}<br /><small>{{ subtitle }}</small>{% endif %} |
||||||
|
{% endwith %} |
||||||
|
{% endif %} |
||||||
|
{% if panel.has_content and panel.enabled %} |
||||||
|
</a> |
||||||
|
{% else %} |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
</li> |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
<div style="display:none;" id="djDebugToolbarHandle"> |
||||||
|
<span title="{% trans "Show toolbar" %}" id="djShowToolBarButton">«</span> |
||||||
|
</div> |
||||||
|
{% for panel in toolbar.panels %} |
||||||
|
{% if panel.has_content and panel.enabled %} |
||||||
|
<div id="{{ panel.panel_id }}" class="djdt-panelContent"> |
||||||
|
<div class="djDebugPanelTitle"> |
||||||
|
<a href="" class="djDebugClose"></a> |
||||||
|
<h3>{{ panel.title|safe }}</h3> |
||||||
|
</div> |
||||||
|
<div class="djDebugPanelContent"> |
||||||
|
{% if toolbar.store_id %} |
||||||
|
<img src="{% static 'debug_toolbar/img/ajax-loader.gif' %}" alt="loading" class="djdt-loader" /> |
||||||
|
<div class="djdt-scroll"></div> |
||||||
|
{% else %} |
||||||
|
<div class="djdt-scroll">{{ panel.content }}</div> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
{% endif %} |
||||||
|
{% endfor %} |
||||||
|
<div id="djDebugWindow" class="djdt-panelContent"></div> |
||||||
|
</div> |
||||||
@ -0,0 +1,69 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<h4>{% trans "Summary" %}</h4> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Total calls" %}</th> |
||||||
|
<th>{% trans "Total time" %}</th> |
||||||
|
<th>{% trans "Cache hits" %}</th> |
||||||
|
<th>{% trans "Cache misses" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr> |
||||||
|
<td>{{ total_calls }}</td> |
||||||
|
<td>{{ total_time }} ms</td> |
||||||
|
<td>{{ hits }}</td> |
||||||
|
<td>{{ misses }}</td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
<h4>{% trans "Commands" %}</h4> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
{% for name in counts.keys %} |
||||||
|
<th>{{ name }}</th> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr> |
||||||
|
{% for value in counts.values %} |
||||||
|
<td>{{ value }}</td> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% if calls %} |
||||||
|
<h4>{% trans "Calls" %}</h4> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th colspan="2">{% trans "Time (ms)" %}</th> |
||||||
|
<th>{% trans "Type" %}</th> |
||||||
|
<th>{% trans "Arguments" %}</th> |
||||||
|
<th>{% trans "Keyword arguments" %}</th> |
||||||
|
<th>{% trans "Backend" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for call in calls %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}" id="cacheMain_{{ forloop.counter }}"> |
||||||
|
<td class="djdt-toggle"> |
||||||
|
<a class="djToggleSwitch" data-toggle-name="cacheMain" data-toggle-id="{{ forloop.counter }}" data-toggle-open="+" data-toggle-close="-" href="javascript:void(0)">+</a> |
||||||
|
</td> |
||||||
|
<td>{{ call.time|floatformat:"4" }}</td> |
||||||
|
<td>{{ call.name|escape }}</td> |
||||||
|
<td>{{ call.args|escape }}</td> |
||||||
|
<td>{{ call.kwargs|escape }}</td> |
||||||
|
<td>{{ call.backend }}</td> |
||||||
|
</tr> |
||||||
|
<tr class="djUnselected djDebugHoverable {% cycle 'djDebugOdd' 'djDebugEven' %} djToggleDetails_{{ forloop.counter }}" id="cacheDetails_{{ forloop.counter }}"> |
||||||
|
<td colspan="1"></td> |
||||||
|
<td colspan="5"><pre class="djdt-stack">{{ call.trace }}</pre></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% endif %} |
||||||
@ -0,0 +1,60 @@ |
|||||||
|
{% load i18n %} |
||||||
|
|
||||||
|
<h4>{% trans "Request headers" %}</h4> |
||||||
|
|
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Key" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in request_headers.items %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ key|escape }}</td> |
||||||
|
<td>{{ value|escape }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<h4>{% trans "Response headers" %}</h4> |
||||||
|
|
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Key" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in response_headers.items %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ key|escape }}</td> |
||||||
|
<td>{{ value|escape }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<h4>{% trans "WSGI environ" %}</h4> |
||||||
|
|
||||||
|
<p>{% trans "Since the WSGI environ inherits the environment of the server, only a significant subset is shown below." %}</p> |
||||||
|
|
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Key" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in environ.items %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ key|escape }}</td> |
||||||
|
<td>{{ value|escape }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
@ -0,0 +1,28 @@ |
|||||||
|
{% load i18n %} |
||||||
|
{% if records %} |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Level" %}</th> |
||||||
|
<th>{% trans "Time" %}</th> |
||||||
|
<th>{% trans "Channel" %}</th> |
||||||
|
<th>{% trans "Message" %}</th> |
||||||
|
<th>{% trans "Location" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for record in records %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ record.level }}</td> |
||||||
|
<td>{{ record.time|date:"h:i:s m/d/Y" }}</td> |
||||||
|
<td>{{ record.channel|default:"-" }}</td> |
||||||
|
<td>{{ record.message|linebreaksbr }}</td> |
||||||
|
<td>{{ record.file }}:{{ record.line }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "No messages logged" %}.</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
@ -0,0 +1,37 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %} |
||||||
|
<table width="100%"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Call" %}</th> |
||||||
|
<th>{% trans "CumTime" %}</th> |
||||||
|
<th>{% trans "Per" %}</th> |
||||||
|
<th>{% trans "TotTime" %}</th> |
||||||
|
<th>{% trans "Per" %}</th> |
||||||
|
<th>{% trans "Count" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for call in func_list %} |
||||||
|
<!-- style="background:{{ call.background }}" --> |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %} djDebugProfileRow{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %}" depth="{{ call.depth }}"> |
||||||
|
<td> |
||||||
|
<div style="padding-left: {{ call.indent }}px;"> |
||||||
|
{% if call.has_subfuncs %} |
||||||
|
<a class="djProfileToggleDetails djToggleSwitch" data-toggle-id="{{ call.id }}" data-toggle-open="+" data-toggle-close="-" href="javascript:void(0)">-</a> |
||||||
|
{% else %} |
||||||
|
<span class="djNoToggleSwitch"></span> |
||||||
|
{% endif %} |
||||||
|
<span class="djdt-stack">{{ call.func_std_string }}</span> |
||||||
|
</div> |
||||||
|
</td> |
||||||
|
<td>{{ call.cumtime|floatformat:3 }}</td> |
||||||
|
<td>{{ call.cumtime_per_call|floatformat:3 }}</td> |
||||||
|
<td>{{ call.tottime|floatformat:3 }}</td> |
||||||
|
<td>{{ call.tottime_per_call|floatformat:3 }}</td> |
||||||
|
<td>{{ call.count }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.profiling.js' %}"></script> |
||||||
@ -0,0 +1,124 @@ |
|||||||
|
{% load i18n %} |
||||||
|
|
||||||
|
<h4>{% trans "View information" %}</h4> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "View function" %}</th> |
||||||
|
<th>{% trans "Arguments" %}</th> |
||||||
|
<th>{% trans "Keyword arguments" %}</th> |
||||||
|
<th>{% trans "URL name" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
<tr> |
||||||
|
<td class="djDebugOdd"><code>{{ view_func }}</code></td> |
||||||
|
<td class="djDebugEven"><code>{{ view_args|pprint }}</code></td> |
||||||
|
<td class="djDebugOdd"><code>{{ view_kwargs|pprint }}</code></td> |
||||||
|
<td class="djDebugEven"><code>{{ view_urlname }}</code></td> |
||||||
|
</tr> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
{% if cookies %} |
||||||
|
<h4>{% trans "Cookies" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col/> |
||||||
|
</colgroup> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Variable" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in cookies %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td><code>{{ key|pprint }}</code></td> |
||||||
|
<td><code>{{ value|pprint }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<h4>{% trans "No cookies" %}</h4> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if session %} |
||||||
|
<h4>{% trans "Session data" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col/> |
||||||
|
</colgroup> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Variable" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in session %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td><code>{{ key|pprint }}</code></td> |
||||||
|
<td><code>{{ value|pprint }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<h4>{% trans "No session data" %}</h4> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if get %} |
||||||
|
<h4>{% trans "GET data" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col/> |
||||||
|
</colgroup> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Variable" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in get %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td><code>{{ key|pprint }}</code></td> |
||||||
|
<td><code>{{ value|pprint }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<h4>{% trans "No GET data" %}</h4> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
{% if post %} |
||||||
|
<h4>{% trans "POST data" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col/> |
||||||
|
</colgr |
||||||
|
<tr> |
||||||
|
<th>{% trans "Variable" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in post %} |
||||||
|
<tr class="{% cycle 'row1' 'row2' %}"> |
||||||
|
<td><code>{{ key|pprint }}</code></td> |
||||||
|
<td><code>{{ value|pprint }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<h4>{% trans "No POST data" %}</h4> |
||||||
|
{% endif %} |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Setting" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for name, value in settings.items %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ name }}</td> |
||||||
|
<td><code>{{ value|pprint }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Signal" %}</th> |
||||||
|
<th>{% trans "Providing" %}</th> |
||||||
|
<th>{% trans "Receivers" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for name, signal, receivers in signals %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ name|escape }}</td> |
||||||
|
<td>{{ signal.providing_args|join:", " }}</td> |
||||||
|
<td>{{ receivers|join:", " }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
@ -0,0 +1,95 @@ |
|||||||
|
{% load i18n l10n %}{% load static from staticfiles %}{% load url from future %} |
||||||
|
<div class="djdt-clearfix"> |
||||||
|
<ul class="djdt-stats"> |
||||||
|
{% for alias, info in databases %} |
||||||
|
<li> |
||||||
|
<strong class="djdt-label"><span style="background-color: rgb({{ info.rgb_color|join:", " }})" class="djdt-color"> </span> {{ alias }}</strong> |
||||||
|
<span class="djdt-info">{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %})</span> |
||||||
|
</li> |
||||||
|
{% endfor %} |
||||||
|
</ul> |
||||||
|
</div> |
||||||
|
|
||||||
|
{% if queries %} |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th class="djdt-color"> </th> |
||||||
|
<th class="query" colspan="2">{% trans "Query" %}</th> |
||||||
|
<th class="timeline">{% trans "Timeline" %}</th> |
||||||
|
<th class="djdt-time">{% trans "Time (ms)" %}</th> |
||||||
|
<th class="djdt-actions">{% trans "Action" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for query in queries %} |
||||||
|
<tr class="djDebugHoverable {% cycle 'djDebugOdd' 'djDebugEven' %}{% if query.is_slow %} djDebugRowWarning{% endif %}{% if query.starts_trans %} djDebugStartTransaction{% endif %}{% if query.ends_trans %} djDebugEndTransaction{% endif %}{% if query.in_trans %} djDebugInTransaction{% endif %}" id="sqlMain_{{ forloop.counter }}"> |
||||||
|
<td class="djdt-color"><span style="background-color: rgb({{ query.rgb_color|join:", " }});"> </span></td> |
||||||
|
<td class="djdt-toggle"> |
||||||
|
<a class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}" data-toggle-open="+" data-toggle-close="-" href="javascript:void(0)">+</a> |
||||||
|
</td> |
||||||
|
<td class="query"> |
||||||
|
<div class="djDebugSqlWrap"> |
||||||
|
<div class="djDebugSql">{{ query.sql|safe }}</div> |
||||||
|
</div> |
||||||
|
</td> |
||||||
|
<td class="timeline"> |
||||||
|
<div class="djDebugTimeline"><div class="djDebugLineChart{% if query.is_slow %} djDebugLineChartWarning{% endif %}" style="left:{{ query.start_offset|unlocalize }}%;"><strong style="width:{{ query.width_ratio_relative|unlocalize }}%; background-color:{{ query.trace_color }};">{{ query.width_ratio }}%</strong></div></div> |
||||||
|
</td> |
||||||
|
<td class="djdt-time"> |
||||||
|
{{ query.duration|floatformat:"2" }} |
||||||
|
</td> |
||||||
|
<td class="djdt-actions"> |
||||||
|
|
||||||
|
{% if query.params %} |
||||||
|
{% if query.is_select %} |
||||||
|
<form method="post"> |
||||||
|
{{ query.form }} |
||||||
|
|
||||||
|
<button formaction="{% url 'djdt:sql_select' %}" class="remoteCall">Sel</button> |
||||||
|
<button formaction="{% url 'djdt:sql_explain' %}" class="remoteCall">Expl</button> |
||||||
|
|
||||||
|
{% if query.vendor == 'mysql' %} |
||||||
|
<button formaction="{% url 'djdt:sql_profile' %}" class="remoteCall">Prof</button> |
||||||
|
{% endif %} |
||||||
|
</form> |
||||||
|
{% endif %} |
||||||
|
{% endif %} |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
<tr class="djUnselected djDebugHoverable {% cycle 'djDebugOdd' 'djDebugEven' %}{% if query.is_slow %} djDebugRowWarning{% endif %} djToggleDetails_{{ forloop.counter }}" id="sqlDetails_{{ forloop.counter }}"> |
||||||
|
<td colspan="2"></td> |
||||||
|
<td colspan="4"> |
||||||
|
<div class="djSQLDetailsDiv"> |
||||||
|
<p><strong>{% trans "Connection:" %}</strong> {{ query.alias }}</p> |
||||||
|
{% if query.iso_level %} |
||||||
|
<p><strong>{% trans "Isolation level:" %}</strong> {{ query.iso_level }}</p> |
||||||
|
{% endif %} |
||||||
|
{% if query.trans_status %} |
||||||
|
<p><strong>{% trans "Transaction status:" %}</strong> {{ query.trans_status }}</p> |
||||||
|
{% endif %} |
||||||
|
{% if query.stacktrace %} |
||||||
|
<pre class="djdt-stack">{{ query.stacktrace }}</pre> |
||||||
|
{% endif %} |
||||||
|
{% if query.template_info %} |
||||||
|
<table> |
||||||
|
{% for line in query.template_info.context %} |
||||||
|
<tr> |
||||||
|
<td>{{ line.num }}</td> |
||||||
|
<td><code style="font-family: monospace;{% if line.highlight %}background-color: lightgrey{% endif %}">{{ line.content }}</code></td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</table> |
||||||
|
<p><strong>{{ query.template_info.name|default:_("(unknown)") }}</strong></p> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "No SQL queries were recorded during this request." %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script> |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %} |
||||||
|
<div class="djDebugPanelTitle"> |
||||||
|
<a class="djDebugClose djDebugBack" href=""></a> |
||||||
|
<h3>{% trans "SQL explained" %}</h3> |
||||||
|
</div> |
||||||
|
<div class="djDebugPanelContent"> |
||||||
|
<div class="djdt-scroll"> |
||||||
|
<dl> |
||||||
|
<dt>{% trans "Executed SQL" %}</dt> |
||||||
|
<dd>{{ sql|safe }}</dd> |
||||||
|
<dt>{% trans "Time" %}</dt> |
||||||
|
<dd>{{ duration }} ms</dd> |
||||||
|
<dt>{% trans "Database" %}</dt> |
||||||
|
<dd>{{ alias }}</dd> |
||||||
|
</dl> |
||||||
|
<table class="djSqlExplain"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
{% for h in headers %} |
||||||
|
<th>{{ h|upper }}</th> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for row in result %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
{% for column in row %} |
||||||
|
<td>{{ column|escape }}</td> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script> |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %} |
||||||
|
<div class="djDebugPanelTitle"> |
||||||
|
<a class="djDebugClose djDebugBack" href=""></a> |
||||||
|
<h3>{% trans "SQL profiled" %}</h3> |
||||||
|
</div> |
||||||
|
<div class="djDebugPanelContent"> |
||||||
|
<div class="djdt-scroll"> |
||||||
|
{% if result %} |
||||||
|
<dl> |
||||||
|
<dt>{% trans "Executed SQL" %}</dt> |
||||||
|
<dd>{{ sql|safe }}</dd> |
||||||
|
<dt>{% trans "Time" %}</dt> |
||||||
|
<dd>{{ duration }} ms</dd> |
||||||
|
<dt>{% trans "Database" %}</dt> |
||||||
|
<dd>{{ alias }}</dd> |
||||||
|
</dl> |
||||||
|
<table class="djSqlProfile"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
{% for h in headers %} |
||||||
|
<th>{{ h|upper }}</th> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for row in result %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
{% for column in row %} |
||||||
|
<td>{{ column|escape }}</td> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<dl> |
||||||
|
<dt>{% trans "Error" %}</dt> |
||||||
|
<dd>{{ result_error }}</dd> |
||||||
|
</dl> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script> |
||||||
@ -0,0 +1,41 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %} |
||||||
|
<div class="djDebugPanelTitle"> |
||||||
|
<a class="djDebugClose djDebugBack" href=""></a> |
||||||
|
<h3>{% trans "SQL selected" %}</h3> |
||||||
|
</div> |
||||||
|
<div class="djDebugPanelContent"> |
||||||
|
<div class="djdt-scroll"> |
||||||
|
<dl> |
||||||
|
<dt>{% trans "Executed SQL" %}</dt> |
||||||
|
<dd>{{ sql|safe }}</dd> |
||||||
|
<dt>{% trans "Time" %}</dt> |
||||||
|
<dd>{{ duration }} ms</dd> |
||||||
|
<dt>{% trans "Database" %}</dt> |
||||||
|
<dd>{{ alias }}</dd> |
||||||
|
</dl> |
||||||
|
{% if result %} |
||||||
|
<table class="djSqlSelect"> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
{% for h in headers %} |
||||||
|
<th>{{ h|upper }}</th> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for row in result %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
{% for column in row %} |
||||||
|
<td>{{ column|escape }}</td> |
||||||
|
{% endfor %} |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "Empty set" %}</p> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.sql.js' %}"></script> |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
{% load i18n %} |
||||||
|
{% load static from staticfiles%} |
||||||
|
|
||||||
|
<h4>{% blocktrans count staticfiles_dirs|length as dirs_count %}Static file path{% plural %}Static file paths{% endblocktrans %}</h4> |
||||||
|
{% if staticfiles_dirs %} |
||||||
|
<ol> |
||||||
|
{% for prefix, staticfiles_dir in staticfiles_dirs %} |
||||||
|
<li>{{ staticfiles_dir }}{% if prefix %} {% blocktrans %}(prefix {{ prefix }}){% endblocktrans %}{% endif %}</li> |
||||||
|
{% endfor %} |
||||||
|
</ol> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<h4>{% blocktrans count staticfiles_apps|length as apps_count %}Static file app{% plural %}Static file apps{% endblocktrans %}</h4> |
||||||
|
{% if staticfiles_apps %} |
||||||
|
<ol> |
||||||
|
{% for static_app in staticfiles_apps %} |
||||||
|
<li>{{ static_app }}</li> |
||||||
|
{% endfor %} |
||||||
|
</ol> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<h4>{% blocktrans count staticfiles|length as staticfiles_count %}Static file{% plural %}Static files{% endblocktrans %}</h4> |
||||||
|
{% if staticfiles %} |
||||||
|
<dl> |
||||||
|
{% for staticfile in staticfiles %} |
||||||
|
<dt><strong><a class="toggleTemplate" href="{{ staticfile.url }}">{{ staticfile }}</a></strong></dt> |
||||||
|
<dd><samp>{{ staticfile.real_path }}</samp></dd> |
||||||
|
{% endfor %} |
||||||
|
</dl> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
|
||||||
|
{% for finder, payload in staticfiles_finders.items %} |
||||||
|
<h4>{{ finder }} ({% blocktrans count payload|length as payload_count %}{{ payload_count }} file{% plural %}{{ payload_count }} files{% endblocktrans %})</h4> |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans 'Path' %}</th> |
||||||
|
<th>{% trans 'Location' %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for path, real_path in payload %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ path }}</td> |
||||||
|
<td>{{ real_path }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
{% endfor %} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<div class="djDebugPanelTitle"> |
||||||
|
<a class="djDebugClose djDebugBack" href=""></a> |
||||||
|
<h3>{% trans "Template source:" %} <code>{{ template_name }}</code></h3> |
||||||
|
</div> |
||||||
|
<div class="djDebugPanelContent"> |
||||||
|
<div class="djdt-scroll"> |
||||||
|
{% if not source.pygmentized %} |
||||||
|
<code>{{ source }}</code> |
||||||
|
{% else %} |
||||||
|
{{ source }} |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
</div> |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %}{% load url from future %} |
||||||
|
<h4>{% blocktrans count template_dirs|length as template_count %}Template path{% plural %}Template paths{% endblocktrans %}</h4> |
||||||
|
{% if template_dirs %} |
||||||
|
<ol> |
||||||
|
{% for template in template_dirs %} |
||||||
|
<li>{{ template }}</li> |
||||||
|
{% endfor %} |
||||||
|
</ol> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<h4>{% blocktrans count templates|length as template_count %}Template{% plural %}Templates{% endblocktrans %}</h4> |
||||||
|
{% if templates %} |
||||||
|
<dl> |
||||||
|
{% for template in templates %} |
||||||
|
<dt><strong><a class="remoteCall toggleTemplate" href="{% url 'djdt:template_source' %}?template={{ template.template.name }}">{{ template.template.name|addslashes }}</a></strong></dt> |
||||||
|
<dd><samp>{{ template.template.origin_name|addslashes }}</samp></dd> |
||||||
|
{% if template.context %} |
||||||
|
<dd> |
||||||
|
<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">▶</span> {% trans "Toggle context" %}</a></div> |
||||||
|
<div class="djTemplateHideContextDiv" style="display:none;"><code>{{ template.context }}</code></div> |
||||||
|
</dd> |
||||||
|
{% endif %} |
||||||
|
{% endfor %} |
||||||
|
</dl> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<h4>{% blocktrans count context_processors|length as context_processors_count %}Context processor{% plural %}Context processors{% endblocktrans %}</h4> |
||||||
|
{% if context_processors %} |
||||||
|
<dl> |
||||||
|
{% for key, value in context_processors.items %} |
||||||
|
<dt><strong>{{ key|escape }}</strong></dt> |
||||||
|
<dd> |
||||||
|
<div class="djTemplateShowContextDiv"><a class="djTemplateShowContext"><span class="toggleArrow">▶</span> {% trans "Toggle context" %}</a></div> |
||||||
|
<div class="djTemplateHideContextDiv" style="display:none;"><code>{{ value|escape }}</code></div> |
||||||
|
</dd> |
||||||
|
{% endfor %} |
||||||
|
</dl> |
||||||
|
{% else %} |
||||||
|
<p>{% trans "None" %}</p> |
||||||
|
{% endif %} |
||||||
|
|
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.template.js' %}"></script> |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
{% load i18n %}{% load static from staticfiles %} |
||||||
|
<h4>{% trans "Resource usage" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col/> |
||||||
|
</colgroup> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Resource" %}</th> |
||||||
|
<th>{% trans "Value" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for key, value in rows %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ key|escape }}</td> |
||||||
|
<td>{{ value|escape }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
|
||||||
|
<!-- This hidden div is populated and displayed by code in toolbar.timer.js --> |
||||||
|
<div id="djDebugBrowserTiming" style="display:none"> |
||||||
|
<h4>{% trans "Browser timing" %}</h4> |
||||||
|
<table> |
||||||
|
<colgroup> |
||||||
|
<col style="width:20%"/> |
||||||
|
<col style="width:60%"/> |
||||||
|
<col style="width:20%"/> |
||||||
|
</colgroup> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Timing attribute" %}</th> |
||||||
|
<th class="timeline">{% trans "Timeline" %}</th> |
||||||
|
<th class="djdt-time">{% trans "Milliseconds since navigation start (+length)" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody id="djDebugBrowserTimingTableBody"> |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
|
</div> |
||||||
|
<script src="{% static 'debug_toolbar/js/toolbar.timer.js' %}"></script> |
||||||
@ -0,0 +1,17 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<table> |
||||||
|
<thead> |
||||||
|
<tr> |
||||||
|
<th>{% trans "Name" %}</th> |
||||||
|
<th>{% trans "Version" %}</th> |
||||||
|
</tr> |
||||||
|
</thead> |
||||||
|
<tbody> |
||||||
|
{% for package, version in versions.items %} |
||||||
|
<tr class="{% cycle 'djDebugOdd' 'djDebugEven' %}"> |
||||||
|
<td>{{ package }}</td> |
||||||
|
<td>{{ version }}</td> |
||||||
|
</tr> |
||||||
|
{% endfor %} |
||||||
|
</tbody> |
||||||
|
</table> |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
{% load i18n %} |
||||||
|
<!DOCTYPE html> |
||||||
|
<html> |
||||||
|
<head> |
||||||
|
</head> |
||||||
|
<body> |
||||||
|
<h1>{{ status_line }}</h1> |
||||||
|
<h2>{% trans "Location:" %} <a id="redirect_to" href="{{ redirect_to }}">{{ redirect_to }}</a></h2> |
||||||
|
<p class="notice"> |
||||||
|
{% trans "The Django Debug Toolbar has intercepted a redirect to the above URL for debug viewing purposes. You can click the above link to continue with the redirect as normal." %} |
||||||
|
</p> |
||||||
|
<script type="text/javascript"> |
||||||
|
document.getElementById('redirect_to').focus(); |
||||||
|
</script> |
||||||
|
</body> |
||||||
|
</html> |
||||||
@ -1 +1,2 @@ |
|||||||
Activate your {{ site }} account - you have {{ expiration_days }} days! |
{% load i18n %} |
||||||
|
{% trans 'Активируйте ваш' %} {{ site }} {% trans 'акаунт - вы имеете' %} {{ expiration_days }} {% trans 'дня' %} |
||||||
|
|||||||
@ -0,0 +1,52 @@ |
|||||||
|
from django.core.management.base import BaseCommand |
||||||
|
from theme.models import Tag, Theme |
||||||
|
|
||||||
|
import MySQLdb |
||||||
|
from MySQLdb.cursors import DictCursor |
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
def handle(self, *args, **options): |
||||||
|
db = MySQLdb.connect(host="localhost", |
||||||
|
user="expomap", |
||||||
|
passwd="7FbLtAGjse", |
||||||
|
db="old_db", |
||||||
|
charset='utf8', |
||||||
|
cursorclass=DictCursor) |
||||||
|
|
||||||
|
cursor = db.cursor() |
||||||
|
# id 3732 duplicate tag with bad name(2 spaces) |
||||||
|
sql_tag = "SELECT id, title, url FROM tags WHERE id != 3732" |
||||||
|
|
||||||
|
sql_theme = "SELECT categories_id as id, url FROM categories_description;" |
||||||
|
|
||||||
|
cursor.execute(sql_theme) |
||||||
|
res = cursor.fetchall() |
||||||
|
""" |
||||||
|
# themes |
||||||
|
for item in res: |
||||||
|
id = item['id'] |
||||||
|
old_url = item['url'] |
||||||
|
theme = Theme.objects.get(id=id) |
||||||
|
theme.old_url = old_url |
||||||
|
theme.save() |
||||||
|
print(theme) |
||||||
|
""" |
||||||
|
|
||||||
|
# tags |
||||||
|
cursor.execute(sql_tag) |
||||||
|
res = cursor.fetchall() |
||||||
|
updated_tags = [] |
||||||
|
for item in res: |
||||||
|
id = item['id'] |
||||||
|
old_url = item['url'] |
||||||
|
title = item['title'] |
||||||
|
#print(id) |
||||||
|
print(title.encode('utf8')) |
||||||
|
try: |
||||||
|
tag = Tag.objects.get(id=id, translations__name=title, translations__language_code='ru') |
||||||
|
tag.old_url = old_url |
||||||
|
updated_tags.append(id) |
||||||
|
tag.save() |
||||||
|
except Tag.DoesNotExist: |
||||||
|
Tag.objects.exclude(id__in=updated_tags).filter(translations__name=title).update(old_url=old_url) |
||||||
|
print(len(updated_tags)) |
||||||
Loading…
Reference in new issue