Browse Source

mediatheque

dev-rcn
root 3 years ago
parent
commit
0339b140bc
9 changed files with 455 additions and 4 deletions
  1. +2
    -1
      __manifest__.py
  2. +7
    -0
      controllers/booking.py
  3. +158
    -2
      controllers/kalachakra.py
  4. +15
    -0
      models/booking_event.py
  5. +6
    -1
      static/js/booking.js
  6. +2
    -0
      views/booking_website_registration.xml
  7. +24
    -0
      views/individual_booking_event.xml
  8. +237
    -0
      views/mediatheque.xml
  9. +4
    -0
      views/website_templates.xml

+ 2
- 1
__manifest__.py View File

@ -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'


+ 7
- 0
controllers/booking.py View File

@ -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)


+ 158
- 2
controllers/kalachakra.py View File

@ -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):


+ 15
- 0
models/booking_event.py View File

@ -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'
)

+ 6
- 1
static/js/booking.js View File

@ -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)
{


+ 2
- 0
views/booking_website_registration.xml View File

@ -188,6 +188,8 @@
<input type="hidden" id="days_duration" name="days_duration"/>
<input type="hidden" id="price_individual_booking" name="price_individual_booking"/>
<input type="hidden" id="id_opt_individual_room" t-att-value="int(id_opt_individual_room)"/>
<input type="hidden" id="id_opt_reduction1200" t-att-value="int(id_opt_reduction1200)"/>
<t t-if="options">


+ 24
- 0
views/individual_booking_event.xml View File

@ -21,4 +21,28 @@
<menuitem id="individual_booking_event_menu" action="individual_booking_event_action"
parent="individual_booking_event_title_menu" sequence="10"/>
<record model="ir.ui.view" id="event_email_list">
<field name="name">event email list</field>
<field name="model">event.email.manager</field>
<field name="arch" type="xml">
<tree>
<field name="firstname"/>
<field name="name"/>
<field name="email"/>
</tree>
</field>
</record>
<record model="ir.actions.act_window" id="individual_booking_event_email_action">
<field name="name">Event emails action</field>
<field name="res_model">event.email.manager</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="booking_email_manager_menu" action="location_action"
parent="booking_title_menu" groups="event.group_event_user" sequence="1"/>
</odoo>

+ 237
- 0
views/mediatheque.xml View File

@ -0,0 +1,237 @@
<odoo>
<template id="website_mediatheque" name="Mediatheque">
<t t-call="website.layout">
<div id="wrap" class="o_wevent_index">
<!-- Options -->
<!-- <t t-set="opt_events_list_cards" t-value="is_view_active('website_event.opt_events_list_cards')"/>
<t t-set="opt_events_list_columns" t-value="is_view_active('website_event.opt_events_list_columns')"/> -->
<!-- Topbar -->
<t t-call="kalachakra.mediatheque_index_topbar"/>
<!-- Drag/Drop Area -->
<div id="oe_structure_we_index_1" class="oe_structure oe_empty"/>
<!-- Content -->
<div t-attf-class="o_wevent_events_list #{opt_events_list_cards and 'opt_event_list_cards_bg'}">
<div class="container">
<!-- <div class="row">
<t t-call="website_event.searched_tags"/>
</div> -->
<div class="row">
<div id="o_wevent_index_main_col" t-attf-class="col-md my-5 #{opt_events_list_columns and 'opt_events_list_columns' or 'opt_events_list_rows'}">
<div class="row">
<!-- Events List -->
<t t-call="kalachakra.mediatheque_events_list"/>
</div>
</div>
</div>
</div>
</div>
<!-- Drag/Drop Area -->
<div id="oe_structure_we_index_2" class="oe_structure oe_empty"/>
</div>
</t>
</template>
<template id="mediatheque_events_list" name="Events list">
<!-- Options -->
<t t-set="opt_index_sidebar" t-value="is_view_active('website_event.opt_index_sidebar')"/>
<t t-if="opt_events_list_columns" t-set="opt_event_size" t-value="opt_index_sidebar and 'col-md-6' or 'col-md-6 col-lg-4'"/>
<t t-else="" t-set="opt_event_size" t-value="opt_index_sidebar and 'col-12' or 'col-xl-10 offset-xl-1'"/>
<!-- No events -->
<t t-if="not event_ids">
<div class="col-12">
<div class="h2 mb-3">No events found.</div>
<div class="alert alert-info text-center" groups="event.group_event_manager">
<p class="m-0">Use the top button '<b>+ New</b>' to create an event.</p>
</div>
</div>
</t>
<!-- List -->
<div t-foreach="event_ids" t-as="event" t-attf-class=" #{opt_event_size} mb-4">
<a t-attf-href="/kalachakra/mediatheque/event?id=#{event.id }" class="text-decoration-none">
<article t-attf-class="h-100 #{opt_events_list_cards and 'card border-0 shadow-sm'}" itemscope="itemscope" itemtype="http://schema.org/Event">
<div class="h-100 row no-gutters">
<!-- Header -->
<header t-attf-class="overflow-hidden bg-secondary #{opt_events_list_columns and 'col-12 rounded-top' or 'col-sm-4 col-lg-3 rounded-left'} #{(not opt_events_list_cards) and 'rounded shadow'} #{(not opt_events_list_cards and not opt_events_list_columns) and 'rounded-top'}">
<!-- Image + Link -->
<div class="d-block h-100 w-100">
<t t-call="website.record_cover">
<t t-set="_record" t-value="event"/>
<!-- Short Date -->
<div class="o_wevent_event_date position-absolute bg-white shadow-sm text-dark">
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'format': 'LLL'}" class="o_wevent_event_month"/>
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'format': 'dd'}" class="o_wevent_event_day"/>
</div>
</t>
</div>
</header>
<div t-att-class="'%s %s' % (
opt_events_list_columns and 'col-12' or 'col',
opt_events_list_columns and event.event_registrations_open and not event.event_registrations_sold_out and 'h-100' or '')">
<!-- Body -->
<main t-attf-class="#{opt_events_list_cards and 'card-body' or (opt_events_list_columns and 'py-3' or 'px-4')}">
<!-- Title -->
<h5 t-attf-class="card-title mt-2 mb-0 text-truncate #{(not event.website_published) and 'text-danger'}">
<span t-field="event.name" itemprop="name"/>
</h5>
<!-- Start Date & Time -->
<time itemprop="startDate" t-att-datetime="event.date_begin">
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'date_only': 'true', 'format': 'long'}"/> -
<span t-field="event.with_context(tz=event.date_tz).date_begin" t-options="{'time_only': 'true', 'format': 'short'}"/>
</time>
<!-- Location -->
<div itemprop="location" t-field="event.address_id" t-options="{'widget': 'contact', 'fields': ['city'], 'no_marker': 'true'}"/>
<div class="mt8 d-flex align-items-center">
<t t-foreach="event.tag_ids" t-as="tag">
<span t-if="tag.color"
t-attf-class="badge mr8 #{'badge-primary' if tag in search_tags else 'badge-light'} #{'o_tag_color_%s' % tag.color if tag.color else ''}">
<span t-esc="tag.name"/>
</span>
</t>
</div>
</main>
</div>
<!-- Footer -->
<footer t-if="not event.event_registrations_open or event.event_registrations_sold_out"
t-att-class="'small align-self-end w-100 %s %s' % (
opt_events_list_cards and 'card-footer' or (not opt_events_list_columns and 'mx-4 mt-auto pt-2') or 'py-2',
opt_events_list_cards and 'border-top' or '',
)">
</footer>
</div>
</article>
</a>
</div>
<!-- Pager -->
<div class="form-inline justify-content-center my-3">
<t t-call="website.pager"/>
</div>
</template>
<template id="mediatheque_index_topbar" name="Topbar">
<nav class="navbar navbar-light border-top shadow-sm d-print-none">
<div class="container">
<div class="d-flex flex-column flex-sm-row justify-content-between w-100">
<span class="navbar-brand h4 my-0 mr-auto">Mediathèque</span>
<ul class="o_wevent_index_topbar_filters nav"/>
<div class="d-flex align-items-center flex-wrap pl-sm-3 pr-0">
<t t-call="kalachakra.mediatheque_search_box">
<t t-set="_searches" t-value="searches"/>
<t t-set="_placeholder">Chercher un événement...</t>
</t>
</div>
</div>
</div>
</nav>
</template>
<template id="mediatheque_search_box" inherit_id="website.website_search_box" primary="True">
<xpath expr="//div[@role='search']" position="replace">
<form t-attf-class="o_wevent_event_searchbar_form o_wait_lazy_js w-100 my-1 my-lg-0 #{_classes}"
t-att-action="action if action else '/kalachakra/mediatheque'" method="get">
<t t-set="search" t-value="search or _searches and _searches['search']"/>
<t t-set="placeholder" t-value="placeholder or _placeholder"/>
<t>$0</t>
<t t-foreach="_searches" t-as="search">
<input t-if="search != 'search' and search_value != 'all'" type="hidden"
t-att-name="search" t-att-value="search_value"/>
</t>
<t t-raw="0"/>
</form>
</xpath>
</template>
<template id="kalachakra.website_mediatheque_event" name="website mediatheque event">
<t t-call="website.layout">
<div class="container">
<a href="/kalachakra/mediatheque?search=&amp;date=old&amp;tags=enregistrements" class="navbar-brand h4 my-0 mr-0 mr-md-4">
<i class="fa fa-long-arrow-left text-primary mr-2"></i>
<span class="kala_evt1">Retour</span>
</a>
<t t-if="event.teaching_day_ids">
<h6 style="background-color: orange;">Enregistrements disponibles :</h6>
<t t-foreach="event.teaching_day_ids.sorted(key=lambda r: r.sequence)" t-as="t_day">
<t t-if="t_day.teaching_session_ids">
<table class="table" style="font-size: smaller;">
<tr>
<td colspan="3"><span t-esc="t_day.day_teaching"/></td>
<td colspan="3"><span t-esc="t_day.day_teaching"/></td>
</tr>
<tr>
<td>Session</td>
<td colspan="2">En français</td>
<td colspan="2">In english</td>
<td>Session</td>
</tr>
<tr>
<td></td>
<td>Audio</td>
<td>Video</td>
<td>Audio</td>
<td>Video</td>
<td></td>
</tr>
<t t-foreach="t_day.teaching_session_ids" t-as="media">
<tr>
<td><span t-esc="media.description_fr" /></td>
<t t-if="media.link_audio_fr">
<td><a t-attf-href="#{media.link_audio_fr}"><span>Audio FR</span></a></td>
</t>
<t t-if="not media.link_audio_fr">
<td>
</td>
</t>
<t t-if="media.link_video_fr">
<td><a t-attf-href="#{media.link_video_fr}"><span>Video FR</span></a></td>
</t>
<t t-if="not media.link_video_fr">
<td>
</td>
</t>
<t t-if="media.link_audio_en">
<td><a t-attf-href="#{media.link_audio_en}"><span>Audio EN</span></a></td>
</t>
<t t-if="not media.link_audio_en">
<td>
</td>
</t>
<t t-if="media.link_video_en">
<td><a t-attf-href="#{media.link_video_en}"><span>Video EN</span></a></td>
</t>
<t t-if="not media.link_video_en">
<td>
</td>
</t>
<td><span t-esc="media.description_en" /></td>
</tr>
</t>
</table>
</t>
<br></br>
</t>
</t>
<t t-if="event.teaching_html_content_records_published">
<h6 style="background-color: orange;">Enregistrements disponibles :</h6>
<div>
<t t-raw="event.teaching_html_content_records"/>
</div>
<br></br><br></br>
</t>
</div>
</t>
</template>
</odoo>

+ 4
- 0
views/website_templates.xml View File

@ -5,4 +5,8 @@
</xpath>
</template>
</odoo>

Loading…
Cancel
Save