Merge branch 'develop' of git.general-servers.com:expomap/expomap into develop

remotes/origin/1203
pavel 11 years ago
commit f0158d8bb7
  1. 8
      article/forms.py
  2. 17
      article/management/commands/news_from_old.py
  3. 45
      article/management/commands/news_generate_file.py
  4. 9
      article/models.py
  5. 25
      article/views.py
  6. 22
      city/management/commands/city_slug.py
  7. 5
      exposition/management/commands/expo_organiser.py
  8. 5
      exposition/management/commands/expo_test.py
  9. 19
      exposition/management/commands/exposition_load.py
  10. 7
      exposition/management/commands/imp_stat.py
  11. 15
      import_xls/utils.py
  12. 13
      templates/client/article/article.html
  13. 68
      templates/client/article/blog_list.html
  14. 29
      templates/client/article/news.html
  15. 65
      templates/client/article/news_list.html
  16. 2
      templates/client/includes/place/place_object.html
  17. 2
      theme/forms.py
  18. 1
      translator/management/__init__.py
  19. 1
      translator/management/commands/__init__.py
  20. 186
      translator/management/commands/translator_from_crm.py

@ -4,6 +4,7 @@ from django.conf import settings
from ckeditor.widgets import CKEditorWidget from ckeditor.widgets import CKEditorWidget
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.forms.util import ErrorList from django.forms.util import ErrorList
from django.utils.translation import ugettext as _
#functions #functions
from functions.translate import fill_with_signal from functions.translate import fill_with_signal
from functions.files import check_tmp_files from functions.files import check_tmp_files
@ -226,4 +227,9 @@ class BlogForm(forms.ModelForm):
widget=forms.TextInput(attrs={'style':'width: 550px'})) widget=forms.TextInput(attrs={'style':'width: 550px'}))
self.fields['descriptions_%s' % code] = forms.CharField(label='Кейвордс', required=False, max_length=255, self.fields['descriptions_%s' % code] = forms.CharField(label='Кейвордс', required=False, max_length=255,
widget=forms.TextInput(attrs={'style':'width: 550px'})) widget=forms.TextInput(attrs={'style':'width: 550px'}))
""" """
class ArticleFilterForm(forms.Form):
theme = forms.MultipleChoiceField(label=_(u'Тематика:'), required=False,
choices=[(item.id, item.name) for item in Theme.objects.language().all()])
tag = forms.CharField(label=_(u'Теги:'), widget=forms.HiddenInput(), required=False)

@ -5,7 +5,7 @@ from django.core.management.base import BaseCommand, CommandError
from functions.translate import fill_with_signal from functions.translate import fill_with_signal
from article.models import Article from article.models import Article
from accounts.models import User from accounts.models import User
from django.db import IntegrityError
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
@ -22,14 +22,15 @@ class Command(BaseCommand):
cid as author, cid as author,
date_added as created date_added as created
FROM `latest_news`""" FROM `latest_news` order by created DESC"""
cursor.execute(sql) cursor.execute(sql)
result = cursor.fetchall() result = cursor.fetchall()
user = User.objects.get(id=1) user = User.objects.get(id=1)
c = 0 Article.objects.news().delete()
for a in result: for a in result:
if len(a['main_title'])>255 or not a['main_title']: if len(a['main_title'])>255 or not a['main_title']:
continue continue
@ -49,11 +50,13 @@ class Command(BaseCommand):
article.translate('ru') article.translate('ru')
article.main_title = a['main_title'] article.main_title = a['main_title']
article.description = a['description'] article.description = a['description']
article.save() try:
print(article) article.save()
print(article)
except :
print ('error. id:%d'%a['id'])
#print(a['main_title'])
#print(a['main_title'])

@ -0,0 +1,45 @@
# -*- 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
from django.db import IntegrityError
import xlwt
from django.utils import translation
from django.conf import settings
class Command(BaseCommand):
def handle(self, *args, **options):
translation.activate('en')
workbook = xlwt.Workbook(encoding = 'utf8')
worksheet = workbook.add_sheet('My Worksheet')
font = xlwt.Font()
font.name = 'Times New Roman'
font.bold = True
style = xlwt.XFStyle()
# Create the Style
style.font = font
qs = Article.objects.news()
worksheet.write(0, 0, 'id')
worksheet.write(0, 1, 'url')
worksheet.write(0, 2, 'title')
row = 1
for a in qs:
print a.id
url = a.slug
id = a.id
name = a.main_title
worksheet.write(row, 0, id)
worksheet.write(row, 1, url)
worksheet.write(row, 2, name)
row += 1
workbook.save(settings.MEDIA_ROOT+'/import/exported_news.xls')

@ -8,6 +8,7 @@ from django.utils.html import strip_tags
from sorl.thumbnail import ImageField from sorl.thumbnail import ImageField
from functions.url_utils import slugify, unique_slug from functions.url_utils import slugify, unique_slug
from functions.model_utils import base_concrete_model from functions.model_utils import base_concrete_model
from functions.form_check import translit_with_separator
class ArticleManager(TranslationManager): class ArticleManager(TranslationManager):
@ -73,10 +74,10 @@ class Article(TranslatableModel):
gen_description = models.BooleanField(_("Generate description"), gen_description = models.BooleanField(_("Generate description"),
help_text=_("If checked, the description will be automatically " help_text=_("If checked, the description will be automatically "
"generated from content. Uncheck if you want to manually " "generated from content. Uncheck if you want to manually "
"set a custom description."), default=True) "set a custom description."), default=False)
# published = models. # published = models.
created = models.DateTimeField(auto_now_add=True) created = models.DateTimeField()
modified = models.DateTimeField(auto_now=True) modified = models.DateTimeField(auto_now=True)
#translated fields #translated fields
@ -140,7 +141,9 @@ class Article(TranslatableModel):
# slug lookup. # slug lookup.
concrete_model = base_concrete_model(Article, self) concrete_model = base_concrete_model(Article, self)
slug_qs = concrete_model.objects.exclude(id=self.id) slug_qs = concrete_model.objects.exclude(id=self.id)
return unique_slug(slug_qs, "slug", self.get_slug()) slug = unique_slug(slug_qs, "slug", self.get_slug())
slug = translit_with_separator(slug)
return slug
def get_slug(self): def get_slug(self):
""" """

@ -1,6 +1,9 @@
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
from django.http import HttpResponse from django.http import HttpResponse
from models import Article from models import Article
from forms import ArticleFilterForm
class NewsList(ListView): class NewsList(ListView):
model = Article model = Article
@ -22,6 +25,18 @@ class NewsList(ListView):
else: else:
return self.model.objects.news() return self.model.objects.news()
def get_context_data(self, **kwargs):
context = super(NewsList, self).get_context_data(object_list=self.object_list)
if self.request.GET:
filter_form = ArticleFilterForm(self.request.GET)
else:
filter_form = ArticleFilterForm()
context['article_filter_form'] = filter_form
return context
class NewsDetail(DetailView): class NewsDetail(DetailView):
model = Article model = Article
slug_field = 'slug' slug_field = 'slug'
@ -49,6 +64,16 @@ class BlogList(ListView):
else: else:
return self.model.objects.blogs() return self.model.objects.blogs()
def get_context_data(self, **kwargs):
context = super(BlogList, self).get_context_data(object_list=self.object_list)
if self.request.GET:
filter_form = ArticleFilterForm(self.request.GET)
else:
filter_form = ArticleFilterForm()
context['article_filter_form'] = filter_form
return context
class BlogDetail(DetailView): class BlogDetail(DetailView):

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from city.models import City
from country.models import Country
from functions.form_check import translit_with_separator
from django.db import IntegrityError
class Command(BaseCommand):
def handle(self, *args, **options):
qs = City.objects.language('en').filter()
for c in qs:
url = translit_with_separator(c.name.encode('utf8'))
c.url = url
try:
c.save()
except IntegrityError:
continue
print(c.url)
#print(qs.count())

@ -17,12 +17,13 @@ F = settings.MEDIA_ROOT+'/import/exp.xlsx'
LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.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_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls'
NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls'
RUSSIA_FILE = settings.MEDIA_ROOT+'/import/expo_russia.xls'
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
f = open(GERMANY_FILE, 'r') f = open(RUSSIA_FILE, 'r')
book = xlrd.open_workbook(file_contents=f.read()) book = xlrd.open_workbook(file_contents=f.read())
sheet = book.sheet_by_index(0) sheet = book.sheet_by_index(0)
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)] row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
@ -48,6 +49,8 @@ class Command(BaseCommand):
organiser.translate('ru') organiser.translate('ru')
organiser.name = org organiser.name = org
organiser.save() organiser.save()
except Organiser.MultipleObjectsReturned:
continue
if not exp.organiser.filter(url=organiser.url).exists(): if not exp.organiser.filter(url=organiser.url).exists():

@ -37,7 +37,7 @@ class Command(BaseCommand):
new = [item.strip() for item in a] new = [item.strip() for item in a]
st = ';'.join(new) st = ';'.join(new)
print st.encode('utf8') #print st.encode('utf8')
i.countries = st i.countries = st
#i.save() #i.save()
elif ',' in i.countries: elif ',' in i.countries:
@ -48,12 +48,14 @@ class Command(BaseCommand):
enters += 1 enters += 1
elif ' ' in i.countries: elif ' ' in i.countries:
spaces += 1 spaces += 1
print(i.countries.encode('utf8'))
if '55' in i.countries: if '55' in i.countries:
continue continue
elif '.' in i.countries: elif '.' in i.countries:
number += 1 number += 1
#print(i.countries)
#a = i.countries.split('.') #a = i.countries.split('.')
#i.countries_number = int(a[0]) #i.countries_number = int(a[0])
#i.countries = '' #i.countries = ''
@ -61,6 +63,7 @@ class Command(BaseCommand):
else: else:
word += 1 word += 1
#print(i.countries.encode('utf8'))

@ -4,6 +4,7 @@ from django.core.management.base import BaseCommand
from django.conf import settings from django.conf import settings
from exposition.models import Exposition from exposition.models import Exposition
from import_xls.excel_settings import event_sett from import_xls.excel_settings import event_sett
from django.db import IntegrityError
CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx' CHINA_FILE = settings.MEDIA_ROOT+'/import/expo_china_ru.xlsx'
GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx' GERMANY_FILE = settings.MEDIA_ROOT+'/import/expo_germany_ru.xlsx'
@ -15,31 +16,35 @@ F = settings.MEDIA_ROOT+'/import/exp.xlsx'
LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.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_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls'
NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls'
RUSSIA_FILE = settings.MEDIA_ROOT+'/import/expo_russia.xls'
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
f = open(NA_EU_ASIA_FILE2, 'r') f = open(RUSSIA_FILE, 'r')
book = xlrd.open_workbook(file_contents=f.read()) book = xlrd.open_workbook(file_contents=f.read())
sheet = book.sheet_by_index(0) sheet = book.sheet_by_index(0)
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)] row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
labels = [label for label in row_list[0]] labels = [label for label in row_list[0]]
existing = 0
for row_number, row in enumerate(row_list[1:]): for row_number, row in enumerate(row_list[1246:]):
#print(row_number) #print(row_number)
if row[0] != '': if row[0] != '':
# in first column ids # in first column ids
try: try:
object = Exposition.objects.language('ru').get(id=int(row[0])) object = Exposition.objects.language('ru').get(id=int(row[0]))
existing += 1
except ValueError: except ValueError:
object = Exposition() object = Exposition()
object.translate('ru') object.translate('ru')
except Exposition.DoesNotExist: except Exposition.DoesNotExist:
object = Exposition(id= int(row[0])) object = Exposition(id= int(row[0]))
object.translate('ru') object.translate('ru')
existing += 1
else: else:
# if id blank - its a new place # if id blank - its a new place
object = Exposition() object = Exposition()
@ -78,11 +83,15 @@ class Command(BaseCommand):
pass pass
else: else:
setattr(object, field_name, value) setattr(object, field_name, value)
try:
object.save() object.save()
except IntegrityError:
continue
print('post save %s'% str(object)) print('post save %s'% str(object))
for method in methods: for method in methods:
func = method['func'] func = method['func']
if method.get('purpose'): if method.get('purpose'):

@ -19,12 +19,13 @@ F = settings.MEDIA_ROOT+'/import/exp.xlsx'
LA_FILE = settings.MEDIA_ROOT+'/import/expo_la.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_FILE = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa.xls'
NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls' NA_EU_ASIA_FILE2 = settings.MEDIA_ROOT+'/import/expo_na_eu_ sa_part2.xls'
RUSSIA_FILE = settings.MEDIA_ROOT+'/import/expo_russia.xls'
class Command(BaseCommand): class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
f = open(NA_EU_ASIA_FILE, 'r') f = open(RUSSIA_FILE, 'r')
book = xlrd.open_workbook(file_contents=f.read()) book = xlrd.open_workbook(file_contents=f.read())
sheet = book.sheet_by_index(0) sheet = book.sheet_by_index(0)
row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)] row_list = [sheet.row_values(row_number) for row_number in range(sheet.nrows)]
@ -40,6 +41,8 @@ class Command(BaseCommand):
continue continue
year = int(row[30]) year = int(row[30])
try: try:
countries_number = int(exp.stat_countries) countries_number = int(exp.stat_countries)
countries = '' countries = ''
@ -62,4 +65,4 @@ class Command(BaseCommand):
s.countries = countries s.countries = countries
s.save() s.save()
print(exp) print(exp)

@ -53,7 +53,7 @@ def to_city(value, lang, country):
# except IndexError if no found # except IndexError if no found
city = City.objects.filter(translations__name=value, country=country)[0] city = City.objects.filter(translations__name=value, country=country)[0]
# print(city) # print(city)
return city return city.id
except IndexError: except IndexError:
print('---------city error------------') print('---------city error------------')
print(value.encode('utf8')) print(value.encode('utf8'))
@ -142,16 +142,23 @@ def save_logo(obj, path):
logo_path = obj.logo.field.upload_to logo_path = obj.logo.field.upload_to
full_path = settings.MEDIA_ROOT + logo_path full_path = settings.MEDIA_ROOT + logo_path
try:
alt_name = get_alternative_filename(full_path, file_name) alt_name = get_alternative_filename(full_path, file_name)
except UnicodeEncodeError:
return None
download_to = full_path+alt_name download_to = full_path+alt_name
if path.startswith('http://') or path.startswith('https://'): if path.startswith('http://') or path.startswith('https://'):
url = path url = path
else: elif path.startswith('/'):
url = 'http://expomap.ru' + path url = 'http://expomap.ru' + path
elif path.startswith('images'):
url = 'http://expomap.ru/' + path
else:
return None
try: try:
response = urllib2.urlopen(url, timeout=15) response = urllib2.urlopen(url, timeout=15)

@ -19,7 +19,7 @@
{% include 'includes/article/article_logo.html' with obj=object %} {% include 'includes/article/article_logo.html' with obj=object %}
<h1>{{ object.main_title }}</h1> <h1>{{ object.main_title }}</h1>
<strong><span>{{ object.created }}</span><a class="profile_link" href="{{ object.author.get_permanent_url }}" title="">{{ object.author.get_full_name }}</a></strong> <strong><span>{{ object.created|date:"d E Y" }}</span><a class="profile_link" href="{{ object.author.get_permanent_url }}" title="">{{ object.author.get_full_name }}</a></strong>
{{ object.description|safe }} {{ object.description|safe }}
<div class="blog_avtor"> <div class="blog_avtor">
@ -29,14 +29,17 @@
<td><a href="{{ object.author.get_permanent_url }}" title="">{% include 'includes/show_logo.html' with obj=object.author %}</a></td> <td><a href="{{ object.author.get_permanent_url }}" title="">{% include 'includes/show_logo.html' with obj=object.author %}</a></td>
<td> <td>
<h3><a href="{{ object.author.get_permanent_url }}" title="">{{ object.author.get_full_name }}</a></h3> <h3><a href="{{ object.author.get_permanent_url }}" title="">{{ object.author.get_full_name }}</a></h3>
<a href="#" title="" class="facebook">zherdneva</a> {% if object.author.profile.fb %}
<a href="{{ object.author.profile.fb }}" title="" class="facebook">{{ object.author.get_full_name }}</a>
{% endif %}
</td> </td>
</tr> </tr>
</table> </table>
{% if object.tag.all.exists %}
<div class="blog_avtor_right"> <div class="blog_avtor_right">
<img src="img/soc.png" class="soc_icons" alt="">
{% include 'includes/article_tags.html' with obj=object %} {% include 'includes/article_tags.html' with obj=object %}
</div> </div>
{% endif %}
<div class="clear"></div> <div class="clear"></div>
</div> </div>
@ -46,7 +49,7 @@
<div class="rq-to-hide"> <div class="rq-to-hide">
<div class="s-comments"> <div class="s-comments">
<div class="sect-title blog_link">{% trans 'Похожие статьи' %}<a class="button more" href="#">{% trans 'Все статьи' %}</a></div> <div class="sect-title blog_link">{% trans 'Похожие статьи' %}<a class="button more" href="/blogs/">{% trans 'Все статьи' %}</a></div>
<div class="cat-list sc-comments"> <div class="cat-list sc-comments">
{% for blog in object.similars %} {% for blog in object.similars %}
<div class="cl-item"> <div class="cl-item">
@ -54,7 +57,7 @@
<a href="{{ blog.get_permanent_url }}" title="">{% include 'includes/show_logo.html' with obj=blog %}</a> <a href="{{ blog.get_permanent_url }}" title="">{% include 'includes/show_logo.html' with obj=blog %}</a>
<h3><a href="{{ blog.get_permanent_url }}" title="">{{ blog.main_title }}</a></h3> <h3><a href="{{ blog.get_permanent_url }}" title="">{{ blog.main_title }}</a></h3>
<p>{{ blog.preview }}</p> <p>{{ blog.preview }}</p>
<strong><span>{{ blog.publish_date }}</span><a href="{{ blog.author.get_permanent_url }}" title=""><i>Евгения Булавина</i></a></strong> <strong><span>{{ blog.created|date:"d E Y" }}</span><a href="{{ blog.author.get_permanent_url }}" title=""><i>Евгения Булавина</i></a></strong>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

@ -21,77 +21,17 @@
<form action="#"> <form action="#">
<div class="adm-form-body"> <div class="adm-form-body">
<div class="mf-line mf-line1 s-subj-tag"> <div class="mf-line mf-line1 s-subj-tag">
<div class="mf-field"> <div class="mf-field">
<label>Тематика:</label> <label>{{ article_filter_form.theme.label }}</label>
<div class="c-select-box select" data-placeholder="Выберите тематику"> {{ article_filter_form.theme }}
<div class="csb-selected-items"></div>
<div class="csb-menu-wrap">
<div class="scroll-container csb-menu">
<div class="scroll-content clearfix">
<ul>
<li><label><input type="checkbox" name="subj" value="1" />Бизнес, инвестиции, финансы</label></li>
<li><label><input type="checkbox" name="subj" value="2" />Индустрия развлечений, шоу, СМИ</label></li>
<li><label><input type="checkbox" name="subj" value="3" />Косметика и парфюмерия</label></li>
<li><label><input type="checkbox" name="subj" value="4" />Маркетинг, реклама, PR</label></li>
<li><label><input type="checkbox" name="subj" value="5" />Мебель, интерьер, декор</label></li>
<li><label><input type="checkbox" name="subj" value="6" />Наука и инновации</label></li>
<li><label><input type="checkbox" name="subj" value="7" />Анализ, измерение и контроль</label></li>
<li><label><input type="checkbox" name="subj" value="8" />Здравоохранение</label></li>
<li><label><input type="checkbox" name="subj" value="9" />Культура, искусство, церковь</label></li>
<li><label><input type="checkbox" name="subj" value="10" />Менеджмент, HR</label></li>
<li><label><input type="checkbox" name="subj" value="11" />Транспорт, склад, логистика</label></li>
<li><label><input type="checkbox" name="subj" value="12" />Экология, очистка, утилизация</label></li>
<li><label><input type="checkbox" name="subj" value="13" />Безопасность</label></li>
<li><label><input type="checkbox" name="subj" value="14" />Городское хозяйство</label></li>
<li><label><input type="checkbox" name="subj" value="15" />Гостиничное, ресторанное дело</label></li>
<li><label><input type="checkbox" name="subj" value="16" />Нефть, газ, горное дело</label></li>
<li><label><input type="checkbox" name="subj" value="17" />Строительство</label></li>
<li><label><input type="checkbox" name="subj" value="18" />Телекоммуникации</label></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div>
<div class="mf-field"> <div class="mf-field">
<label>Теги:</label> <label>{{ article_filter_form.tag.label }}</label>
<div class="c-select-box select" data-placeholder="Выберете ключевые теги"> {{ article_filter_form.tag.label }}
<div class="csb-selected-items"></div>
<div class="csb-menu-wrap">
<div class="scroll-container csb-menu">
<div class="scroll-content clearfix">
<ul>
<li><label><input type="checkbox" name="subj" value="1" />Бизнес, инвестиции, финансы</label></li>
<li><label><input type="checkbox" name="subj" value="2" />Индустрия развлечений, шоу, СМИ</label></li>
<li><label><input type="checkbox" name="subj" value="3" />Косметика и парфюмерия</label></li>
<li><label><input type="checkbox" name="subj" value="4" />Маркетинг, реклама, PR</label></li>
<li><label><input type="checkbox" name="subj" value="5" />Мебель, интерьер, декор</label></li>
<li><label><input type="checkbox" name="subj" value="6" />Наука и инновации</label></li>
<li><label><input type="checkbox" name="subj" value="7" />Анализ, измерение и контроль</label></li>
<li><label><input type="checkbox" name="subj" value="8" />Здравоохранение</label></li>
<li><label><input type="checkbox" name="subj" value="9" />Культура, искусство, церковь</label></li>
<li><label><input type="checkbox" name="subj" value="10" />Менеджмент, HR</label></li>
<li><label><input type="checkbox" name="subj" value="11" />Транспорт, склад, логистика</label></li>
<li><label><input type="checkbox" name="subj" value="12" />Экология, очистка, утилизация</label></li>
<li><label><input type="checkbox" name="subj" value="13" />Безопасность</label></li>
<li><label><input type="checkbox" name="subj" value="14" />Городское хозяйство</label></li>
<li><label><input type="checkbox" name="subj" value="15" />Гостиничное, ресторанное дело</label></li>
<li><label><input type="checkbox" name="subj" value="16" />Нефть, газ, горное дело</label></li>
<li><label><input type="checkbox" name="subj" value="17" />Строительство</label></li>
<li><label><input type="checkbox" name="subj" value="18" />Телекоммуникации</label></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
</form> </form>
</div> </div>

@ -17,38 +17,35 @@
<div class="m-article cl-news blog_block"> <div class="m-article cl-news blog_block">
<div class="blog_block_headline"> <div class="blog_block_headline">
{% include 'includes/show_logo.html' with obj=object %}
{% include 'includes/article/article_logo.html' with obj=object %}
<h1>{{ object.main_title }}</h1> <h1>{{ object.main_title }}</h1>
<strong><span>{{ object.publish_date }}</span><a class="flag" href="{{ object.get_event.get_permanent_url }}" title="">{{ object.get_event.name }}</a></strong> <strong><span>{{ object.created|date:"d E Y" }}</span>{% if object.get_event %}<a class="flag" href="{{ object.get_event.get_permanent_url }}" title="">{{ object.get_event.name }}</a>{% endif %}</strong>
<p>Смартфоны, планшеты, программные решения и аксессуары заполнили каждый свободный метр экспоцентра Барселоны в надежде стать лидером продаж в своем сегменте. За день до официального старта восьмой выставки-конгресса Mobile World Congress глава GSMA Джон Хоффман торжественно отметил новую точку отсчета в богатой истории мероприятия: два монумента, которые появились у входа в экспоцентр, кажется, навсегда закрепили за Барселоной статус столицы мобильной индустрии. </p>
</div> </div>
{{ object.description }} {{ object.description|safe }}
<div class="blog_avtor"> <div class="blog_avtor">
<div class="blog_avtormidle"> <div class="blog_avtormidle">
<i>Источник: {{ object.author }}</i> <i>{% trans 'Источник' %}: {{ object.author }}</i>
{% include 'includes/article_tags.html' with obj=object %} {% if object.tag.all.exists %}
{% include 'includes/article_tags.html' with obj=object %}
{% endif %}
</div> </div>
</div> </div>
<div class="blog_avtor">
<img src="img/soc.png" class="soc_icons" alt="">
</div>
</div> </div>
<div class="rq-to-hide"> <div class="rq-to-hide">
<div class="s-comments"> <div class="s-comments">
<div class="sect-title blog_link">Похожие новости<a class="button more" href="#">Все новости</a></div> <div class="sect-title blog_link">{% trans 'Похожие новости' %}<a class="button more" href="/news/">{% trans 'Все новости' %}</a></div>
<div class="cat-list sc-comments"> <div class="cat-list sc-comments">
{% for news in object.similar %} {% for news in object.similar %}
<div class="cl-item"> <div class="cl-item">
<div class="acticle_list"> <div class="acticle_list">
<a href="#" title=""><img src="img/pic2.jpg" class="pic" alt=""></a> <a href="{{ news.get_permanent_url }}" title="">{% include 'includes/show_logo.html' with obj=news %}</a>
<h3><a href="#" title="">Самое интересное на Baby Active' 2014</a></h3> <h3><a href="{{ news.get_permanent_url }}" title="">{{ news.main_title }}</a></h3>
<p>С 16 по 18 мая в Выставочном центре «АККО Интернешнл», на территории парка им. А.С. Пушкина, состоится Выставка- <p>{{ news.preview }}</p>
фестиваль семейного досуга Baby Active' 2014 («Активный ребенок»). </p> <strong><span>{{ news.created|date:"d E Y" }}</span>{% if news.get_event %}<a href="{{ news.get_event.get_permanent_url }}" title=""><b>{{ news.get_event.name }}</b></a><{% endif %}/strong>
<strong><span>28 апреля 2014</span><a href="#" title=""><b>РИФ-2014</b></a></strong>
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

@ -23,71 +23,14 @@
<div class="mf-line mf-line1 s-subj-tag"> <div class="mf-line mf-line1 s-subj-tag">
<div class="mf-field"> <div class="mf-field">
<label>Тематика:</label> <label>{{ article_filter_form.theme.label }}</label>
<div class="c-select-box select" data-placeholder="Выберите тематику"> {{ article_filter_form.theme }}
<div class="csb-selected-items"></div>
<div class="csb-menu-wrap">
<div class="scroll-container csb-menu">
<div class="scroll-content clearfix">
<ul>
<li><label><input type="checkbox" name="subj" value="1" />Бизнес, инвестиции, финансы</label></li>
<li><label><input type="checkbox" name="subj" value="2" />Индустрия развлечений, шоу, СМИ</label></li>
<li><label><input type="checkbox" name="subj" value="3" />Косметика и парфюмерия</label></li>
<li><label><input type="checkbox" name="subj" value="4" />Маркетинг, реклама, PR</label></li>
<li><label><input type="checkbox" name="subj" value="5" />Мебель, интерьер, декор</label></li>
<li><label><input type="checkbox" name="subj" value="6" />Наука и инновации</label></li>
<li><label><input type="checkbox" name="subj" value="7" />Анализ, измерение и контроль</label></li>
<li><label><input type="checkbox" name="subj" value="8" />Здравоохранение</label></li>
<li><label><input type="checkbox" name="subj" value="9" />Культура, искусство, церковь</label></li>
<li><label><input type="checkbox" name="subj" value="10" />Менеджмент, HR</label></li>
<li><label><input type="checkbox" name="subj" value="11" />Транспорт, склад, логистика</label></li>
<li><label><input type="checkbox" name="subj" value="12" />Экология, очистка, утилизация</label></li>
<li><label><input type="checkbox" name="subj" value="13" />Безопасность</label></li>
<li><label><input type="checkbox" name="subj" value="14" />Городское хозяйство</label></li>
<li><label><input type="checkbox" name="subj" value="15" />Гостиничное, ресторанное дело</label></li>
<li><label><input type="checkbox" name="subj" value="16" />Нефть, газ, горное дело</label></li>
<li><label><input type="checkbox" name="subj" value="17" />Строительство</label></li>
<li><label><input type="checkbox" name="subj" value="18" />Телекоммуникации</label></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div>
<div class="mf-field"> <div class="mf-field">
<label>Теги:</label> <label>{{ article_filter_form.tag.label }}</label>
<div class="c-select-box select" data-placeholder="Выберете ключевые теги"> {{ article_filter_form.tag.label }}
<div class="csb-selected-items"></div>
<div class="csb-menu-wrap">
<div class="scroll-container csb-menu">
<div class="scroll-content clearfix">
<ul>
<li><label><input type="checkbox" name="subj" value="1" />Бизнес, инвестиции, финансы</label></li>
<li><label><input type="checkbox" name="subj" value="2" />Индустрия развлечений, шоу, СМИ</label></li>
<li><label><input type="checkbox" name="subj" value="3" />Косметика и парфюмерия</label></li>
<li><label><input type="checkbox" name="subj" value="4" />Маркетинг, реклама, PR</label></li>
<li><label><input type="checkbox" name="subj" value="5" />Мебель, интерьер, декор</label></li>
<li><label><input type="checkbox" name="subj" value="6" />Наука и инновации</label></li>
<li><label><input type="checkbox" name="subj" value="7" />Анализ, измерение и контроль</label></li>
<li><label><input type="checkbox" name="subj" value="8" />Здравоохранение</label></li>
<li><label><input type="checkbox" name="subj" value="9" />Культура, искусство, церковь</label></li>
<li><label><input type="checkbox" name="subj" value="10" />Менеджмент, HR</label></li>
<li><label><input type="checkbox" name="subj" value="11" />Транспорт, склад, логистика</label></li>
<li><label><input type="checkbox" name="subj" value="12" />Экология, очистка, утилизация</label></li>
<li><label><input type="checkbox" name="subj" value="13" />Безопасность</label></li>
<li><label><input type="checkbox" name="subj" value="14" />Городское хозяйство</label></li>
<li><label><input type="checkbox" name="subj" value="15" />Гостиничное, ресторанное дело</label></li>
<li><label><input type="checkbox" name="subj" value="16" />Нефть, газ, горное дело</label></li>
<li><label><input type="checkbox" name="subj" value="17" />Строительство</label></li>
<li><label><input type="checkbox" name="subj" value="18" />Телекоммуникации</label></li>
</ul>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>

@ -68,7 +68,7 @@
<li>{% trans 'Конгресс-центр' %}</li> <li>{% trans 'Конгресс-центр' %}</li>
{% endif %} {% endif %}
{% if place.business_centre %} {% if place.business_centre %}
<li>{% trans 'Бизнес центр' %}</li> <li>{% trans 'Бизнес-центр' %}</li>
{% endif %} {% endif %}
{% if place.online_registration %} {% if place.online_registration %}
<li>{% trans 'Онлайн-регистрация' %}</li> <li>{% trans 'Онлайн-регистрация' %}</li>

@ -53,7 +53,7 @@ class ThemeForm(forms.Form):
#generates bitfield #generates bitfield
flag = reduce(lambda x,y: x|y, (getattr(Theme.types, item) for item in data['types'])) flag = reduce(lambda x,y: x|y, (getattr(Theme.types, item) for item in data['types']))
theme.types = flag theme.types = flag
theme.save() #theme.save()
fill_with_signal(Theme, theme, data) fill_with_signal(Theme, theme, data)

@ -0,0 +1 @@
__author__ = 'root'

@ -0,0 +1,186 @@
# -*- coding: utf-8 -*-
import MySQLdb
import datetime
from MySQLdb.cursors import DictCursor
from django.core.management.base import BaseCommand, CommandError
from functions.translate import fill_with_signal
from translator.models import Translator
from accounts.models import User, Profile
from country.models import Country
from city.models import City
from functions.form_check import is_positive_integer
def to_phone(phone):
if not phone:
return None
deduct = ('-','(',')','.',' ', '+')
for elem in deduct:
phone = phone.replace(elem, '')
if phone.isdigit():
return int(phone)
else:
return None
def get_country_name(id):
db = MySQLdb.connect(host="localhost",
user="kotzilla",
passwd="qazedc",
db="crm",
charset='utf8',
cursorclass=DictCursor)
sql ="""
SELECT country_name as name
FROM `country`
WHERE `country_id` =%d"""%id
cursor = db.cursor()
cursor.execute(sql)
result = cursor.fetchone()
return result['name']
def get_city_name(id):
db = MySQLdb.connect(host="localhost",
user="kotzilla",
passwd="qazedc",
db="crm",
charset='utf8',
cursorclass=DictCursor)
sql ="""
SELECT city_name as name
FROM `city`
WHERE `city_id` =%d"""%id
cursor = db.cursor()
cursor.execute(sql)
result = cursor.fetchone()
return result['name']
class Command(BaseCommand):
def handle(self, *args, **options):
db = MySQLdb.connect(host="localhost",
user="kotzilla",
passwd="qazedc",
db="crm",
charset='utf8',
cursorclass=DictCursor)
cursor = db.cursor()
sql = """SELECT *
FROM `interpreter_table` """
cursor.execute(sql)
result = cursor.fetchall()
for data in result:
email = data['email']
print(email.encode('utf8'))
if email:
try:
user = User.objects.select_related('translator').get(username=email)
except User.DoesNotExist:
user = None
if user:
# add information to user
profile = user.profile
if data['phone1']:
phone = to_phone(data['phone1'])
if len(str(phone))<15:
profile.phone = phone
if data['skype']:
profile.skype = data['skype']
if data['country_id']:
name = get_country_name(data['country_id'])
country_qs = Country.objects.filter(translations__name=name)
if country_qs.exists():
country = country_qs[0]
else:
country = None
profile.country = country
if profile.country and data['city_id']:
name = get_city_name(data['city_id'])
city_qs = City.objects.filter(translations__name=name, country=profile.country)
if city_qs.exists():
city = city_qs[0]
else:
city = None
profile.city = city
profile.save()
else:
# create new user
user = User.objects.create_user(email, data['fam'], data['name'], data['pass'])
user.is_active = True
user.save()
profile = user.profile
#user.url = 'id%s'%str(self.id)
if data['phone1']:
phone = to_phone(data['phone1'])
if len(str(phone))<15:
profile.phone = phone
if data['skype']:
profile.skype = data['skype']
if data['country_id']:
name = get_country_name(data['country_id'])
country_qs = Country.objects.filter(translations__name=name)
if country_qs.exists():
country = country_qs[0]
else:
country = None
profile.country = country
if profile.country and data['city_id']:
name = get_city_name(data['city_id'])
city_qs = City.objects.filter(translations__name=name, country=profile.country)
if city_qs.exists():
city = city_qs[0]
else:
city = None
profile.city = city
profile.save()
user.save()
# fill translator
if user.translator:
translator_id = user.translator_id
translator = Translator.objects.language('ru').get(id=translator_id)
new = 0
else:
translator = Translator()
new = 1
gender = data['gender']
if gender == u'мужской':
gender = 'male'
elif gender == u'женский':
gender = 'female'
else:
gender = 'male'
translator.gender = gender
translator.birth = data['born']
if data['automobile'] == u'да':
translator.car = 1
if new:
translator.translate('ru')
translator.education = data['education']
translator.specialization = data['spec']
translator.languages = ', '.join([data['selfLang'], data['selfLang2']])
translator.save()
user.translator = translator
user.save()
Loading…
Cancel
Save