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
20 from werkzeug
.exceptions
import NotFound
, Forbidden
22 from indico
.modules
.attachments
.controllers
.management
.base
import (ManageAttachmentsMixin
, AddAttachmentFilesMixin
,
23 AddAttachmentLinkMixin
, EditAttachmentMixin
,
24 CreateFolderMixin
, EditFolderMixin
,
25 DeleteFolderMixin
, DeleteAttachmentMixin
)
26 from indico
.modules
.attachments
.util
import can_manage_attachments
27 from indico
.modules
.attachments
.controllers
.event_package
import MaterialsPackageMixin
28 from indico
.modules
.attachments
.views
import (WPContributionAttachments
, WPEventAttachments
, WPSessionAttachments
,
29 WPSubContributionAttachments
, WPMaterialsPackage
)
30 from indico
.modules
.events
.util
import get_object_from_args
31 from MaKaC
.webinterface
.rh
.base
import RHProtected
32 from MaKaC
.webinterface
.rh
.conferenceBase
import RHConferenceBase
33 from MaKaC
.webinterface
.rh
.conferenceModif
import RHConferenceModifBase
36 class RHEventAttachmentManagementBase(RHConferenceBase
, RHProtected
):
37 normalize_url_spec
= {
39 lambda self
: self
.object
43 def _checkParams(self
, params
):
44 RHConferenceBase
._checkParams
(self
, params
)
45 self
.object_type
, self
.base_object
, self
.object = get_object_from_args()
46 if self
.object is None:
49 def _checkProtection(self
):
50 RHProtected
._checkProtection
(self
)
51 if not can_manage_attachments(self
.object, session
.user
):
55 class RHManageEventAttachments(ManageAttachmentsMixin
, RHEventAttachmentManagementBase
):
57 'event': WPEventAttachments
,
58 'session': WPSessionAttachments
,
59 'contribution': WPContributionAttachments
,
60 'subcontribution': WPSubContributionAttachments
65 return self
._wp
_mapping
[self
.object_type
]
68 class RHAddEventAttachmentFiles(AddAttachmentFilesMixin
, RHEventAttachmentManagementBase
):
72 class RHAddEventAttachmentLink(AddAttachmentLinkMixin
, RHEventAttachmentManagementBase
):
76 class RHEditEventAttachment(EditAttachmentMixin
, RHEventAttachmentManagementBase
):
77 def _checkParams(self
, params
):
78 RHEventAttachmentManagementBase
._checkParams
(self
, params
)
79 EditAttachmentMixin
._checkParams
(self
)
82 class RHCreateEventFolder(CreateFolderMixin
, RHEventAttachmentManagementBase
):
86 class RHEditEventFolder(EditFolderMixin
, RHEventAttachmentManagementBase
):
87 def _checkParams(self
, params
):
88 RHEventAttachmentManagementBase
._checkParams
(self
, params
)
89 EditFolderMixin
._checkParams
(self
)
92 class RHDeleteEventFolder(DeleteFolderMixin
, RHEventAttachmentManagementBase
):
93 def _checkParams(self
, params
):
94 RHEventAttachmentManagementBase
._checkParams
(self
, params
)
95 DeleteFolderMixin
._checkParams
(self
)
98 class RHDeleteEventAttachment(DeleteAttachmentMixin
, RHEventAttachmentManagementBase
):
99 def _checkParams(self
, params
):
100 RHEventAttachmentManagementBase
._checkParams
(self
, params
)
101 DeleteAttachmentMixin
._checkParams
(self
)
104 class RHMaterialsDownloadManagement(MaterialsPackageMixin
, RHConferenceModifBase
):
105 wp
= WPMaterialsPackage