def validate_name(self, field): jid = generate_jid(field.data, self._date) if not jid: # This error is not very helpful to a user, but it is extremely unlikely - only if he uses a name # which does not contain a single char usable in a JID 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')) 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 ))
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) if changed: self.event.log(EventLogRealm.management, EventLogKind.change, 'Chat', 'Chatroom updated during refresh: {}'.format(self.chatroom.name), session.user) return jsonify(result='changed' if changed else '')