Skip to content

Commit

Permalink
static sites interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacques Dafflon committed May 27, 2015
1 parent 6f519b0 commit d103efa
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 41 deletions.
29 changes: 1 addition & 28 deletions indico/MaKaC/webinterface/pages/conferences.py
Expand Up @@ -1969,7 +1969,7 @@ def _createTabCtrl(self):
self._tabMatPackage = self._tabCtrl.newTab("matPackage", _("Material Package"), \
urlHandlers.UHConfModFullMaterialPackage.getURL(self._conf))
if Config.getInstance().getOfflineStore():
self._tabOffline = self._tabCtrl.newTab("offline", _("Offline version"),
self._tabOffline = self._tabCtrl.newTab("offline", _("Offline copy"),
url_for('static_site.list', self._conf))

self._setActiveTab()
Expand Down Expand Up @@ -2480,33 +2480,6 @@ def _getTabContent( self, params ):
pars['cloneOptions'] += EventCloner.get_plugin_items(self._conf)
return p.getHTML(pars)

#---------------------------------------------------------------------------------------

class WPConfOffline(WPConfModifToolsBase):

def _setActiveTab(self):
self._tabOffline.setActive()

def _getTabContent(self, params):
p = WConfOffline(self._conf)
return p.getHTML(params)


class WConfOffline(wcomponents.WTemplated):

def __init__(self, conf):
self._conf = conf

def getVars(self):
vars = wcomponents.WTemplated.getVars(self)
vars["confId"] = self._conf.getId()
vars['event'] = self._conf
vars["avatarId"] = self._rh._aw.getUser().getId()
vars["offlineTasks"] = ModuleHolder().getById("offlineEvents").getOfflineEventByConfId(self._conf.getId())
return vars

#---------------------------------------------------------------------------------------


class WConferenceAllSessionsConveners(wcomponents.WTemplated):

Expand Down
11 changes: 0 additions & 11 deletions indico/MaKaC/webinterface/rh/conferenceModif.py
Expand Up @@ -4499,14 +4499,3 @@ def _process(self):
key = "tempBackground-%s-%s" % (self._conf.id, self.__templateId)
filePath = os.path.join(tempPath, session[key][int(self.__backgroundId)][0])
return self.__fileBin(filePath)


class RHConfOffline(RHConferenceModifBase):

def _checkProtection(self):
RHConferenceModifBase._checkProtection(self)

def _process(self):
if not Config.getInstance().getOfflineStore():
raise MaKaCError(_("This feature is not enabled"))
return conferences.WPConfOffline(self, self._conf).display()
47 changes: 47 additions & 0 deletions indico/htdocs/sass/modules/_event_management.scss
@@ -0,0 +1,47 @@
/* This file is part of Indico.
* Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
*
* Indico is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of the
* License, or (at your option) any later version.
*
* Indico 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
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Indico; if not, see <http://www.gnu.org/licenses/>.
*/

@import 'base';

.static-sites {
width: 650px;
.i-table-widget {
border: 0;
// date
th:nth-child(2),
td:nth-child(2),
// download
th:nth-child(4),
td:nth-child(4) {
text-align: center;
}
// date
td:nth-child(2) {
color: $dark-gray;
}
// status
th:nth-child(3),
td:nth-child(3) {
text-align: center;
.i-label {
width: 100%;

border: 0;
}
}
}
}
6 changes: 4 additions & 2 deletions indico/modules/events/static/controllers.py
Expand Up @@ -25,10 +25,10 @@
from indico.core.errors import IndicoError
from indico.modules.events.static.models.static import StaticSite, StaticSiteState
from indico.modules.events.static.tasks import build_static_site
from indico.modules.events.static.views import WPStaticSites
from indico.util.i18n import _
from indico.web.flask.util import send_file, url_for

from MaKaC.webinterface.pages.conferences import WPConfOffline
from MaKaC.webinterface.rh.conferenceModif import RHConferenceModifBase


Expand All @@ -43,7 +43,9 @@ def _process(self):
self.check_legacy_events()
if not Config.getInstance().getOfflineStore():
raise NotFound()
return WPConfOffline(self, self._conf).display()
static_sites = StaticSite.find(event_id=self._conf.id).order_by(StaticSite.requested_dt.desc()).all()
return WPStaticSites.render_template('static_sites.html', self._conf,
event=self._conf, static_sites=static_sites)


class RHStaticSiteBuild(RHStaticSiteBase):
Expand Down
@@ -0,0 +1,64 @@
<div class="i-box-group vert fixed-width static-sites">
<div class="i-box titled">
<div class="i-box-header">
<div class="i-box-title">{%- trans %}New Offline Copy{% endtrans -%}</div>
<button id="test" class="i-button icon-wrench right" type="button"
data-method="post"
data-href="{{ url_for('static_site.build', event) }}"
data-title="{{ _('Build an offline copy') }}"
data-confirm="{{ _('Are you sure you want to build an offline copy of this event?<br>Beware that it is a heavy operation, especially for large events, and it might take some time to finish.') }}">{{_('Build offline copy')}}
</button>
</div>
<div class="i-box-content">
{% trans %}This will build an offline copy of the event. This is useful if you want to make it available where no Internet connection is available.{% endtrans %}</li>
</div>
</div>
<div class="i-box titled no-padding">
<div class="i-box-header">
<div class="i-box-title">{%- trans %}Existing Offline Copies{% endtrans -%}</div>
</div>
<div class="i-box-content">
{% if static_sites %}
{% set label_mapping = {
'success': 'accept',
'failed': 'danger',
'expired': 'warning',
'running': 'highlight'
} %}
{% set has_downloads = static_sites|selectattr('state.name', 'equalto', 'success')|any %}
<table class="i-table-widget">
<thead>
<tr>
<th>{% trans %}Requested by{% endtrans %}</th>
<th>{% trans %}Requested on{% endtrans %}</th>
<th>{% trans %}Status{% endtrans %}</th>
{% if has_downloads %}
<th>{% trans %}Download{% endtrans %}</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for site in static_sites %}
<tr>
<td>{{ site.user.full_name }}</td>
<td>{{ site.requested_dt|format_datetime }}</td>
<td><span class="i-label {{ label_mapping.get(site.state.name, 'disabled') }}">{{ site.state.title }}</span></td>
{% if has_downloads %}
<td>
{% if site.state.name == 'success' %}
<a href="{{ url_for('static_site.download', site, _external=True) }}" class="i-button icon-file-download">
{%- trans %}Download{% endtrans -%}
</a>
{% endif %}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<span class="empty">{% trans %}There are no offline copies of this event.{% endtrans %}</span>
{% endif %}
</div>
</div>
</div>
31 changes: 31 additions & 0 deletions indico/modules/events/static/views.py
@@ -0,0 +1,31 @@
# This file is part of Indico.
# Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
#
# Indico is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Indico 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
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.

from MaKaC.webinterface.pages.conferences import WPConfModifToolsBase
from MaKaC.webinterface.pages.base import WPJinjaMixin


class WPStaticSites(WPConfModifToolsBase, WPJinjaMixin):
template_prefix = 'events/static/'

def getCSSFiles(self):
return WPConfModifToolsBase.getCSSFiles(self) + self._asset_env['event_management_sass'].urls()

def _setActiveTab(self):
self._tabOffline.setActive()

def _getTabContent(self, params):
return WPJinjaMixin._getPageContent(self, params)
2 changes: 2 additions & 0 deletions indico/web/assets/bundles.py
Expand Up @@ -386,6 +386,7 @@ def sass_module_bundle(module_name, depends=[]):
admin_sass = sass_module_bundle('admin')
eventservices_sass = sass_module_bundle('eventservices')
event_display_sass = sass_module_bundle('event_display')
event_management_sass = sass_module_bundle('event_management')
overviews_sass = sass_module_bundle('overviews')
vc_sass = sass_module_bundle('vc')
news_sass = sass_module_bundle('news')
Expand Down Expand Up @@ -462,6 +463,7 @@ def register_all_css(env, main_css_file):
env.register('screen_sass', screen_sass)
env.register('eventservices_sass', eventservices_sass)
env.register('event_display_sass', event_display_sass)
env.register('event_management_sass', event_management_sass)
env.register('overviews_sass', overviews_sass)
env.register('vc_sass', vc_sass)
env.register('news_sass', news_sass)
Expand Down
1 change: 1 addition & 0 deletions indico/web/flask/app.py
Expand Up @@ -211,6 +211,7 @@ def setup_jinja(app):
app.add_template_filter(markdown)
app.add_template_filter(dedent)
app.add_template_filter(natsort)
app.add_template_filter(any)
# Tests
app.add_template_test(instanceof) # only use this test if you really have to!
app.add_template_test(equalto)
Expand Down

0 comments on commit d103efa

Please sign in to comment.