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 request
, session
, redirect
20 from werkzeug
.exceptions
import Forbidden
22 from MaKaC
.webinterface
.rh
.conferenceBase
import RHConferenceBase
23 from MaKaC
.webinterface
.rh
.conferenceDisplay
import RHConferenceBaseDisplay
25 from indico
.modules
.attachments
.controllers
.event_package
import MaterialsPackageMixin
26 from indico
.modules
.attachments
.controllers
.util
import SpecificFolderMixin
27 from indico
.modules
.attachments
.controllers
.display
.base
import DownloadAttachmentMixin
28 from indico
.modules
.attachments
.views
import (WPEventFolderDisplay
, WPEventMaterialsDownloadDisplay
,
29 WPSimpleMaterialsDownloadDisplay
)
32 class RHDownloadEventAttachment(DownloadAttachmentMixin
, RHConferenceBase
):
33 def _checkParams(self
, params
):
34 RHConferenceBase
._checkParams
(self
, params
)
35 DownloadAttachmentMixin
._checkParams
(self
)
38 class RHListEventAttachmentFolder(SpecificFolderMixin
, RHConferenceBaseDisplay
):
39 def _checkParams(self
, params
):
40 RHConferenceBaseDisplay
._checkParams
(self
, params
)
41 SpecificFolderMixin
._checkParams
(self
)
43 def _checkProtection(self
):
44 RHConferenceBaseDisplay
._checkProtection
(self
)
45 if not self
.folder
.can_access(session
.user
):
49 if request
.args
.get('redirect_if_single') == '1' and len(self
.folder
.attachments
) == 1:
50 return redirect(self
.folder
.attachments
[0].download_url
)
52 return WPEventFolderDisplay
.render_template('folder.html', self
._target
,
53 folder
=self
.folder
, event
=self
._target
)
56 class RHMaterialsDownloadDisplay(MaterialsPackageMixin
, RHConferenceBaseDisplay
):
60 if self
._conf
.getType() == 'conference':
61 return WPEventMaterialsDownloadDisplay
63 return WPSimpleMaterialsDownloadDisplay