diff --git a/__manifest__.py b/__manifest__.py index 82a315f..e69d2ba 100755 --- a/__manifest__.py +++ b/__manifest__.py @@ -68,7 +68,8 @@ 'views/media.xml', 'views/asset.xml', 'views/payment_transaction.xml', - 'views/donation.xml' + 'views/donation.xml', + 'views/mediatheque.xml' #'views/payment_views.xml' diff --git a/controllers/booking.py b/controllers/booking.py index 107af1e..74c9043 100755 --- a/controllers/booking.py +++ b/controllers/booking.py @@ -66,8 +66,14 @@ class booking(WebsiteEventController,AuthSignupHome): #options data['options']=[] + data['id_opt_reduction1200']=False + data['id_opt_individual_room']=False for opt in event.booking_option_ids: + if opt.booking_option_id.individual_room: + data['id_opt_individual_room']=opt.booking_option_id.id + if "1200" in opt.booking_option_id.name: + data['id_opt_reduction1200']=opt.booking_option_id.id if opt.booking_option_id.membership_product: if partner.member_status!='member' and partner.member_status!='super member':data['options'].append(opt) @@ -81,6 +87,7 @@ class booking(WebsiteEventController,AuthSignupHome): #questions data['questions']=event.question_ids + request.session['invoice_id']=False return http.request.render('kalachakra.booking_registration_options_form',data) diff --git a/controllers/kalachakra.py b/controllers/kalachakra.py index 05036c8..1c4b6b2 100755 --- a/controllers/kalachakra.py +++ b/controllers/kalachakra.py @@ -1,17 +1,21 @@ # -*- coding: utf-8 -*- from odoo import http,_ from odoo.http import request +from odoo.osv import expression import logging from odoo import models, fields, api import werkzeug +from werkzeug.datastructures import OrderedMultiDict from datetime import datetime,timedelta from odoo.tools import format_datetime, format_date, is_html_empty from dateutil.relativedelta import relativedelta from odoo.exceptions import UserError +from collections import defaultdict import babel import babel.dates from odoo.addons.web.controllers.main import ensure_db, Home from odoo.addons.website_event.controllers.main import WebsiteEventController +from odoo.addons.website.controllers.main import QueryURL from odoo.addons.payment.controllers.portal import PaymentProcessing #from odoo.addons.sale.controllers.portal import CustomerPortal from odoo.addons.account.controllers.portal import CustomerPortal @@ -156,7 +160,9 @@ class KalaAuthSignupHome(Home): return response class kalachakra_event(WebsiteEventController,PaymentProcessing): - + def sitemap_event(env, rule, qs): + if not qs or qs.lower() in '/events': + yield {'loc': '/events'} #afficher la liste des prochains événement sur la home page (sans les retraites ! ) @http.route('/event/csv_booking_registrants', website=False, auth='user',methods=['GET']) def export_csv_booking_registrants(self,id,*args,**kw): @@ -266,7 +272,157 @@ class kalachakra_event(WebsiteEventController,PaymentProcessing): tags = request.env['event.tag'].search([('name', '=', searches['tags'])]) return tags - + @http.route(['/kalachakra/mediatheque/event'], type='http', auth="public", website=True, sitemap=sitemap_event) + def kalachakraMediathequeEvent(self,**id): + id=id.get('id') + event = request.env['event.event'].sudo().search([('id','=',int(id))]) + data={} + data['event']=event + return request.render("kalachakra.website_mediatheque_event",data) + + @http.route(['/kalachakra/mediatheque'], type='http', auth="public", website=True, sitemap=sitemap_event) + def kalachakraMediatheque(self,page=1,**searches): + + Event = request.env['event.event'] + SudoEventType = request.env['event.type'].sudo() + + searches.setdefault('search', '') + searches.setdefault('date', 'all') + searches.setdefault('tags', '') + searches.setdefault('type', 'all') + searches.setdefault('country', 'all') + + website = request.website + today = fields.Datetime.today() + + def sdn(date): + return fields.Datetime.to_string(date.replace(hour=23, minute=59, second=59)) + + def sd(date): + return fields.Datetime.to_string(date) + + def get_month_filter_domain(filter_name, months_delta): + first_day_of_the_month = today.replace(day=1) + filter_string = _('This month') if months_delta == 0 \ + else format_date(request.env, value=today + relativedelta(months=months_delta), + date_format='LLLL', lang_code=get_lang(request.env).code).capitalize() + return [filter_name, filter_string, [ + ("date_end", ">=", sd(first_day_of_the_month + relativedelta(months=months_delta))), + ("date_begin", "<", sd(first_day_of_the_month + relativedelta(months=months_delta+1)))], + 0] + + dates = [ + ['all', _('Upcoming Events'), [("date_end", ">", sd(today))], 0], + ['today', _('Today'), [ + ("date_end", ">", sd(today)), + ("date_begin", "<", sdn(today))], + 0], + get_month_filter_domain('month', 0), + ['old', _('Past Events'), [ + ("date_end", "<", sd(today))], + 0], + ] + + # search domains + domain_search = {'website_specific': website.website_domain()} + + if searches['search']: + domain_search['search'] = [('name', 'ilike', searches['search'])] + + + search_tags = self._extract_searched_event_tags(searches) + if search_tags: + # Example: You filter on age: 10-12 and activity: football. + # Doing it this way allows to only get events who are tagged "age: 10-12" AND "activity: football". + # Add another tag "age: 12-15" to the search and it would fetch the ones who are tagged: + # ("age: 10-12" OR "age: 12-15") AND "activity: football + grouped_tags = defaultdict(list) + for tag in search_tags: + grouped_tags[tag.category_id].append(tag) + domain_search['tags'] = [] + for group in grouped_tags: + domain_search['tags'] = expression.AND([domain_search['tags'], [('tag_ids', 'in', [tag.id for tag in grouped_tags[group]])]]) + + current_date = None + current_type = None + current_country = None + for date in dates: + if searches["date"] == date[0]: + domain_search["date"] = date[2] + if date[0] != 'all': + current_date = date[1] + + if searches["type"] != 'all': + current_type = SudoEventType.browse(int(searches['type'])) + domain_search["type"] = [("event_type_id", "=", int(searches["type"]))] + + if searches["country"] != 'all' and searches["country"] != 'online': + current_country = request.env['res.country'].browse(int(searches['country'])) + domain_search["country"] = ['|', ("country_id", "=", int(searches["country"])), ("country_id", "=", False)] + elif searches["country"] == 'online': + domain_search["country"] = [("country_id", "=", False)] + + def dom_without(without): + domain = [] + for key, search in domain_search.items(): + if key != without: + domain += search + return domain + + # count by domains without self search + for date in dates: + if date[0] != 'old': + date[3] = Event.search_count(dom_without('date') + date[2]) + + domain = dom_without('type') + + domain = dom_without('country') + countries = Event.read_group(domain, ["id", "country_id"], groupby="country_id", orderby="country_id") + countries.insert(0, { + 'country_id_count': sum([int(country['country_id_count']) for country in countries]), + 'country_id': ("all", _("All Countries")) + }) + + step = 12 # Number of events per page + event_count = Event.search_count(dom_without("none")) + pager = website.pager( + url="/event", + url_args=searches, + total=event_count, + page=page, + step=step, + scope=5) + + order = 'date_begin' + if searches.get('date', 'all') == 'old': + order = 'date_begin desc' + order = 'is_published desc, ' + order + events = Event.search(dom_without("none"), limit=step, offset=pager['offset'], order=order) + + keep = QueryURL('/event', **{key: value for key, value in searches.items() if (key == 'search' or value != 'all')}) + #search_tags=['enregistrement'] + values = { + 'current_date': current_date, + 'current_country': current_country, + 'current_type': current_type, + 'event_ids': events, # event_ids used in website_event_track so we keep name as it is + 'dates': dates, + 'categories': request.env['event.tag.category'].search([]), + 'countries': countries, + 'pager': pager, + 'searches': searches, + 'search_tags': search_tags, + 'keep': keep, + } + + if searches['date'] == 'old': + # the only way to display this content is to set date=old so it must be canonical + values['canonical_params'] = OrderedMultiDict([('date', 'old')]) + + return request.render("kalachakra.website_mediatheque", values) + + + @http.route(['/notre-centre-de-retraite/presentation-du-centre'], type='http', auth='public', website=True, sitemap=False,csrf=False) def kalachakracentreretraite(self,**post): diff --git a/models/booking_event.py b/models/booking_event.py index 8d2c496..521273d 100755 --- a/models/booking_event.py +++ b/models/booking_event.py @@ -391,3 +391,18 @@ class event_membership_product(models.Model): membership_product_id=fields.Many2one('product.product',string='Membership product',domain="[('booking_option_product','=','True')]") +class event_email_manager(models.Model): + _name = 'event.email.manager' + _description = 'e-mails of individuals retreats managers to inform' + + name=fields.Char('name') + firstname=fields.Char('firstname') + email=fields.Char(string='e-mail') + event_id = fields.Many2one( + 'event.event', + String='event', + index=True, + readonly=True, + track_visibility='onchange', + ondelete='restrict' + ) diff --git a/static/js/booking.js b/static/js/booking.js index dc49758..34c9a72 100755 --- a/static/js/booking.js +++ b/static/js/booking.js @@ -390,9 +390,14 @@ odoo.define('booking.main', function (require) { }); $(":checkbox").change(function() { - //console.log('start debug price') + //console.log(this.value) + //console.log($("#id_opt_reduction1200").val()) //console.log('status:'+$("#status").val()) //si coche adhésion alors le statut devient membre + if (this.value==$("#id_opt_individual_room").val() && this.checked) + { + alert('toto') + } if(this.value==$("#membership_product").val() && this.checked) { diff --git a/views/booking_website_registration.xml b/views/booking_website_registration.xml index cfc6e75..1c8be32 100755 --- a/views/booking_website_registration.xml +++ b/views/booking_website_registration.xml @@ -188,6 +188,8 @@ + + diff --git a/views/individual_booking_event.xml b/views/individual_booking_event.xml index 7d34b85..4bfa9ca 100755 --- a/views/individual_booking_event.xml +++ b/views/individual_booking_event.xml @@ -21,4 +21,28 @@ + + event email list + event.email.manager + + + + + + + + + + + + Event emails action + event.email.manager + tree,form + + + + + + diff --git a/views/mediatheque.xml b/views/mediatheque.xml new file mode 100755 index 0000000..818c1d0 --- /dev/null +++ b/views/mediatheque.xml @@ -0,0 +1,237 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/views/website_templates.xml b/views/website_templates.xml index cf53f4d..f52ca8f 100755 --- a/views/website_templates.xml +++ b/views/website_templates.xml @@ -5,4 +5,8 @@ + + + + \ No newline at end of file