diff --git a/chat/indico_chat/blueprint.py b/chat/indico_chat/blueprint.py index 9f1f77c..24e5763 100644 --- a/chat/indico_chat/blueprint.py +++ b/chat/indico_chat/blueprint.py @@ -14,6 +14,11 @@ # You should have received a copy of the GNU General Public License # along with Indico; if not, see . +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//chat-new', 'event-page', RHChatEventPage) diff --git a/chat/indico_chat/controllers.py b/chat/indico_chat/controllers.py new file mode 100644 index 0000000..6fb9a4f --- /dev/null +++ b/chat/indico_chat/controllers.py @@ -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 . + +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')) + diff --git a/chat/indico_chat/plugin.py b/chat/indico_chat/plugin.py index d4eedf9..0f2149e 100644 --- a/chat/indico_chat/plugin.py +++ b/chat/indico_chat/plugin.py @@ -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) diff --git a/chat/indico_chat/templates/event_page.html b/chat/indico_chat/templates/event_page.html new file mode 100644 index 0000000..256d43e --- /dev/null +++ b/chat/indico_chat/templates/event_page.html @@ -0,0 +1,54 @@ +

{% trans %}Chat Rooms{% endtrans %}

+ + + + + + + {% if 'description' in cols -%} + + {% endif %} + {% if 'password' in cols -%} + + {% endif %} + {% if chat_links %} + + {% endif %} + + + + {% for event_chatroom in event_chatrooms %} + {% set chatroom = event_chatroom.chatroom %} + {% set server = chatroom.server %} + + + + + {% if 'description' in cols -%} + + {% endif %} + {% if 'password' in cols %} + + {% endif %} + {% if chat_links %} + + {% endif %} + + {% endfor %} + +
{% trans %}Room{% endtrans %}{% trans %}Server{% endtrans %}{% trans %}Description{% endtrans %}{% trans %}Password{% endtrans %}{% trans %}Actions{% endtrans %}
{{ chatroom.name }}{{ server }}{{ chatroom.description }} + {% if chatroom.password %} + {% if event_chatroom.show_password %} + {{ chatroom.password }} + {% else %} + {% trans %}Hidden{% endtrans %} + {% endif %} + {% else %} + {% trans %}None{% endtrans %} + {% endif %} + + {% trans %}Join now!{% endtrans %} +
+ diff --git a/chat/indico_chat/views.py b/chat/indico_chat/views.py new file mode 100644 index 0000000..81ebb61 --- /dev/null +++ b/chat/indico_chat/views.py @@ -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 . + +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)