parent
85326c7079
commit
531c85fe6f
15 changed files with 251 additions and 18 deletions
@ -0,0 +1 @@ |
||||
__author__ = 'root' |
||||
@ -0,0 +1 @@ |
||||
__author__ = 'root' |
||||
@ -0,0 +1,22 @@ |
||||
# -*- coding: utf-8 -*- |
||||
import MySQLdb |
||||
from MySQLdb.cursors import DictCursor |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
from functions.translate import fill_with_signal |
||||
from article.models import Article |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
db = MySQLdb.connect(host="localhost", |
||||
user="kotzilla", |
||||
passwd="qazedc", |
||||
db="old_expomap", |
||||
charset='utf8', |
||||
cursorclass=DictCursor) |
||||
cursor = db.cursor() |
||||
sql = """SELECT articles_description.articles_id as id , articles_description.articles_name as name, articles_description.articles_description as description, articles_description.articles_head_title_tag as title, articles_description.articles_head_desc_tag as descriptions, articles_description.articles_head_keywords_tag as keywords, articles_description.articles_intro as main_title, articles.articles_date_added as created, articles.articles_last_modified as modified |
||||
FROM `articles_description` |
||||
JOIN articles |
||||
ON articles_description.articles_id=articles.articles_id""" |
||||
|
||||
@ -0,0 +1,30 @@ |
||||
# -*- coding: utf-8 -*- |
||||
import MySQLdb |
||||
from MySQLdb.cursors import DictCursor |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
from django.utils import translation |
||||
from country.models import City |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
db = MySQLdb.connect(host="localhost", |
||||
user="kotzilla", |
||||
passwd="qazedc", |
||||
db="test2", |
||||
charset='utf8', |
||||
cursorclass=DictCursor) |
||||
cursor = db.cursor() |
||||
sql = """SELECT title, url, inflect |
||||
FROM old_expomap.products_places |
||||
WHERE parent_id > 0 """ |
||||
|
||||
|
||||
cursor.execute(sql) |
||||
result = cursor.fetchall() |
||||
for res in result: |
||||
name = res['title'] |
||||
url = res['url'] |
||||
inflect = res['inflect'] |
||||
City.objects.filter(translations__name=name).update(inflect=inflect, old_url=url) |
||||
print(name.encode('utf-8')) |
||||
@ -0,0 +1,39 @@ |
||||
# -*- coding: utf-8 -*- |
||||
import MySQLdb |
||||
from MySQLdb.cursors import DictCursor |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
from django.utils import translation |
||||
from country.models import Country |
||||
|
||||
|
||||
def get_from_old(country): |
||||
db = MySQLdb.connect(host="localhost", |
||||
user="kotzilla", |
||||
passwd="qazedc", |
||||
db="test2", |
||||
charset='utf8', |
||||
cursorclass=DictCursor) |
||||
cursor = db.cursor() |
||||
sql = """SELECT url, inflect FROM old_expomap.products_places WHERE title="%(name)s" """%{'name': country.name.encode('utf-8')} |
||||
#print(country.name.encode('utf-8')) |
||||
# print(sql) |
||||
cursor.execute(sql) |
||||
result = cursor.fetchone() |
||||
|
||||
return result |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
translation.activate('ru') |
||||
for country in Country.objects.all(): |
||||
old_data = get_from_old(country) |
||||
if old_data is None: |
||||
continue |
||||
country.old_url = old_data['url'] |
||||
country.inflect = old_data['inflect'] |
||||
try: |
||||
country.save() |
||||
print(country) |
||||
except: |
||||
continue |
||||
@ -0,0 +1,65 @@ |
||||
{% extends 'base_catalog.html' %} |
||||
{% load template_filters %} |
||||
{% load i18n %} |
||||
|
||||
{% block bread_scrumbs %} |
||||
<div class="bread-crumbs"> |
||||
<a href="/">{% trans 'Главная страница' %}</a> |
||||
<a href="{{ catalog_url }}">{% trans 'Выставки' %}</a> |
||||
{% if month %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/">{{ filter_object.name }}</a> |
||||
{% if country %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/country/{{ country.url }}">{{ country.name }}</a> |
||||
{% endif %} |
||||
{% if city %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/city/{{ city.url }}">{{ city.name }}</a> |
||||
{% endif %} |
||||
<a href="{{ year.link }}">{{ year.text }}</a> |
||||
<strong>{{ month.text }}</strong> |
||||
{% else %} |
||||
{% if year %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/">{{ filter_object.name }}</a> |
||||
{% if country %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/country/{{ country.url }}">{{ country.name }}</a> |
||||
{% endif %} |
||||
{% if city %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/city/{{ city.url }}">{{ city.name }}</a> |
||||
{% endif %} |
||||
<strong>{{ year.text }}</strong> |
||||
{% else %} |
||||
{% if country %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/">{{ filter_object.name }}</a> |
||||
<strong>{{ country.name }}</strong> |
||||
{% else %} |
||||
{% if city %} |
||||
<a href="{{ catalog_url }}{{ filter_object.url }}/">{{ filter_object.name }}</a> |
||||
<strong>{{ city.name }}</strong> |
||||
{% else %} |
||||
<strong>{{ filter_object.name }}</strong> |
||||
{% endif %} |
||||
|
||||
{% endif %} |
||||
|
||||
|
||||
{% endif %} |
||||
{% endif %} |
||||
</div> |
||||
{% endblock %} |
||||
|
||||
|
||||
{% block page_title %} |
||||
<div class="page-title"> |
||||
<h1>{% trans 'Выставки' %}: <strong>{{ filter_object.name }}</strong></h1> |
||||
</div> |
||||
|
||||
{% include 'includes/exposition/catalog_filter_period.html' %} |
||||
|
||||
{% endblock %} |
||||
|
||||
{% block content_list %} |
||||
{% include 'includes/exposition/exposition_list.html' with object_list=object_list %} |
||||
{% endblock %} |
||||
|
||||
{% block paginator %} |
||||
{% include 'includes/catalog_paginator.html' with page_obj=page_obj %} |
||||
{% endblock %} |
||||
Loading…
Reference in new issue