diff --git a/addons/website/static/src/css/website.css b/addons/website/static/src/css/website.css index e9df2841347..e734525ee08 100644 --- a/addons/website/static/src/css/website.css +++ b/addons/website/static/src/css/website.css @@ -530,3 +530,9 @@ span[data-oe-type="monetary"] { width: 400px; margin: 40px auto; } + +.oe_website_overflow_ellipsis{ + white-space:nowrap; + overflow:hidden; + text-overflow:ellipsis; +} diff --git a/addons/website/static/src/css/website.sass b/addons/website/static/src/css/website.sass index 2c8d5d2fdda..3bdda2cb720 100644 --- a/addons/website/static/src/css/website.sass +++ b/addons/website/static/src/css/website.sass @@ -429,3 +429,9 @@ span[data-oe-type="monetary"] .oe_website_login_container width: 400px margin: 40px auto + +.oe_website_overflow_ellipsis + white-space:nowrap + overflow:hidden + text-overflow:ellipsis + diff --git a/addons/website_event/controllers/main.py b/addons/website_event/controllers/main.py index dad603f47ef..5b5de06dba1 100644 --- a/addons/website_event/controllers/main.py +++ b/addons/website_event/controllers/main.py @@ -28,9 +28,11 @@ controllers = controllers() from datetime import datetime, timedelta +import time from dateutil.relativedelta import relativedelta from openerp import tools import werkzeug.urls +import GeoIP class website_event(http.Controller): @http.route(['/event', '/event/page/'], type='http', auth="public", website=True, multilang=True) @@ -203,3 +205,33 @@ class website_event(http.Controller): } event_id = Event.create(request.cr, request.uid, vals, context=context) return request.redirect("/event/%s?enable_editor=1" % event_id) + + def get_visitors_country(self): + GI = GeoIP.open('/usr/share/GeoIP/GeoIP.dat', 0) + return {'country_code': GI.country_code_by_addr(request.httprequest.remote_addr), 'country_name': GI.country_name_by_addr(request.httprequest.remote_addr)} + + def get_formated_date(self, event): + start_date = datetime.strptime(event.date_begin, tools.DEFAULT_SERVER_DATETIME_FORMAT).date() + end_date = datetime.strptime(event.date_end, tools.DEFAULT_SERVER_DATETIME_FORMAT).date() + return ('%s %s%s') % (start_date.strftime("%b"), start_date.strftime("%e"), (end_date != start_date and ("-"+end_date.strftime("%e")) or "")) + + @http.route('/event/get_country_event_list', type='http', auth='public', website=True) + def get_country_events(self ,**post): + country_obj = request.registry['res.country'] + event_obj = request.registry['event.event'] + cr, uid, context,event_ids = request.cr, request.uid, request.context,[] + country_code = self.get_visitors_country()['country_code'] + result = {'events':[],'country':False} + if country_code: + country_ids = country_obj.search(request.cr, request.uid, [('code', '=', country_code)], context=request.context) + event_ids = event_obj.search(request.cr, request.uid, ['|', ('address_id', '=', None),('country_id.code', '=', country_code),('date_begin','>=', time.strftime('%Y-%m-%d 00:00:00')),('state', '=', 'confirm')], order="date_begin", context=request.context) + if not event_ids: + event_ids = event_obj.search(request.cr, request.uid, [('date_begin','>=', time.strftime('%Y-%m-%d 00:00:00')),('state', '=', 'confirm')], order="date_begin", context=request.context) + for event in event_obj.browse(request.cr, request.uid, event_ids, context=request.context)[:6]: + if country_code and event.country_id.code == country_code: + result['country'] = country_obj.browse(request.cr, request.uid, country_ids[0], context=request.context) + result['events'].append({ + "date": self.get_formated_date(event), + "event": event, + "url": event.website_url}) + return request.website.render("website_event.country_events_list",result) diff --git a/addons/website_event/static/src/img/world_map.jpg b/addons/website_event/static/src/img/world_map.jpg new file mode 100644 index 00000000000..2813f53f4c3 Binary files /dev/null and b/addons/website_event/static/src/img/world_map.jpg differ diff --git a/addons/website_event/static/src/js/website_geolocation.js b/addons/website_event/static/src/js/website_geolocation.js new file mode 100644 index 00000000000..fb00edc5e64 --- /dev/null +++ b/addons/website_event/static/src/js/website_geolocation.js @@ -0,0 +1,16 @@ +(function() { + "use strict"; + var website = openerp.website; + + website.snippet.animationRegistry.visitor = website.snippet.Animation.extend({ + selector: ".oe_country_events", + start: function () { + var self = this; + $.post( "/event/get_country_event_list", function( data ) { + if(data){ + $( ".country_events_list" ).replaceWith( data ); + } + }); + } + }); +})(); \ No newline at end of file diff --git a/addons/website_event/views/website_event.xml b/addons/website_event/views/website_event.xml index 3d019ba7417..1b3ce09fca6 100644 --- a/addons/website_event/views/website_event.xml +++ b/addons/website_event/views/website_event.xml @@ -117,6 +117,23 @@ + + + + + + + +