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

stage8
Slava 9 years ago
commit ed0ca7e52b
  1. 1
      .dockerignore
  2. 2
      Dockerfile
  3. 4
      apps/city/models.py
  4. 5
      apps/expobanner/views.py
  5. 2
      apps/place_exposition/models.py
  6. 2
      docker-compose.yml
  7. 21
      static/client/css/main.css
  8. 2
      static/client/css_min/main.min.css
  9. 6
      static/client/js/rejs/tops.js
  10. 102
      static/client/js/scripts.js
  11. 102
      static/client/js/vendor.js
  12. 16
      static/client/js_min/vendor.min.js
  13. 2
      templates/client/includes/booking_block.html

@ -1,3 +1,4 @@
data data
media media
collected_static collected_static
node_modules

@ -30,6 +30,8 @@ RUN apt-get update \
\ \
&& rm -rf /var/lib/apt/lists/* \ && rm -rf /var/lib/apt/lists/* \
\ \
&& npm install -g gulp \
\
&& npm install && npm install
RUN sed -i -e 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \ RUN sed -i -e 's/# ru_RU.UTF-8 UTF-8/ru_RU.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="ru_RU.UTF-8"'>/etc/default/locale && \ echo 'LANG="ru_RU.UTF-8"'>/etc/default/locale && \

@ -63,9 +63,9 @@ class City(TranslatableModel):
def get_hotels(self): def get_hotels(self):
""" """
returns list of 5 hotels in current city returns list of 4 hotels in current city
""" """
return list(self.hotels.all()[:5]) return list(self.hotels.all()[:4])
def get_events(self): def get_events(self):
""" """

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import json import json
import re import re
from datetime import date
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import redirect, get_object_or_404, render from django.shortcuts import redirect, get_object_or_404, render
@ -100,8 +101,8 @@ def get_top(request):
'catalog': catalog, 'catalog': catalog,
'month': request.GET.get('month')} 'month': request.GET.get('month')}
tops = Top.cached.all() tops = Top.cached.filter(fr__lte=date.today(), to__gte=date.today()).order_by('?')
events = get_top_events(tops, params, request) events = get_top_events(tops, params, request)[:3]
ctx = {'objects': events} ctx = {'objects': events}
if not events: if not events:

@ -206,7 +206,7 @@ class PlaceExposition(TranslatableModel, ExpoMixin):
# coordinate current place # coordinate current place
place_coord = (float(self.address['lat']), float(self.address['lng'])) place_coord = (float(self.address['lat']), float(self.address['lng']))
# 4 coordinates of 4 nearest hotels # 4 coordinates of 4 nearest hotels
hotels_coord = sorted(hotels_coord, key=partial(dist, place_coord))[:5] hotels_coord = sorted(hotels_coord, key=partial(dist, place_coord))[:4]
# start generating filter for queryset # start generating filter for queryset
qs = [Q(latitude=item[0]) & Q(longitude=item[1]) for item in hotels_coord] qs = [Q(latitude=item[0]) & Q(longitude=item[1]) for item in hotels_coord]
res = reduce(lambda a,b: a|b, qs) res = reduce(lambda a,b: a|b, qs)

@ -34,7 +34,7 @@ services:
- MYSQL_ROOT_PASSWORD=root - MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=expomap - MYSQL_DATABASE=expomap
ports: ports:
- "3306:3306" - "3305:3306"
volumes: volumes:
- ./data/mysql/db:/var/lib/mysql - ./data/mysql/db:/var/lib/mysql

@ -5934,6 +5934,18 @@ dl.add-info dd ul li {
.h-booking a.more { .h-booking a.more {
font-size: 11px font-size: 11px
} }
.h-booking ul.flexing_for_one_row {
display: -webkit-box;
display: -webkit-flex;
display: -moz-box;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: space-around;
-ms-flex-pack: distribute;
justify-content: space-around;
}
.h-booking ul { .h-booking ul {
margin: 0; margin: 0;
padding: 0 0 0 4px; padding: 0 0 0 4px;
@ -14798,9 +14810,10 @@ h1 .preview_toggle:hover{
float: none; float: none;
} }
.exposition_booking_block .h-booking ul li:last-child { /*Hotels: 4 items for row*/
margin-right: 0; /*.exposition_booking_block .h-booking ul li:last-child {*/
} /*margin-right: 0;*/
/*}*/
.exposition_booking_block .h-booking .sect-title a { .exposition_booking_block .h-booking .sect-title a {
color: #40bbea; color: #40bbea;
@ -14853,4 +14866,4 @@ h1 .preview_toggle:hover{
.exposition_nearest .sect-title { .exposition_nearest .sect-title {
font-size: 23px; font-size: 23px;
font-weight: 500; font-weight: 500;
} }

File diff suppressed because one or more lines are too long

@ -79,9 +79,9 @@
if (parent) { if (parent) {
parent.innerHTML = text; parent.innerHTML = text;
$(document).ready(function () { // $(document).ready(function () {
removeDublicates(); // removeDublicates();
}); // });
} }
}; };

@ -88,6 +88,7 @@ function build_filters_period () {
function submit_search_form () { function submit_search_form () {
var $form = $('.filter_form'), var $form = $('.filter_form'),
params = $form.serialize(), params = $form.serialize(),
paramsForTop = $form.serializeArray(),
filters_url = $form.data('formurl'), filters_url = $form.data('formurl'),
results_url = $form.data('resultsurl'), results_url = $form.data('resultsurl'),
$loader = $('#wait-ajax'); $loader = $('#wait-ajax');
@ -101,7 +102,7 @@ function submit_search_form () {
$.getJSON(results_url, params, function(data) { $.getJSON(results_url, params, function(data) {
if (data.success) { if (data.success) {
$('.page-body').html(data.results); $('.page-body').html(data.results).prepend('<div id="expo_top_events"></div>');
build_sidebar(); build_sidebar();
$loader.hide(); $loader.hide();
} }
@ -115,6 +116,105 @@ function submit_search_form () {
build_filters_period(); build_filters_period();
} }
}) })
var API_URL_ROOT = "/expo-b/get-tops/";
var PARENT_ID = "expo_top_events";
var getUrl = function () {
var search = [];
var parts = /^\/([^\/]+)(?:\/|$)/i.exec(location.pathname);
if (parts) {
search.push("catalog=" + encodeURIComponent(parts[1]));
} else {
search.push("catalog=");
}
var data = window.sendData, theme = [];
$.each(paramsForTop, function(i,val){
if(val.name === 'theme') {
theme.push(parseInt(val.value));
}
});
data.theme = theme;
console.log('NEW:',data);
if (data instanceof Object) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
var value = data[key];
if (value instanceof Array) {
for (var i = 0, l = value.length; i < l; i++) {
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value[i]));
}
} else {
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
}
}
}
}
return API_URL_ROOT + "?" + search.join("&");
};
var runCallback = function (callback, arg) {
try {
callback(arg);
} catch (error) {
// do nothing
}
// console.info('callback Done');
};
var getTops = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (event) {
if (event.target.readyState === 4) {
if (event.target.status === 200) {
if (document.readyState === "loading" && !window.marker_DOMtopjsElementInserted) {
// console.info('setting DOMContentLoaded event listener');
// console.info('setting DOMtopjsElementInserted event listener');
// document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMtopjsElementInserted", function() {
runCallback(callback, event.target.responseText);
});
} else {
runCallback(callback, event.target.responseText);
}
}
}
};
xhr.send();
};
var removeDublicates = function () {
$('div#' + PARENT_ID + ' ul li.cl-item').each(function(index, el) {
$('div.page-body ul.cat-list li.cl-item[data-slug=\'' + $(el).data('slug') + '\']').not(el).remove();
});
};
var insertTops = function (text) {
var parent = document.getElementById(PARENT_ID);
if (parent) {
parent.innerHTML = text;
// $(document).ready(function () {
// removeDublicates();
// });
}
};
var main = function () {
getTops(getUrl(), insertTops);
};
// main();
// window.addEventListener("load", main);
// document.addEventListener("DOMContentLoaded", main);
main();
} }
$(document).ready(function () { $(document).ready(function () {

@ -4947,6 +4947,7 @@ function build_filters_period () {
function submit_search_form () { function submit_search_form () {
var $form = $('.filter_form'), var $form = $('.filter_form'),
params = $form.serialize(), params = $form.serialize(),
paramsForTop = $form.serializeArray(),
filters_url = $form.data('formurl'), filters_url = $form.data('formurl'),
results_url = $form.data('resultsurl'), results_url = $form.data('resultsurl'),
$loader = $('#wait-ajax'); $loader = $('#wait-ajax');
@ -4960,7 +4961,7 @@ function submit_search_form () {
$.getJSON(results_url, params, function(data) { $.getJSON(results_url, params, function(data) {
if (data.success) { if (data.success) {
$('.page-body').html(data.results); $('.page-body').html(data.results).prepend('<div id="expo_top_events"></div>');
build_sidebar(); build_sidebar();
$loader.hide(); $loader.hide();
} }
@ -4974,6 +4975,105 @@ function submit_search_form () {
build_filters_period(); build_filters_period();
} }
}) })
var API_URL_ROOT = "/expo-b/get-tops/";
var PARENT_ID = "expo_top_events";
var getUrl = function () {
var search = [];
var parts = /^\/([^\/]+)(?:\/|$)/i.exec(location.pathname);
if (parts) {
search.push("catalog=" + encodeURIComponent(parts[1]));
} else {
search.push("catalog=");
}
var data = window.sendData, theme = [];
$.each(paramsForTop, function(i,val){
if(val.name === 'theme') {
theme.push(parseInt(val.value));
}
});
data.theme = theme;
console.log('NEW:',data);
if (data instanceof Object) {
for (var key in data) {
if (data.hasOwnProperty(key)) {
var value = data[key];
if (value instanceof Array) {
for (var i = 0, l = value.length; i < l; i++) {
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value[i]));
}
} else {
search.push(encodeURIComponent(key) + "=" + encodeURIComponent(value));
}
}
}
}
return API_URL_ROOT + "?" + search.join("&");
};
var runCallback = function (callback, arg) {
try {
callback(arg);
} catch (error) {
// do nothing
}
// console.info('callback Done');
};
var getTops = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onreadystatechange = function (event) {
if (event.target.readyState === 4) {
if (event.target.status === 200) {
if (document.readyState === "loading" && !window.marker_DOMtopjsElementInserted) {
// console.info('setting DOMContentLoaded event listener');
// console.info('setting DOMtopjsElementInserted event listener');
// document.addEventListener("DOMContentLoaded", function() {
document.addEventListener("DOMtopjsElementInserted", function() {
runCallback(callback, event.target.responseText);
});
} else {
runCallback(callback, event.target.responseText);
}
}
}
};
xhr.send();
};
var removeDublicates = function () {
$('div#' + PARENT_ID + ' ul li.cl-item').each(function(index, el) {
$('div.page-body ul.cat-list li.cl-item[data-slug=\'' + $(el).data('slug') + '\']').not(el).remove();
});
};
var insertTops = function (text) {
var parent = document.getElementById(PARENT_ID);
if (parent) {
parent.innerHTML = text;
// $(document).ready(function () {
// removeDublicates();
// });
}
};
var main = function () {
getTops(getUrl(), insertTops);
};
// main();
// window.addEventListener("load", main);
// document.addEventListener("DOMContentLoaded", main);
main();
} }
$(document).ready(function () { $(document).ready(function () {

File diff suppressed because one or more lines are too long

@ -8,7 +8,7 @@
</div> </div>
<a class="more blue2" target="_blank" href="http://www.booking.com/searchresults.html?aid={{ book_aid }}&city={{ city.id }}{% if event %}&checkin_monthday={{ event.data_begin|date:'j' }}&checkin_year_month={{ event.data_begin|date:'Y' }}-{{ event.data_begin|date:'n' }}&checkout_monthday={{ event.data_end|date:'j' }}&checkout_year_month={{ event.data_end|date:'Y' }}-{{ event.data_end|date:'n' }}{% endif %}">{% trans 'Все отели поблизости' %}</a> <a class="more blue2" target="_blank" href="http://www.booking.com/searchresults.html?aid={{ book_aid }}&city={{ city.id }}{% if event %}&checkin_monthday={{ event.data_begin|date:'j' }}&checkin_year_month={{ event.data_begin|date:'Y' }}-{{ event.data_begin|date:'n' }}&checkout_monthday={{ event.data_end|date:'j' }}&checkout_year_month={{ event.data_end|date:'Y' }}-{{ event.data_end|date:'n' }}{% endif %}">{% trans 'Все отели поблизости' %}</a>
</header> </header>
<ul> <ul class="flexing_for_one_row">
{% if place %} {% if place %}
{% for hotel in place.get_nearest_hotels %} {% for hotel in place.get_nearest_hotels %}
<li> <li>

Loading…
Cancel
Save