Add chatroom info page (for conferences)

This commit is contained in:
Adrian Moennich 2014-10-02 16:49:26 +02:00
parent c01fc80f93
commit 3fa09dd2ed
5 changed files with 134 additions and 1 deletions

View File

@ -14,6 +14,11 @@
# You should have received a copy of the GNU General Public License
# along with Indico; if not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
from indico.core.plugins import IndicoPluginBlueprint
from indico_chat.controllers import RHChatEventPage
blueprint = IndicoPluginBlueprint('chat', 'indico_chat')
blueprint.add_url_rule('/event/<confId>/chat-new', 'event-page', RHChatEventPage)

View File

@ -0,0 +1,43 @@
# This file is part of Indico.
# Copyright (C) 2002 - 2014 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 __future__ import unicode_literals
from flask_pluginengine import current_plugin
from indico.core.errors import IndicoError
from MaKaC.webinterface.rh.conferenceDisplay import RHConferenceBaseDisplay
from indico_chat.models.chatrooms import ChatroomEventAssociation
from indico_chat.views import WPChatEventPage
class RHChatEventPage(RHConferenceBaseDisplay):
def _process(self):
try:
event_id = int(self._conf.id)
except ValueError:
raise IndicoError('This page is not available for legacy events.')
chatrooms = ChatroomEventAssociation.find_all(ChatroomEventAssociation.event_id == event_id,
~ChatroomEventAssociation.hidden)
cols = set()
if any(c.chatroom.description for c in chatrooms):
cols.add('description')
if any(c.chatroom.password for c in chatrooms):
cols.add('password')
return WPChatEventPage.render_template('event_page.html', self._conf, event_chatrooms=chatrooms, cols=cols,
chat_links=current_plugin.settings.get('chat_links'))

View File

@ -28,6 +28,7 @@ from MaKaC.webinterface.pages.conferences import WPTPLConferenceDisplay, WPXSLCo
from indico_chat.blueprint import blueprint
from indico_chat.models.chatrooms import ChatroomEventAssociation
from indico_chat.views import WPChatEventPage
class SettingsForm(IndicoForm):
@ -61,7 +62,7 @@ class ChatPlugin(IndicoPlugin):
def init(self):
super(ChatPlugin, self).init()
self.template_hook('event-header', self.inject_event_header)
for wp in (WPTPLConferenceDisplay, WPXSLConferenceDisplay):
for wp in (WPTPLConferenceDisplay, WPXSLConferenceDisplay, WPChatEventPage):
self.inject_css('chat_css', wp)
self.inject_js('chat_js', wp)

View File

@ -0,0 +1,54 @@
<h2 class="page-title">{% trans %}Chat Rooms{% endtrans %}</h2>
<table class="infoTable" width="100%" align="center" border="0" cellspacing="0">
<thead>
<tr>
<td class="tableHeader">{% trans %}Room{% endtrans %}</td>
<td class="tableHeader">{% trans %}Server{% endtrans %}</td>
{% if 'description' in cols -%}
<td class="tableHeader">{% trans %}Description{% endtrans %}</td>
{% endif %}
{% if 'password' in cols -%}
<td class="tableHeader">{% trans %}Password{% endtrans %}</td>
{% endif %}
{% if chat_links %}
<td class="tableHeader">{% trans %}Actions{% endtrans %}</td>
{% endif %}
</tr>
</thead>
<tbody id="chat-info-container" data-chat-links="{{ chat_links | tojson | forceescape }}">
{% for event_chatroom in event_chatrooms %}
{% set chatroom = event_chatroom.chatroom %}
{% set server = chatroom.server %}
<tr class="infoTR" style="vertical-align: baseline;">
<td class="infoTD">{{ chatroom.name }}</td>
<td class="infoTD">{{ server }}</td>
{% if 'description' in cols -%}
<td class="infoTD">{{ chatroom.description }}</td>
{% endif %}
{% if 'password' in cols %}
<td class="infoTD">
{% if chatroom.password %}
{% if event_chatroom.show_password %}
{{ chatroom.password }}
{% else %}
<i>{% trans %}Hidden{% endtrans %}</i>
{% endif %}
{% else %}
<i>{% trans %}None{% endtrans %}</i>
{% endif %}
</td>
{% endif %}
{% if chat_links %}
<td style="white-space: nowrap;">
<strong><a class="dropDownMenu highlight js-chat-join" href="#" data-server="{{ server }}" data-room="{{ chatroom.name }}">{% trans %}Join now!{% endtrans %}</a></strong>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<script>
eventChatInfo();
</script>

30
chat/indico_chat/views.py Normal file
View File

@ -0,0 +1,30 @@
# This file is part of Indico.
# Copyright (C) 2002 - 2014 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 __future__ import unicode_literals
from indico.core.plugins import WPJinjaMixinPlugin
from MaKaC.webinterface.pages.conferences import WPConferenceDefaultDisplayBase
class WPChatEventPage(WPJinjaMixinPlugin, WPConferenceDefaultDisplayBase):
def __init__(self, rh, conf, **kwargs):
WPConferenceDefaultDisplayBase.__init__(self, rh, conf, **kwargs)
self._conf = conf
self._aw = rh.getAW()
def _getBody(self, params):
return self._getPageContent(params)