This reverts commitremotes/origin/1203cbf649ebe3, reversing changes made to7011f2a2fb.
parent
cbf649ebe3
commit
e4de1447b2
37 changed files with 211 additions and 745 deletions
@ -1,59 +0,0 @@ |
|||||||
# -*- 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 |
|
||||||
from accounts.models import User |
|
||||||
|
|
||||||
|
|
||||||
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 news_id as id , |
|
||||||
headline as main_title, |
|
||||||
content as description, |
|
||||||
cid as author, |
|
||||||
date_added as created |
|
||||||
|
|
||||||
FROM `latest_news`""" |
|
||||||
|
|
||||||
cursor.execute(sql) |
|
||||||
|
|
||||||
result = cursor.fetchall() |
|
||||||
user = User.objects.get(id=1) |
|
||||||
|
|
||||||
c = 0 |
|
||||||
for a in result: |
|
||||||
if len(a['main_title'])>255 or not a['main_title']: |
|
||||||
continue |
|
||||||
article = Article(type=Article.news, |
|
||||||
id=a['id'], |
|
||||||
created=a['created']) |
|
||||||
if a['author']: |
|
||||||
try: |
|
||||||
author = User.objects.get(id=a['author']) |
|
||||||
except User.DoesNotExist: |
|
||||||
author = user |
|
||||||
else: |
|
||||||
author = user |
|
||||||
|
|
||||||
article.author = author |
|
||||||
|
|
||||||
article.translate('ru') |
|
||||||
article.main_title = a['main_title'] |
|
||||||
article.description = a['description'] |
|
||||||
article.save() |
|
||||||
print(article) |
|
||||||
|
|
||||||
|
|
||||||
#print(a['main_title']) |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1,74 +0,0 @@ |
|||||||
# -*- coding: utf-8 -*- |
|
||||||
import xlrd |
|
||||||
import urllib2 |
|
||||||
from django.core.management.base import BaseCommand |
|
||||||
from django.conf import settings |
|
||||||
from functions.form_check import translit_with_separator |
|
||||||
from functions.files import get_alternative_filename |
|
||||||
from exposition.models import Exposition, Statistic |
|
||||||
from organiser.models import Organiser |
|
||||||
|
|
||||||
|
|
||||||
CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx' |
|
||||||
GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx' |
|
||||||
# 391 row not imported(same url) |
|
||||||
ITALY_FILE = settings.MEDIA_ROOT+'/import/expo_italy_ru.xlsx' |
|
||||||
# moscow 3 exps |
|
||||||
F = settings.MEDIA_ROOT+'/import/exp.xlsx' |
|
||||||
|
|
||||||
LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.xlsx' |
|
||||||
NA_EU_ASIA_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls' |
|
||||||
NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' |
|
||||||
|
|
||||||
# 44 |
|
||||||
class Command(BaseCommand): |
|
||||||
def handle(self, *args, **options): |
|
||||||
qs = Statistic.objects.language('ru').exclude(translations__countries='') |
|
||||||
comas = 0 |
|
||||||
enters = 0 |
|
||||||
main = 0 |
|
||||||
spaces = 0 |
|
||||||
word = 0 |
|
||||||
number = 0 |
|
||||||
for i in qs: |
|
||||||
if ';' in i.countries: |
|
||||||
main +=1 |
|
||||||
a = i.countries.split(';') |
|
||||||
new = [item.strip() for item in a] |
|
||||||
|
|
||||||
st = ';'.join(new) |
|
||||||
print st.encode('utf8') |
|
||||||
i.countries = st |
|
||||||
#i.save() |
|
||||||
elif ',' in i.countries: |
|
||||||
comas += 1 |
|
||||||
|
|
||||||
|
|
||||||
elif '\n' in i.countries: |
|
||||||
enters += 1 |
|
||||||
elif ' ' in i.countries: |
|
||||||
spaces += 1 |
|
||||||
if '55' in i.countries: |
|
||||||
continue |
|
||||||
|
|
||||||
|
|
||||||
elif '.' in i.countries: |
|
||||||
number += 1 |
|
||||||
#a = i.countries.split('.') |
|
||||||
#i.countries_number = int(a[0]) |
|
||||||
#i.countries = '' |
|
||||||
#i.save() |
|
||||||
|
|
||||||
else: |
|
||||||
word += 1 |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print('all: %d'%qs.count()) |
|
||||||
print('main: %d'%main) |
|
||||||
print('comas: %d'%comas) |
|
||||||
print('enter: %d'%enters) |
|
||||||
print('spaces: %d'%spaces) |
|
||||||
print('word: %d'%word) |
|
||||||
print('number: %d'%number) |
|
||||||
|
|
||||||
@ -1,65 +0,0 @@ |
|||||||
# -*- coding: utf-8 -*- |
|
||||||
import xlrd |
|
||||||
import urllib2 |
|
||||||
from django.core.management.base import BaseCommand |
|
||||||
from django.conf import settings |
|
||||||
from functions.form_check import translit_with_separator |
|
||||||
from functions.files import get_alternative_filename |
|
||||||
from exposition.models import Exposition, Statistic |
|
||||||
from organiser.models import Organiser |
|
||||||
|
|
||||||
|
|
||||||
CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx' |
|
||||||
GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx' |
|
||||||
# 391 row not imported(same url) |
|
||||||
ITALY_FILE = settings.MEDIA_ROOT+'/import/expo_italy_ru.xlsx' |
|
||||||
# moscow 3 exps |
|
||||||
F = settings.MEDIA_ROOT+'/import/exp.xlsx' |
|
||||||
|
|
||||||
LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.xlsx' |
|
||||||
NA_EU_ASIA_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls' |
|
||||||
NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' |
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand): |
|
||||||
def handle(self, *args, **options): |
|
||||||
|
|
||||||
f = open(NA_EU_ASIA_FILE, 'r') |
|
||||||
book = xlrd.open_workbook(file_contents=f.read()) |
|
||||||
sheet = book.sheet_by_index(0) |
|
||||||
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)] |
|
||||||
labels = [label for label in row_list[0]] |
|
||||||
|
|
||||||
for row_number, row in enumerate(row_list[1:]): |
|
||||||
exp_url = translit_with_separator(row[2]) |
|
||||||
try: |
|
||||||
exp = Exposition.objects.language('ru').get(url=exp_url) |
|
||||||
except Exposition.DoesNotExist: |
|
||||||
continue |
|
||||||
if not row[30]: |
|
||||||
continue |
|
||||||
|
|
||||||
year = int(row[30]) |
|
||||||
try: |
|
||||||
countries_number = int(exp.stat_countries) |
|
||||||
countries = '' |
|
||||||
except ValueError: |
|
||||||
countries_number = None |
|
||||||
countries = exp.stat_countries |
|
||||||
|
|
||||||
members = exp.members |
|
||||||
visitors = exp.visitors |
|
||||||
area = exp.area |
|
||||||
|
|
||||||
|
|
||||||
s = Statistic(exposition=exp, |
|
||||||
year=year, |
|
||||||
countries_number=countries_number, |
|
||||||
members=members, |
|
||||||
visitors=visitors, |
|
||||||
area=area) |
|
||||||
s.translate('ru') |
|
||||||
s.countries = countries |
|
||||||
s.save() |
|
||||||
|
|
||||||
print(exp) |
|
||||||
@ -1,19 +1,10 @@ |
|||||||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||||||
from django.conf.urls import patterns, include, url |
from django.conf.urls import patterns, include, url |
||||||
from views import ServiceView, CallBackListView, VisitListView, TranslationListView, AdvertisingListView, \ |
from views import ServiceView |
||||||
ParticipationListView, RemoteListView,TicketsListView |
|
||||||
|
|
||||||
urlpatterns = patterns('', |
urlpatterns = patterns('', |
||||||
url(r'service/order/callback/$', CallBackListView.as_view()), |
|
||||||
url(r'service/order/visit/$', VisitListView.as_view()), |
|
||||||
url(r'service/order/translation/$', TranslationListView.as_view()), |
|
||||||
url(r'service/order/advertising/$', AdvertisingListView.as_view()), |
|
||||||
url(r'service/order/participation/$', ParticipationListView.as_view()), |
|
||||||
url(r'service/order/remote/$', RemoteListView.as_view()), |
|
||||||
url(r'service/order/tickets/$', TicketsListView.as_view()), |
|
||||||
url(r'service/advertise/$', 'service.views.advertise'), |
url(r'service/advertise/$', 'service.views.advertise'), |
||||||
url(r'service/(?P<url>.*)/$', ServiceView.as_view()), |
url(r'service/(?P<url>.*)/$', ServiceView.as_view()), |
||||||
|
|
||||||
|
|
||||||
) |
) |
||||||
|
|
||||||
|
|||||||
@ -1,58 +0,0 @@ |
|||||||
<div class="modal hide fade bs-example-modal-lg" id="stat_modal" > |
|
||||||
<div class="modal-header"> |
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true" id="close_stat">×</button> |
|
||||||
<h3>Добавить год</h3> |
|
||||||
</div> |
|
||||||
<form method="post" class="form-horizontal" id="stat_form" enctype="multipart/form-data" action="#"> {% csrf_token %} |
|
||||||
|
|
||||||
<div class="modal-body"> |
|
||||||
|
|
||||||
<div class="control-group{% if form.year.errors %}error{% endif %}"> |
|
||||||
<label class="control-label">{{ form.year.label }}:</label> |
|
||||||
<div class="controls">{{ form.year }} |
|
||||||
<span class="help-inline">{{ form.year.errors }}</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
<div class="control-group{% if form.members.errors %}error{% endif %}"> |
|
||||||
<label class="control-label">{{ form.members.label }}:</label> |
|
||||||
<div class="controls">{{ form.members }} |
|
||||||
<span class="help-inline">{{ form.members.errors }}</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="control-group{% if form.visitors.errors %}error{% endif %}"> |
|
||||||
<label class="control-label">{{ form.visitors.label }}:</label> |
|
||||||
<div class="controls">{{ form.visitors }} |
|
||||||
<span class="help-inline">{{ form.visitors.errors }}</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="control-group{% if form.area.errors %}error{% endif %}"> |
|
||||||
<label class="control-label">{{ form.area.label }}:</label> |
|
||||||
<div class="controls">{{ form.area }} |
|
||||||
<span class="help-inline">{{ form.area.errors }}</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="control-group{% if form.countries_number.errors %}error{% endif %}"> |
|
||||||
<label class="control-label">{{ form.countries_number.label }}:</label> |
|
||||||
<div class="controls">{{ form.countries_number }} |
|
||||||
<span class="help-inline">{{ form.countries_number.errors }}</span> |
|
||||||
</div> |
|
||||||
</div> |
|
||||||
|
|
||||||
{% include 'admin/forms/multilang.html' with field='countries' form=form languages=languages %} |
|
||||||
|
|
||||||
</div> |
|
||||||
|
|
||||||
<div class="modal-footer"> |
|
||||||
<div class="controls"> |
|
||||||
<input class="btn btn-primary" type="submit" value="Добавить"> |
|
||||||
<input type="reset" class="btn" value="Отменить" data-dismiss="modal"> |
|
||||||
|
|
||||||
</div> |
|
||||||
</div> |
|
||||||
</form> |
|
||||||
|
|
||||||
|
|
||||||
</div> |
|
||||||
@ -1,37 +0,0 @@ |
|||||||
{% extends 'base.html' %} |
|
||||||
|
|
||||||
{% block body %} |
|
||||||
|
|
||||||
<div class="box span8"> |
|
||||||
<div class="box-header well"> |
|
||||||
<h2><i class="icon-arrow-down"></i>Список заказов</h2> |
|
||||||
</div> |
|
||||||
<div class="box-content"> |
|
||||||
<table class="table table-hover"> |
|
||||||
<thead> |
|
||||||
<tr> |
|
||||||
<th>id</th> |
|
||||||
<th>Контактное лицо</th> |
|
||||||
<th>Телефон</th> |
|
||||||
<th>Время создания</th> |
|
||||||
</tr> |
|
||||||
</thead> |
|
||||||
<tbody> |
|
||||||
{% for item in object_list %} |
|
||||||
<tr> |
|
||||||
<td>{{ item.id }}</td> |
|
||||||
<td>{{ item.person_inf }}</td> |
|
||||||
<td>{{ item.phone }}</td> |
|
||||||
<td>{{ item.created }}</td> |
|
||||||
</tr> |
|
||||||
{% endfor %} |
|
||||||
</tbody> |
|
||||||
</table> |
|
||||||
</div> |
|
||||||
|
|
||||||
{% include 'admin/includes/admin_pagination.html' with page_obj=page_obj %} |
|
||||||
</div> |
|
||||||
{# pagination #} |
|
||||||
|
|
||||||
|
|
||||||
{% endblock %} |
|
||||||
Loading…
Reference in new issue