Fix datepicker arrows style on hover
[cds-indico.git] / indico / modules / rb / __init__.py
blobc7dfab6f8317c86d2ea3ee379166ba6a59c6fd45
1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
17 from __future__ import unicode_literals
19 from flask import session
21 from indico.core import signals
22 from indico.core.logger import Logger
23 from indico.core.settings import SettingsProxy
24 from indico.modules.rb.models.blocking_principals import BlockingPrincipal
25 from indico.modules.rb.models.blockings import Blocking
26 from indico.modules.rb.models.reservations import Reservation
27 from indico.modules.rb.models.rooms import Room
28 from indico.web.flask.util import url_for
29 from indico.util.i18n import _
32 logger = Logger.get('rb')
35 settings = SettingsProxy('roombooking', {
36 'assistance_emails': [],
37 'vc_support_emails': [],
38 'notification_hour': 6,
39 'notification_before_days': 1,
40 'notifications_enabled': True
41 }, acls={'admin_principals', 'authorized_principals'})
44 @signals.import_tasks.connect
45 def _import_tasks(sender, **kwargs):
46 import indico.modules.rb.tasks
49 @signals.admin_sidemenu.connect
50 def _extend_admin_menu(sender, **kwargs):
51 from MaKaC.webinterface.wcomponents import SideMenuItem
52 return 'rb', SideMenuItem(_("Rooms"), url_for('rooms_admin.settings'))
55 @signals.users.merged.connect
56 def _merge_users(target, source, **kwargs):
57 BlockingPrincipal.merge_users(target, source, 'blocking')
58 Blocking.find(created_by_id=source.id).update({Blocking.created_by_id: target.id})
59 Reservation.find(created_by_id=source.id).update({Reservation.created_by_id: target.id})
60 Reservation.find(booked_for_id=source.id).update({Reservation.booked_for_id: target.id})
61 Room.find(owner_id=source.id).update({Room.owner_id: target.id})
62 settings.acls.merge_users(target, source)
65 @signals.event.deleted.connect
66 def _event_deleted(event, user, **kwargs):
67 if event.has_legacy_id:
68 return
69 reservations = Reservation.find(Reservation.event_id == int(event.id),
70 ~Reservation.is_cancelled,
71 ~Reservation.is_rejected)
72 for resv in reservations:
73 resv.event_id = None
74 resv.cancel(user or session.user, 'Associated event was deleted')