1626 in progress, 1581 правки от димона

remotes/origin/stage6
Alexander Burdeiny 9 years ago
parent b7c448a9a0
commit be6f78eb31
  1. 16
      emencia/django/newsletter/templates/newsletter/AutomaticEmail_web.html
  2. 1
      functions/custom_views.py
  3. 44
      functions/forms.py
  4. 30
      functions/utils.py
  5. 1
      proj/config.ini
  6. 16
      settings/admin.py
  7. 9
      settings/admin_urls.py
  8. 64
      settings/forms.py
  9. 23
      static/mailing_settings/js/main.js
  10. 3
      templates/c_admin/includes/admin_nav.html
  11. 119
      templates/c_admin/settings/default_description.html
  12. 2
      templates/c_admin/settings/sections.html
  13. 0
      templates/client/includes/conference/default_description_en.html
  14. 1
      templates/client/includes/conference/default_description_ru.html
  15. 1
      templates/client/includes/exposition/default_description_en.html
  16. 0
      templates/client/includes/exposition/default_description_ru.html
  17. 6
      templates/client/includes/services.html

@ -83,13 +83,13 @@
<table>
<tr>
<td>
<td valign="top" style="width: 225px;">
{% thumbnail obj.get_logo '281x225' as im %}
<img src="{{ im.url }}"/>
{% endthumbnail %}
</td>
<td valign="top" align="left" style="width: 50%; padding-left: 22px;">
<td valign="top" align="left" style="padding-left: 22px;">
<table style="wigth: 100%;">
<tr>
<td valign="middle" style="color: #cc3399; font-size: 13px; text-transform: uppercase; padding: 3px 0px 3px 0px;">
@ -152,7 +152,7 @@
{% with sqs_obj.object as obj %}
<table style="width: 100%; margin-top: 15px;">
<tr {% if not forloop.last %}style="border-bottom: 1px solid #eaeaea;"{% endif %}>
<td valign="top">
<td valign="top" style="width: 110px;">
{% thumbnail obj.get_logo '109x114' as im %}
<img style="border: 1px solid #eaeaea;" src="{{ im.url }}"/>
{% endthumbnail %}
@ -230,9 +230,9 @@
<td style="padding-left: 20px;">
<table style="width: 100%;">
<tr>
<td class="color1" style="font-size: 14px; padding-bottom: 5px;">
<td class="color{{ forloop.counter }}" style="font-size: 14px; padding-bottom: 5px;">
{% if obj.get_event_place_name %}
<img src="{% static 'newsletter/images/m1.png' %}" alt="" style="display: inline-block; vertical-align: middle; margin-right: 4px;">
<img src="/static/newsletter/images/m{{ forloop.counter }}.png" alt="" style="display: inline-block; vertical-align: middle; margin-right: 4px;">
{{ obj.get_event_place_name }}
{% endif %}
</td>
@ -292,7 +292,7 @@
<tr>
{% for sqs_obj in foreign %}
{% with sqs_obj.object as obj %}
<td>
<td valign="top">
<table style="width: 130px; margin: 0 auto;">
<tr>
<td style="padding-bottom: 15px;">
@ -302,9 +302,9 @@
</td>
</tr>
<tr>
<td class="color1" style="font-family: Arial, sans-serif; font-size: 13px; text-transform: uppercase; padding-bottom: 12px;">
<td class="color{{ forloop.counter }}" style="font-family: Arial, sans-serif; font-size: 13px; text-transform: uppercase; padding-bottom: 12px;">
{% if obj.get_event_place_name %}
<img src="{% static 'newsletter/images/m1.png' %}" alt="" style="display: inline-block; vertical-align: middle; margin-right: 4px;">
<img src="{{ STATIC_URL }}newsletter/images/m{{ forloop.counter }}.png" alt="" style="display: inline-block; vertical-align: middle; margin-right: 4px;">
{{ obj.get_event_place_name }}
{% endif %}
</td>

@ -36,6 +36,7 @@ from file.forms import FileModelForm
from file.models import TmpFile
from functions.forms import AdminSearchForm
from functions.views_help import split_params
from functions.http import JsonResponse
from haystack.query import EmptySearchQuerySet
from hvad.utils import get_translation_aware_manager
from meta.models import MetaSetting

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import force_text
from django.db.models import ObjectDoesNotExist
from django.forms.models import ModelChoiceIterator
@ -186,17 +187,42 @@ class FieldsetMixin(object):
}
class CustomModelChoiceIterator(ModelChoiceIterator):
def __init__(self, field):
self.field = field
self.queryset = getattr(field, 'c_queryset', field.queryset.none())
# class CustomModelChoiceIterator(ModelChoiceIterator):
# def __init__(self, field):
# self.field = field
# self.queryset = getattr(field, 'c_queryset', field.queryset.none())
class OrderedSelectMultiple(forms.SelectMultiple):
def render_options(self, choices, selected_choices):
self.choices.queryset = self.choices.queryset.filter(pk__in=selected_choices)
choices = dict(self.choices)
selected_choices_str = set(force_text(v) for v in selected_choices)
output = []
for choice in selected_choices:
label = choices.get(choice)
if label:
output.append(self.render_option(selected_choices_str, choice, label))
# unselected_choices = set(choices.iterkeys()).difference(selected_choices)
# if unselected_choices:
# for option_value, option_label in filter(lambda x: x[0] in unselected_choices, choices.iteritems()):
# if isinstance(option_label, (list, tuple)):
# output.append(format_html('<optgroup label="{0}">', force_text(option_value)))
# for option in option_label:
# output.append(self.render_option(selected_choices_str, *option))
# output.append('</optgroup>')
# else:
# output.append(self.render_option(selected_choices_str, option_value, option_label))
return '\n'.join(output)
class ML_ModelMultipleChoiceField(forms.ModelMultipleChoiceField):
def _get_choices(self):
if hasattr(self, '_choices'):
return self._choices
return CustomModelChoiceIterator(self)
choices = property(_get_choices, forms.ChoiceField._set_choices)
widget = OrderedSelectMultiple
# def _get_choices(self):
# if hasattr(self, '_choices'):
# return self._choices
# return CustomModelChoiceIterator(self)
# choices = property(_get_choices, forms.ChoiceField._set_choices)

@ -1,7 +1,9 @@
from string import Template
# -*- coding: utf-8 -*-
# from string import Template
import string
from datetime import timedelta, datetime
class DeltaTemplate(Template):
class DeltaTemplate(string.Template):
delimiter = "%"
@ -14,3 +16,25 @@ def strfdelta(tdelta, fmt):
d["S"] = '{:02d}'.format(seconds)
t = DeltaTemplate(fmt)
return t.substitute(**d)
class CachedSting(object):
def __init__(self, path, timeout=None):
super(CachedSting, self).__init__()
self.path = path
self.timeout = timeout or timedelta(days=1)
self.get_object()
def __repr__(self):
return self.__str__()
def __str__(self):
if self.timeto > datetime.now():
return self.object
self.get_object()
return self.object
def get_object(self):
self.timeto = datetime.now() + self.timeout
with open(self.path, 'r') as f:
self.object = f.read()

@ -3,3 +3,4 @@ expo_city = [-2960561, -2996338, -1044367, -1762397, -1746443, -1771148, -192446
conf_city = [-2960561, -2996338, -1044367]
expo_country = [159, 47, 40, 186, 31, 99, 87, 60]
conf_country = [159, 47, 187]

@ -9,7 +9,11 @@ from django.core.context_processors import csrf
from django.conf import settings
from functions.custom_views import ContextMixin
from forms import MainPageArticle, MainPageNews, MainPageThemes, EventSectionSettingsForm
from .forms import MainPageArticle
from .forms import MainPageNews
from .forms import MainPageThemes
from .forms import EventSectionSettingsForm
from .forms import EventDefaultDescriptionEditForm
def handle_form(request, form):
@ -81,3 +85,13 @@ class EventSectionSettings(ContextMixin, FormView):
def form_valid(self, form):
form.save()
return super(EventSectionSettings, self).form_valid(form)
class EventDefaultDescription(ContextMixin, FormView):
form_class = EventDefaultDescriptionEditForm
template_name = 'c_admin/settings/default_description.html'
success_url = reverse_lazy('settings_default_description')
def form_valid(self, form):
form.save()
return super(EventDefaultDescription, self).form_valid(form)

@ -1,6 +1,12 @@
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from .admin import handle_themes, handle_news, handle_articles, main_page, EventSectionSettings
from .admin import handle_themes
from .admin import handle_news
from .admin import handle_articles
from .admin import main_page
from .admin import EventSectionSettings
from .admin import EventDefaultDescription
urlpatterns = patterns('',
url(r'^main-page/themes/', handle_themes, name='settings_main_page_themes'),
@ -9,5 +15,6 @@ urlpatterns = patterns('',
url(r'^main-page/$', main_page, name='settings_main_page'),
url(r'^sections/$', EventSectionSettings.as_view(), name='settings_sections'),
url(r'^description/$', EventDefaultDescription.as_view(), name='settings_default_description'),
)

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import os
import json
from itertools import chain
@ -10,7 +11,7 @@ from django.core.exceptions import (
)
from django.db.models import Q
from django.utils.encoding import force_text
from django.utils.html import format_html
# from django.utils.html import format_html
from django.utils.translation import ugettext as _
from django.conf import settings
from django.core.urlresolvers import reverse, reverse_lazy
@ -53,28 +54,6 @@ class ParticipationCommentForm(CommentForm):
model = ParticipationComment
class OrderedSelectMultiple(forms.SelectMultiple):
def render_options(self, choices, selected_choices):
choices = dict(self.choices)
selected_choices_str = set(force_text(v) for v in selected_choices)
output = []
for choice in selected_choices:
label = choices.get(choice)
if label:
output.append(self.render_option(selected_choices_str, choice, label))
# unselected_choices = set(choices.iterkeys()).difference(selected_choices)
# if unselected_choices:
# for option_value, option_label in filter(lambda x: x[0] in unselected_choices, choices.iteritems()):
# if isinstance(option_label, (list, tuple)):
# output.append(format_html('<optgroup label="{0}">', force_text(option_value)))
# for option in option_label:
# output.append(self.render_option(selected_choices_str, *option))
# output.append('</optgroup>')
# else:
# output.append(self.render_option(selected_choices_str, option_value, option_label))
return '\n'.join(output)
class OredredMixin(object):
def clean(self, value):
if self.required and not value:
@ -107,7 +86,7 @@ class OrderedModelMultipleChoiceField(OredredMixin, forms.ModelMultipleChoiceFie
class OML_MMChoiceField(OredredMixin, ML_ModelMultipleChoiceField):
widget = OrderedSelectMultiple
pass
class MainPageThemes(forms.Form):
@ -159,6 +138,7 @@ class MainPageArticle(forms.Form):
class EventSectionSettingsForm(forms.Form):
verbose = _(u'Блок "самые популярные"')
expo_city = OML_MMChoiceField(label=_(u'Каталог городов (выставки)'),
queryset=City.objects.all(), required=False)
conf_city = OML_MMChoiceField(label=_(u'Каталог городов (конференции)'),
@ -176,9 +156,9 @@ class EventSectionSettingsForm(forms.Form):
'data-ajax-url': reverse('admin_{model}_search'.format(model=model)),
'select2': 'true',
})
if self.initial[name]:
field.c_queryset = field.queryset.filter(pk__in=self.initial[name])
field.widget.choices = field.choices
# if self.initial[name]:
# field.c_queryset = field.queryset.filter(pk__in=self.initial[name])
# field.widget.choices = field.choices
def save(self):
INI_CONFIG = settings.INI_CONFIG
@ -191,3 +171,33 @@ class EventSectionSettingsForm(forms.Form):
for lang_code, name in settings.LANGUAGES:
for key_attr in ['C_CITY_CATALOG_KEY', 'C_COUNTRY_CATALOG_KEY', 'E_CITY_CATALOG_KEY', 'E_COUNTRY_CATALOG_KEY']:
cache.delete(getattr(settings, key_attr) + '_' + lang_code)
class EventDefaultDescriptionEditForm(forms.Form):
data_mapping = {
'e_description_ru': 'templates/client/includes/conference/default_description_ru.html',
'e_description_en': 'templates/client/includes/conference/default_description_en.html',
'c_description_ru': 'templates/client/includes/exposition/default_description_ru.html',
'c_description_en': 'templates/client/includes/exposition/default_description_en.html',
}
e_description_ru = forms.CharField(label=_(u'Описание для выставки'), required=False, widget=CKEditorWidget)
e_description_en = forms.CharField(label=_(u'Описание для выставки'), required=False, widget=CKEditorWidget)
c_description_ru = forms.CharField(label=_(u'Описание для конференции'), required=False, widget=CKEditorWidget)
c_description_en = forms.CharField(label=_(u'Описание для конференции'), required=False, widget=CKEditorWidget)
def __init__(self, *args, **kwargs):
super(EventDefaultDescriptionEditForm, self).__init__(*args, **kwargs)
for field_name, path in self.data_mapping.iteritems():
try:
with open(os.path.join(settings.SITE_ROOT, path), 'r') as f:
self.initial[field_name] = f.read()
except:
pass
def save(self):
for field_name, path in self.data_mapping.iteritems():
try:
with open(os.path.join(settings.SITE_ROOT, path), 'w+') as f:
f.write(self.cleaned_data.get(field_name))
except:
pass

@ -1,5 +1,17 @@
'use strict';
function sendForm () {
var $form = $('#mailing_settings_form');
$.ajax({
url: $form.attr('action'),
type: $form.attr('method'),
data: $form.serializeArray(),
success: function(response){
console.log(response);
}
})
}
// Выбор тем
(function () {
var $themes_modal = $('.popup-window.themes'),
@ -124,6 +136,8 @@
}
$.fancybox.close();
sendForm();
});
@ -145,6 +159,7 @@
removeCheckbox($input.attr('name'), $input.val());
$(this).parent('li').remove();
sendForm();
});
@ -157,6 +172,7 @@
removeCheckbox($input.attr('name'), $input.val());
$(this).parent('li').remove();
sendForm();
});
})();
@ -211,6 +227,7 @@
}
$.fancybox.close();
sendForm();
});
@ -225,6 +242,7 @@
$('#id_' + $input.attr('name')).find('option[value="' + $input.val() + '"]').remove();
$(this).parent('li').remove();
sendForm();
});
})();
@ -303,8 +321,6 @@
$selected_co.append($co);
});
console.log(user_countries);
// открываем список тегов в теме
$countries_modal.on('click', '.trigger', function (e) {
e.preventDefault();
@ -359,6 +375,7 @@
}
$.fancybox.close();
sendForm();
});
// Удаление выбранного континента
@ -370,6 +387,7 @@
removeCheckbox($input.attr('name'), $input.val());
$(this).parent('li').remove();
sendForm();
});
@ -382,6 +400,7 @@
removeCheckbox($input.attr('name'), $input.val());
$(this).parent('li').remove();
sendForm();
});
})();

@ -46,7 +46,8 @@
<li><a href="/admin/service/all">Услуги</a></li>
<li><a href="{% url 'linked_service_all' %}">Управление услугами</a></li>
<li><a href="/admin/settings/main-page/">Главная страница</a></li>
<li><a href="{% url 'settings_sections' %}">Разделы событий</a></li>
<li><a href="{% url 'settings_sections' %}">{% trans 'Блок "Самые популярные" (каталог)' %}</a></li>
<li><a href="{% url 'settings_default_description' %}">{% trans 'Описание по умолчанию' %}</a></li>
<li><a href="/admin/meta/all/">Мета</a></li>
<li><a href="/admin/rosetta/">Перевод</a></li>

@ -0,0 +1,119 @@
{% extends 'base.html' %}
{% load i18n %}
{% load static %}
{% block scripts %}
<script src="{% static 'ckeditor/ckeditor/ckeditor.js' %}"></script>
{% endblock %}
{% block body %}
<form method="post" action="." class="form-horizontal">{% csrf_token %}
<div class="box span8">
<div class="box-header well" data-original-title>
<h2><i class="icon-tasks"></i>{{ form.verbose }}</h2>
</div>
<div class="box-content">
<div class="control-group" style="margin-bottom: 1px;" >
<div class="controls span3" id="m_e">
<ul class="nav nav-tabs" style="margin-bottom: -2px; margin-left: 10px;">
<li class="active">
<a href="#field_{{ form.e_description_ru.auto_id }}" data-toggle="tab">ru</a>
</li>
<li>
<a href="#field_{{ form.e_description_en.auto_id }}" data-toggle="tab">en</a>
</li>
</ul>
</div>
</div>
<div class="tab-content" >
{# expo ru #}
<div class="tab-pane active" id="field_{{ form.e_description_ru.auto_id }}">
<div class="control-group {% if form.e_description_ru.errors %}error{% endif %}" >
<label class="control-label">
{% if form.e_description_ru.required %}
<b>{{ form.e_description_ru.label }}</b>:
{% else %}
{{ form.e_description_ru.label }}:
{% endif %}
</label>
<div class="controls" style="border: 1px solid #ddd; padding: 10px; border-radius: 5px">
{{ form.e_description_ru }}
<span class="help-inline">{{ form.e_description_ru.errors }}</span>
</div>
</div>
</div>
{# expo en #}
<div class="tab-pane" id="field_{{ form.e_description_en.auto_id }}">
<div class="control-group {% if form.e_description_en.errors %}error{% endif %}" >
<label class="control-label">
{% if form.e_description_en.required %}
<b>{{ form.e_description_en.label }}</b>:
{% else %}
{{ form.e_description_en.label }}:
{% endif %}
</label>
<div class="controls" style="border: 1px solid #ddd; padding: 10px; border-radius: 5px">
{{ form.e_description_en }}
<span class="help-inline"> {{ form.e_description_en.errors }}</span></div>
</div>
</div>
</div>
<div class="control-group" style="margin-bottom: 1px;" >
<div class="controls span3" id="m_c">
<ul class="nav nav-tabs" style="margin-bottom: -2px; margin-left: 10px;">
<li class="active">
<a href="#field_{{ form.c_description_ru.auto_id }}" data-toggle="tab">ru</a>
</li>
<li>
<a href="#field_{{ form.c_description_en.auto_id }}" data-toggle="tab">en</a>
</li>
</ul>
</div>
</div>
<div class="tab-content" >
{# conf ru #}
<div class="tab-pane active" id="field_{{ form.c_description_ru.auto_id }}">
<div class="control-group {% if form.c_description_ru.errors %}error{% endif %}" >
<label class="control-label">
{% if form.c_description_ru.required %}
<b>{{ form.c_description_ru.label }}</b>:
{% else %}
{{ form.c_description_ru.label }}:
{% endif %}
</label>
<div class="controls" style="border: 1px solid #ddd; padding: 10px; border-radius: 5px">
{{ form.c_description_ru }}
<span class="help-inline">{{ form.c_description_ru.errors }}</span></div>
</div>
</div>
{# conf en #}
<div class="tab-pane" id="field_{{ form.c_description_en.auto_id }}">
<div class="control-group {% if form.c_description_en.errors %}error{% endif %}" >
<label class="control-label">
{% if form.c_description_en.required %}
<b>{{ form.c_description_en.label }}</b>:
{% else %}
{{ form.c_description_en.label }}:
{% endif %}
</label>
<div class="controls" style="border: 1px solid #ddd; padding: 10px; border-radius: 5px">
{{ form.c_description_en }}
<span class="help-inline"> {{ form.c_description_en.errors }}</span></div>
</div>
</div>
</div>
<hr/>
<button type="submit" class="btn btn-primary" >Сохранить</button>
</div>
</div>
</form>
{% endblock %}

@ -147,7 +147,7 @@
<div class="row-fluid sortable">
<div class="box span12">
<div class="box-header well" data-original-title>
<h2><i class="icon-tasks"></i></h2>
<h2><i class="icon-tasks"></i>{{ form.verbose }}</h2>
</div>
<div class="box-content">
<form method="post" action=".">

@ -3,10 +3,10 @@
<header>{% trans 'Наши услуги' %}</header>
<nav>
<ul>
<li><a href="/service/translator/">{% trans 'Переводчики' %}</a></li>
{% comment %}<li><a href="/service/tickets/">{% trans 'Билеты на выставки' %}</a></li>{% endcomment %}
<li><a href="/service/remote/">{% trans 'Заочное посещение' %}</a></li>
<li><a href="/service/participation/">{% trans 'Участие в выставках' %}</a></li>
<li><a href="/service/translator/">{% trans 'Переводчики' %}</a></li>
{% comment %}<li><a href="/service/tickets/">{% trans 'Билеты на выставки' %}</a></li>{% endcomment %}
<li><a href="/service/remote/">{% trans 'Заочное посещение' %}</a></li>
</ul>
</nav>
</div>

Loading…
Cancel
Save