# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (C) 2013-Today OpenERP SA (). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # ############################################################################## import openerp from openerp.addons.web import http from openerp.addons.web.http import request from openerp.addons.website.controllers.main import Website as controllers import datetime import re import werkzeug.utils controllers = controllers() import pytz from pytz import timezone class website_event(http.Controller): @http.route(['''/event//track/dates[-1][0]) or not location: dates.append((start_date, {}, bool(location))) for loc in locations.keys(): if locations[loc] and (locations[loc][-1][2] > start_date): locations[loc][-1][3] += 1 elif not locations[loc] or locations[loc][-1][2] < start_date: locations[loc].append([False, locations[loc] and locations[loc][-1][2] or dates[0][0], start_date, 1]) dates[-1][1][loc] = locations[loc][-1] forcetr = not bool(location) # Add event if locations[location] and locations[location][-1][1] > start_date: locations[location][-1][3] -= 1 locations[location].append([track, start_date, end_date, 1]) dates[-1][1][location] = locations[location][-1] return { 'locations': locations, 'dates': dates } # TODO: not implemented @http.route(['''/event//track_proposal/post'], type='http', auth="public", methods=['POST'], website=True, multilang=True) def event_track_proposal_post(self, event, **post): cr, uid, context = request.cr, request.uid, request.context tobj = request.registry['event.track'] tags = [] for tag in event.allowed_track_tag_ids: if post.get('tag_'+str(tag.id)): tags.append(tag.id) e = werkzeug.utils.escape track_description = '''

%s

%s

About The Author

%s

''' % (e(post['track_name']), e(post['description']), e(post['biography'])) track_id = tobj.create(cr, openerp.SUPERUSER_ID, { 'name': post['track_name'], 'event_id': event.id, 'tag_ids': [(6, 0, tags)], 'user_id': False, 'description': track_description }, context=context) tobj.message_post(cr, openerp.SUPERUSER_ID, [track_id], body="""Proposed By: %s
Mail: %s
Phone: %s""" % (e(post['partner_name']), e(post['email_from']), e(post['email_from']), e(post['phone'])), context=context) track = tobj.browse(cr, uid, track_id, context=context) values = {'track': track, 'event':event} return request.website.render("website_event_track.event_track_proposal_success", values)