Merge branch 'develop' of gitlab.com:OldminTeam/expomap into develop

remotes/origin/HEAD
Slava Kyrachevsky 9 years ago
commit a1c0ee9ef1
  1. 2
      apps/accounts/urls.py
  2. 7
      apps/accounts/views.py
  3. 126
      static/custom_js/main.js
  4. 102
      static/custom_js/select_tag.js
  5. 59
      static/mailing_settings/css/main.css
  6. 16
      static/mailing_settings/js/main.js
  7. 192
      templates/c_admin/article/blog_form.html
  8. 30
      templates/client/newsletters/mailing_settings.html

@ -42,7 +42,7 @@ urlpatterns = patterns('',
url(r'^profile/change-password/', 'accounts.views.change_password'), url(r'^profile/change-password/', 'accounts.views.change_password'),
url( url(
r'^profile/subscribe-themes-tags/$', r'^profile/subscribe-themes-tags/$',
login_required(UserSubscribeThemesTagsView.as_view()), UserSubscribeThemesTagsView.as_view(),
name='user_subscribe_themes_tags' name='user_subscribe_themes_tags'
), ),

@ -543,11 +543,14 @@ class UserSubscribeThemesTagsView(GetUserMixin, TemplateView):
ctx = super(UserSubscribeThemesTagsView, self).get_context_data(**kwargs) ctx = super(UserSubscribeThemesTagsView, self).get_context_data(**kwargs)
data = [] data = []
instance = self.get_user() instance = self.get_user()
user_themes = []
user_tags = []
themes = Theme.objects.language().values('pk', 'name') themes = Theme.objects.language().values('pk', 'name')
user_themes = instance.themes.values_list('pk', flat=True) if instance is not None:
user_tags = instance.tags.values_list('pk', flat=True) user_themes = instance.themes.values_list('pk', flat=True)
user_tags = instance.tags.values_list('pk', flat=True)
for theme in themes: for theme in themes:
tags = [] tags = []

@ -325,13 +325,12 @@ $(document).ready(function(){
} }
if( $("#id_tag" ).length && $("#id_tag").is('select')) { try{
$('#id_tag').select2({ $('#id_tag').select2({
placeholder: "Теги", placeholder: "Теги",
width: '550px', width: '550px',
multiple: true, multiple: true,
ajax: { ajax: {
url: "/admin/theme/tag/search/", url: "/admin/theme/tag/search/",
dataType: "json", dataType: "json",
quietMillis: 200, quietMillis: 200,
@ -339,9 +338,11 @@ $(document).ready(function(){
data: function(term, page, theme){ data: function(term, page, theme){
var theme = $('#id_theme').serialize(); var theme = $('#id_theme').serialize();
return {term: term, return {
page: page, term: term,
theme: theme}; page: page,
theme: theme
};
}, },
results: function (data) { results: function (data) {
@ -365,10 +366,12 @@ $(document).ready(function(){
}); });
}); });
callback(data); callback(data);
} }
}); });
} catch (e) {
console.log('===== Error =====');
console.warn(e);
console.log('=================')
} }
@ -377,52 +380,55 @@ $(document).ready(function(){
*/ */
// theme change // theme change
$('#id_theme').change(function(){ $('#id_theme').change(function(){
$.get( $.get("/admin/ajax_tag/", {'id': $(this).serialize()}, function(data){
"/admin/ajax_tag/", {'id': $(this).serialize()}, function(data){ var optionValues = [];
var optionValues = []; var getValues = [];
var getValues = []; var selectedValues = [];
var selectedValues = []
//push values sended from server in array //push values sended from server in array
$.each(data, function(i, elem){ $.each(data, function(i, elem){
getValues.push(elem[0].toString()) getValues.push(elem[0].toString())
}); });
//delete options if they aren't in getvalues
//otherwise push it in array //delete options if they aren't in getvalues
//also push in array already selected values //otherwise push it in array
$('#id_tag option').each(function() { //also push in array already selected values
var check = $.inArray($(this), getValues); $('#id_tag option').each(function() {
if ($(this).is(':selected') ){ var check = $.inArray($(this), getValues);
selectedValues.push($(this).val()) if ($(this).is(':selected') ){
} selectedValues.push($(this).val())
if (check == -1){ }
$(this).remove() if (check == -1){
} $(this).remove()
else{ }
optionValues.push($(this).val()); else{
} optionValues.push($(this).val());
}); }
//generate new options });
//old options unchanged
var html = '' //generate new options
$.each(data, function(i, elem){ //old options unchanged
var check = $.inArray(elem[0].toString(), optionValues); var html = ''
$.each(data, function(i, elem){
if (check == -1){ var check = $.inArray(elem[0].toString(), optionValues);
html += '<option value="';
html += elem[0]; if (check == -1){
html += '">'; html += '<option value="';
html += elem[1]; html += elem[0];
html += '</option>'; html += '">';
} html += elem[1];
}); html += '</option>';
$('#id_tag').append(html); }
//select previous selected values });
$('#id_tag option').each(function() {
var check = $.inArray($(this).val(), selectedValues) $('#id_tag').append(html);
if (check != -1){ //select previous selected values
$(this).attr('selected', 'selected'); $('#id_tag option').each(function() {
} var check = $.inArray($(this).val(), selectedValues)
}); if (check != -1){
$(this).attr('selected', 'selected');
}
});
});//end get });//end get
});//end change });//end change
@ -499,7 +505,11 @@ $(document).ready(function(){
allowClear: true allowClear: true
}); });
} catch (e){} } catch (e){
console.log('===== Error =====');
console.warn(e);
console.log('=================');
}
} }

@ -1,52 +1,56 @@
// replace // replace
$(document).ready(function(){ $(document).ready(function(){
$('#id_theme').change(function(){ $('#id_theme').change(function(){
$.get( $.get("/admin/ajax_tag/", {'id': $(this).serialize()}, function(data){
"/admin/ajax_tag/", {'id': $(this).serialize()}, function(data){ var optionValues = [];
var optionValues = []; var getValues = [];
var getValues = []; var selectedValues = [];
var selectedValues = []
//push values sended from server in array
$.each(data, function(i, elem){
getValues.push(elem[0].toString())
});
//delete options if they aren't in getvalues
//otherwise push it in array
//also push in array already selected values
$('#id_tag option').each(function() {
var check = $.inArray($(this), getValues);
if ($(this).is(':selected') ){
selectedValues.push($(this).val())
}
if (check == -1){
$(this).remove()
}
else{
optionValues.push($(this).val());
}
});
//generate new options
//old options unchanged
var html = ''
$.each(data, function(i, elem){
var check = $.inArray(elem[0].toString(), optionValues);
if (check == -1){ //push values sended from server in array
html += '<option value="'; $.each(data, function(i, elem){
html += elem[0]; getValues.push(elem[0].toString())
html += '">'; });
html += elem[1];
html += '</option>'; //delete options if they aren't in getvalues
} //otherwise push it in array
}); //also push in array already selected values
$('#id_tag').append(html); $('#id_tag option').each(function() {
//select previous selected values var check = $.inArray($(this), getValues);
$('#id_tag option').each(function() { if ($(this).is(':selected') ){
var check = $.inArray($(this).val(), selectedValues) selectedValues.push($(this).val())
if (check != -1){ }
$(this).attr('selected', 'selected'); if (check == -1){
} $(this).remove()
}); }
});//end get else{
});//end change optionValues.push($(this).val());
});//end ready }
});
//generate new options
//old options unchanged
var html = '';
$.each(data, function(i, elem){
var check = $.inArray(elem[0].toString(), optionValues);
if (check == -1){
html += '<option value="';
html += elem[0];
html += '">';
html += elem[1];
html += '</option>';
}
});
$('#id_tag').append(html);
//select previous selected values
$('#id_tag option').each(function() {
var check = $.inArray($(this).val(), selectedValues)
if (check != -1){
$(this).attr('selected', 'selected');
}
});
});//end get
});//end change
});//end ready

@ -842,44 +842,57 @@ a.themes_trigger{
} }
.pr-form .pr-row{ .pr-form .pr-row{
overflow:hidden; /*overflow:hidden;*/
margin:0 0 14px; margin:0 0 14px;
} }
.pr-form .pr-row:after{
content: '';
display: block;
clear: both;
}
.pr-input{ .pr-input{
float:left; display: inline-block;
height:46px; vertical-align: bottom;
width:247px;
padding:0 44px 0 18px;
margin:0 0 0 13px; margin:0 0 0 13px;
background:#fff; }
border-radius:4px;
position:relative; .errorlist{
list-style: none;
}
.text_error{
display: block;
text-align: center;
font-weight: 300;
font-size: 14px;
color: #bd2626;
padding-bottom: 3px;
}
.pr-input.field_error input{
box-shadow: 0 0 0 2px #f00;
} }
.pr-input:first-child{ .pr-input:first-child{
margin:0; margin:0;
} }
.pr-input:after{ .pr-input.pr-name input{
content:''; background:#fff url(../images/pr-icon02.png) no-repeat 210px 50%;
position:absolute;
top:13px;
right:14px;
width:20px;
height:20px;
}
.pr-input.pr-name:after{
background:url(../images/pr-icon02.png) no-repeat 50% 50%;
} }
.pr-input.pr-email:after{ .pr-input.pr-email input{
background:url(../images/pr-icon03.png) no-repeat 50% 50%; background:#fff url(../images/pr-icon03.png) no-repeat 210px 50%;
} }
.pr-form input{ .pr-form input {
padding:0; padding:0;
border:none; border:none;
color:#000; color:#000;
font:17px/21px 'pf_dindisplay_promedium', Arial, Helvetica, sans-serif; font:17px/21px 'pf_dindisplay_promedium', Arial, Helvetica, sans-serif;
height:24px; height:46px;
margin:12px 0 0; width:247px;
padding:0 44px 0 18px;
background:#fff;
border-radius:4px;
position:relative;
} }
.pr-form input:focus::-webkit-input-placeholder { .pr-form input:focus::-webkit-input-placeholder {
color:transparent; color:transparent;

@ -2,12 +2,24 @@
function sendForm () { function sendForm () {
var $form = $('#mailing_settings_form'); var $form = $('#mailing_settings_form');
$form.find('.field_error').removeClass('field_error');
$form.find('.text_error').remove();
$.ajax({ $.ajax({
url: $form.attr('action'), url: $form.attr('action'),
type: $form.attr('method'), type: $form.attr('method'),
data: $form.serializeArray(), data: $form.serializeArray(),
success: function(response){ // success: function(response){
console.log(response); // console.log(response);
// },
error: function (error) {
var form_errors = error.responseJSON.form_errors;
$.each(form_errors, function (field, err) {
var $field = $form.find('#id_' + field);
$field.addClass('field_error');
$field.parent('.pr-input').prepend('<span class="text_error">' + err + '</span>');
})
} }
}); });
} }

@ -15,17 +15,17 @@
<link href="{% static 'js/datetimepicker/css/datetimepicker.css' %}" rel="stylesheet"/> <link href="{% static 'js/datetimepicker/css/datetimepicker.css' %}" rel="stylesheet"/>
<script src="{% static 'js/datetimepicker/js/bootstrap-datetimepicker.js' %}"></script> <script src="{% static 'js/datetimepicker/js/bootstrap-datetimepicker.js' %}"></script>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('#id_publish_date').datetimepicker({ $('#id_publish_date').datetimepicker({
todayHighlight: true, todayHighlight: true,
format : 'yyyy-mm-dd', format : 'yyyy-mm-dd',
minView:2 minView:2
}); });
}); });
</script>
</script>
<link rel="stylesheet" href="{% static 'jQuery-filer/css/jquery.filer.css' %}"> <link rel="stylesheet" href="{% static 'jQuery-filer/css/jquery.filer.css' %}">
<link rel="stylesheet" href="{% static 'jQuery-filer/css/jquery.filer-dragdropbox-theme.css' %}"> <link rel="stylesheet" href="{% static 'jQuery-filer/css/jquery.filer-dragdropbox-theme.css' %}">
<script src="{% static 'jQuery-filer/js/jquery.filer.js' %}"></script> <script src="{% static 'jQuery-filer/js/jquery.filer.js' %}"></script>
@ -43,6 +43,7 @@
<div class="box-header well"> <div class="box-header well">
<h2><i class="icon-pencil"></i> {% trans "Основная информация" %}</h2> <h2><i class="icon-pencil"></i> {% trans "Основная информация" %}</h2>
</div> </div>
<div class="box-content"> <div class="box-content">
{# main_title #} {# main_title #}
@ -50,35 +51,38 @@
<div class="control-group {% if form.publish_date.errors %}error{% endif %}"> <div class="control-group {% if form.publish_date.errors %}error{% endif %}">
<label class="control-label"><b>{{ form.publish_date.label }}:</b></label> <label class="control-label"><b>{{ form.publish_date.label }}:</b></label>
<div class="controls"> <div class="controls">
{{ form.publish_date }} {{ form.publish_date }}
<span class="help-inline">{{ form.publish_date.errors }}</span> <span class="help-inline">{{ form.publish_date.errors }}</span>
</div> </div>
</div> </div>
{% if not article %} {% if not article %}
<div class="control-group {% if form.slug.errors %}error{% endif %}"> <div class="control-group {% if form.slug.errors %}error{% endif %}">
<label class="control-label">{{ form.slug.label }}:</label> <label class="control-label">{{ form.slug.label }}:</label>
<div class="controls"> <div class="controls">
{{ form.slug }} {{ form.slug }}
<span class="help-inline">{{ form.slug.errors }}</span> <span class="help-inline">{{ form.slug.errors }}</span>
</div> </div>
</div> </div>
{% endif %} {% endif %}
{# theme #} {# theme #}
<div class="control-group {% if form.theme.errors %}error{% endif %}"> <div class="control-group {% if form.theme.errors %}error{% endif %}">
<label class="control-label"><b>{{ form.theme.label }}:</b></label> <label class="control-label"><b>{{ form.theme.label }}:</b></label>
<div class="controls"> <div class="controls">
{{ form.theme }} {{ form.theme }}
<span class="help-inline">{{ form.theme.errors }}</span> <span class="help-inline">{{ form.theme.errors }}</span>
</div> </div>
</div> </div>
{# tag #} {# tag #}
<div class="control-group {% if form.tag.errors %}error{% endif %}"> <div class="control-group {% if form.tag.errors %}error{% endif %}">
<label class="control-label">{{ form.tag.label }}:</label> <label class="control-label">{{ form.tag.label }}:</label>
<div class="controls"> <div class="controls">
{{ form.tag }} {{ form.tag }}
<span class="help-inline">{{ form.tag.errors }}</span> <span class="help-inline">{{ form.tag.errors }}</span>
</div> </div>
</div> </div>
{# exposition #} {# exposition #}
{% if form.exposition %} {% if form.exposition %}
@ -160,78 +164,78 @@
{% block bot_scripts %} {% block bot_scripts %}
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$('#id_exposition').select2({ $('#id_exposition').select2({
placeholder: "Выставка", placeholder: "Выставка",
multiple: false, multiple: false,
width: 'element', width: 'element',
ajax: { ajax: {
url: "/admin/exposition/search/", url: "/admin/exposition/search/",
width: '550px', width: '550px',
dataType: "json", dataType: "json",
quietMillis: 200, quietMillis: 200,
data: function(term, page, theme){ data: function(term, page, theme){
return {term: term, return {term: term,
page: page}; page: page};
}, },
results: function (data) { results: function (data) {
var results = []; var results = [];
$.each(data, function(index, item){ $.each(data, function(index, item){
results.push({ results.push({
id: item.id, id: item.id,
text: item.label text: item.label
}); });
}); });
return {results: results}; return {results: results};
} }
}, },
initSelection : function(element, callback) { initSelection : function(element, callback) {
var id= $(element).val(); var id= $(element).val();
var text = $(element).attr('data-init-text'); var text = $(element).attr('data-init-text');
callback({id: id, text:text}); callback({id: id, text:text});
} }
}); });
$('#id_conference').select2({ $('#id_conference').select2({
placeholder: "Конференция", placeholder: "Конференция",
multiple: false, multiple: false,
width: 'element', width: 'element',
ajax: { ajax: {
url: "/admin/conference/search/", url: "/admin/conference/search/",
width: '550px', width: '550px',
dataType: "json", dataType: "json",
quietMillis: 200, quietMillis: 200,
data: function(term, page, theme){ data: function(term, page, theme){
return {term: term, return {term: term,
page: page}; page: page};
}, },
results: function (data) { results: function (data) {
var results = []; var results = [];
$.each(data, function(index, item){ $.each(data, function(index, item){
results.push({ results.push({
id: item.id, id: item.id,
text: item.label text: item.label
}); });
}); });
return {results: results}; return {results: results};
} }
}, },
initSelection : function(element, callback) { initSelection : function(element, callback) {
var id= $(element).val(); var id= $(element).val();
var text = $(element).attr('data-init-text'); var text = $(element).attr('data-init-text');
callback({id: id, text:text}); callback({id: id, text:text});
} }
}); });
}); });
</script> </script>
{% endblock %} {% endblock %}

@ -60,8 +60,15 @@
<div class="pr-form"> <div class="pr-form">
<fieldset> <fieldset>
<div class="pr-row"> <div class="pr-row">
<span class="pr-input pr-name">{{ form.first_name }}</span> <span class="pr-input pr-name {% if form.first_name.errors %}field_error{% endif %}">
<span class="pr-input pr-email" >{{ form.email }}</span> {% if form.first_name.errors %}<span class="text_error">{{ form.first_name.errors }}</span>{% endif %}
{{ form.first_name }}
</span>
<span class="pr-input pr-email {% if form.email.errors %}field_error{% endif %}">
{% if form.email.errors %}<span class="text_error">{{ form.email.errors }}</span>{% endif %}
{{ form.email }}
</span>
</div> </div>
<button>{% trans 'Подписаться' %}</button> <button>{% trans 'Подписаться' %}</button>
</fieldset> </fieldset>
@ -195,11 +202,20 @@
</div> </div>
<div class="button_block"> <div class="button_block">
<div class="container"> <div class="container">
<div class="tos"> {% if not user.is_authenticated %}
<strong>{% trans 'Нажимая «Подписаться», вы соглашаетесь получать' %} <br /> {% trans 'материалы компании Expomap на свой электронный адрес' %} </strong> <div class="tos">
<a href="{% url 'termsofuse' %}" style="color:#a2a2a2;">{% trans "Пользовательское соглашение" %}</a> <strong>{% trans 'Нажимая «Подписаться», вы соглашаетесь получать' %} <br /> {% trans 'материалы компании Expomap на свой электронный адрес' %} </strong>
</div> <a href="{% url 'termsofuse' %}" style="color:#a2a2a2;">{% trans "Пользовательское соглашение" %}</a>
<button type="submit">{% trans "Сохранить" %}</button> </div>
{% endif %}
<button type="submit">
{% if user.is_authenticated %}
{% trans "Сохранить" %}
{% else %}
{% trans 'Подписаться' %}
{% endif %}
</button>
<a href="?unsibscribe=1">{% trans 'Не хочу быть в курсе событий (отписаться от всего)' %}</a> <a href="?unsibscribe=1">{% trans 'Не хочу быть в курсе событий (отписаться от всего)' %}</a>
</div> </div>
</div> </div>

Loading…
Cancel
Save