diff --git a/chat/indico_chat/controllers/event_mgmt.py b/chat/indico_chat/controllers/event_mgmt.py index ac698d6..3202482 100644 --- a/chat/indico_chat/controllers/event_mgmt.py +++ b/chat/indico_chat/controllers/event_mgmt.py @@ -71,9 +71,10 @@ class RHChatManageEvent(RHChatManageEventBase): _eager='chatroom.events').all() chatroom_filter = (~Chatroom.id.in_(x.chatroom_id for x in chatrooms)) if chatrooms else True available_chatrooms = Chatroom.find_all(Chatroom.created_by_id == int(session.user.id), chatroom_filter) + logs_enabled = current_plugin.settings.get('log_url') return WPChatEventMgmt.render_template('manage_event.html', self._conf, event_chatrooms=chatrooms, event=self.event, chat_links=current_plugin.settings.get('chat_links'), - available_chatrooms=available_chatrooms) + available_chatrooms=available_chatrooms, logs_enabled=logs_enabled) class RHChatManageEventModify(RHEventChatroomMixin, RHChatManageEventBase): @@ -108,16 +109,21 @@ class RHChatManageEventRefresh(RHEventChatroomMixin, RHChatManageEventBase): RHEventChatroomMixin._checkParams(self) def _process(self): + if self.chatroom.custom_server: + return jsonify(result='') + config = get_room_config(self.chatroom.jid) if config is None: if not room_exists(self.chatroom.jid): return jsonify(result='not-found') raise IndicoError(_('Unexpected result from Jabber server')) + changed = False for key, value in config.iteritems(): if getattr(self.chatroom, key) != value: changed = True setattr(self.chatroom, key, value) + return jsonify(result='changed' if changed else '') diff --git a/chat/indico_chat/forms.py b/chat/indico_chat/forms.py index ca5f9e8..585c5d7 100644 --- a/chat/indico_chat/forms.py +++ b/chat/indico_chat/forms.py @@ -58,11 +58,12 @@ class AddChatroomForm(EditChatroomForm): raise ValidationError(_('Could not convert name to a jabber ID')) if Chatroom.find_first(jid_node=jid, custom_server=self.custom_server.data): raise ValidationError(_('A room with this name already exists')) - tmp_room = Chatroom(jid_node=jid, custom_server=self.custom_server.data) - if room_exists(tmp_room.jid): - raise ValidationError(_('A room with this name/JID already exists on the Jabber server ({0})').format( - tmp_room.jid - )) + if not self.custom_server.data: + tmp_room = Chatroom(jid_node=jid) + if room_exists(tmp_room.jid): + raise ValidationError(_('A room with this name/JID already exists on the Jabber server ({0})').format( + tmp_room.jid + )) @generated_data def jid_node(self): diff --git a/chat/indico_chat/static/js/chat.js b/chat/indico_chat/static/js/chat.js index 6a0ec8b..3487f7a 100644 --- a/chat/indico_chat/static/js/chat.js +++ b/chat/indico_chat/static/js/chat.js @@ -58,7 +58,12 @@ var $this = $(this); var msg = $T('Do you really want to remove this chatroom from the event?'); if ($this.data('numEvents') == 1) { - msg += '
' + $T('Since it is only used in this event, it will be deleted from the Jabber server, too!'); + msg += '
'; + if ($this.data('customServer')) { + msg += $T('Since it is on an external server, it will not be deleted on that server.'); + } else { + msg += $T('Since it is only used in this event, it will be deleted from the Jabber server, too!'); + } } new ConfirmPopup($T('Delete this chatroom?'), msg, function(confirmed) { if (!confirmed) { diff --git a/chat/indico_chat/templates/manage_event.html b/chat/indico_chat/templates/manage_event.html index 893c26d..51b0c8d 100644 --- a/chat/indico_chat/templates/manage_event.html +++ b/chat/indico_chat/templates/manage_event.html @@ -10,14 +10,20 @@ {{ chatroom.name }} - {% trans %}Show Details{% endtrans %} - - - {% trans %}Logs{% endtrans %} + {% if logs_enabled and not chatroom.custom_server %} + - + {% trans %}Logs{% endtrans %} + {% endif %} - {% trans %}Edit{% endtrans %} + {% if not chatroom.custom_server %} + - + {% trans %}Refresh{% endtrans %} + {% endif %} - - {% trans %}Refresh{% endtrans %} - - - {% trans %}Remove{% endtrans %} + + {%- trans %}Remove{% endtrans -%} + {% if chat_links %} - {% trans %}Join now!{% endtrans %} diff --git a/chat/indico_chat/xmpp.py b/chat/indico_chat/xmpp.py index 2d951be..75fd523 100644 --- a/chat/indico_chat/xmpp.py +++ b/chat/indico_chat/xmpp.py @@ -37,6 +37,9 @@ WHITESPACE = re.compile(r'\s+') def create_room(room): """Creates a MUC room on the XMPP server.""" + if room.custom_server: + return + def _create_room(xmpp): muc = xmpp.plugin['xep_0045'] muc.joinMUC(room.jid, xmpp.requested_jid.user) @@ -49,6 +52,9 @@ def create_room(room): def update_room(room): """Updates a MUC room on the XMPP server.""" + if room.custom_server: + return + def _update_room(xmpp): muc = xmpp.plugin['xep_0045'] muc.joinMUC(room.jid, xmpp.requested_jid.user) @@ -61,6 +67,9 @@ def update_room(room): def delete_room(room, reason=''): """Deletes a MUC room from the XMPP server.""" + if room.custom_server: + return + def _delete_room(xmpp): muc = xmpp.plugin['xep_0045'] muc.destroy(room.jid, reason=reason)