Esempio n. 1
0
 def _process(self):
     form = AddChatroomForm(obj=FormDefaults(name=self.event.title),
                            date=self.event.start_dt_local)
     if form.validate_on_submit():
         chatroom = Chatroom(created_by_user=session.user)
         event_chatroom = ChatroomEventAssociation(event=self.event,
                                                   chatroom=chatroom)
         form.populate_obj(event_chatroom,
                           fields=form.event_specific_fields)
         form.populate_obj(chatroom, skip=form.event_specific_fields)
         chatroom.jid_node = form.jid_node.data
         db.session.add_all((chatroom, event_chatroom))
         db.session.flush()
         create_room(chatroom)
         notify_created(chatroom, self.event, session.user)
         self.event.log(EventLogRealm.management, EventLogKind.positive,
                        'Chat',
                        'Chatroom created: {}'.format(chatroom.name),
                        session.user)
         flash(_('Chatroom created'), 'success')
         return jsonify_data(flash=False)
     return jsonify_template('manage_event_edit.html',
                             render_plugin_template,
                             form=form,
                             event=self.event)
Esempio n. 2
0
 def inject_event_header(self, event, **kwargs):
     chatrooms = ChatroomEventAssociation.find_for_event(event).all()
     if not chatrooms:
         return ''
     how_to_connect = self.settings.get('how_to_connect')
     return render_plugin_template('event_header.html', event=event, event_chatrooms=chatrooms,
                                   how_to_connect=how_to_connect, chat_links=self.settings.get('chat_links'))
 def run(self, new_event, cloners, shared_data):
     for old_event_chatroom in self.old_event.chatroom_associations:
         event_chatroom = ChatroomEventAssociation(
             chatroom=old_event_chatroom.chatroom,
             hidden=old_event_chatroom.hidden,
             show_password=old_event_chatroom.show_password)
         new_event.chatroom_associations.append(event_chatroom)
     db.session.flush()
Esempio n. 4
0
 def _process(self):
     chatrooms = ChatroomEventAssociation.find_for_event(self._conf).all()
     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'))
Esempio n. 5
0
 def _process(self):
     chatrooms = ChatroomEventAssociation.find_for_event(self.event, include_hidden=True,
                                                         _eager='chatroom.events').all()
     logs_enabled = current_plugin.settings.get('log_url')
     attach_form = self._get_attach_form()
     if not attach_form.chatroom._get_object_list():
         attach_form = None
     return WPChatEventMgmt.render_template('manage_event.html', self.event, event_chatrooms=chatrooms,
                                            chat_links=current_plugin.settings.get('chat_links'),
                                            logs_enabled=logs_enabled, attach_form=attach_form)
Esempio n. 6
0
 def _process(self):
     chatrooms = ChatroomEventAssociation.find_for_event(self.event, include_hidden=True,
                                                         _eager='chatroom.events').all()
     logs_enabled = current_plugin.settings.get('log_url')
     attach_form = self._get_attach_form()
     if not attach_form.chatroom._get_object_list():
         attach_form = None
     return WPChatEventMgmt.render_template('manage_event.html', self._conf, event_chatrooms=chatrooms,
                                            event=self.event, chat_links=current_plugin.settings.get('chat_links'),
                                            logs_enabled=logs_enabled, attach_form=attach_form)
Esempio n. 7
0
 def _process(self):
     form = self._get_attach_form()
     if form.validate_on_submit():
         event_chatroom = ChatroomEventAssociation(event_id=self.event_id, chatroom=form.chatroom.data)
         db.session.add(event_chatroom)
         notify_attached(form.chatroom.data, self.event, session.user)
         flash(_('Chatroom added'), 'success')
         self.event.log(EventLogRealm.management, EventLogKind.positive, 'Chat',
                        'Chatroom attached: {}'.format(event_chatroom.chatroom.name), session.user)
     return redirect(url_for_plugin('.manage_rooms', self.event))
 def inject_event_header(self, event, **kwargs):
     chatrooms = ChatroomEventAssociation.find_for_event(event).all()
     if not chatrooms:
         return ''
     how_to_connect = self.settings.get('how_to_connect')
     return render_plugin_template(
         'event_header.html',
         event=event,
         event_chatrooms=chatrooms,
         how_to_connect=how_to_connect,
         chat_links=self.settings.get('chat_links'))
Esempio n. 9
0
 def _process(self):
     chatrooms = ChatroomEventAssociation.find_for_event(self.event).all()
     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.event,
         event_chatrooms=chatrooms,
         cols=cols,
         chat_links=current_plugin.settings.get('chat_links'))
Esempio n. 10
0
    def migrate_chatrooms(self):
        print cformat('%{white!}migrating chatrooms')
        default_server = ChatPlugin.settings.get('muc_server')
        chatrooms = {}
        for old_room in committing_iterator(
                self.chat_root['indexByID']._data.itervalues()):
            has_custom_server = not old_room._createdInLocalServer and old_room._host != default_server
            custom_server = convert_to_unicode(
                old_room._host) if has_custom_server else ''
            identifier = (custom_server, old_room._name.lower())
            room = chatrooms.get(identifier)
            if room:
                print cformat(
                    '- %{cyan}{}   %{yellow!}DUPLICATE%{reset}').format(
                        room.name)
            else:
                user = User.get(int(old_room._owner.id)) or User.get(
                    Config.getInstance().getJanitorUserId())
                room = Chatroom(
                    jid_node=convert_to_unicode(old_room._name.lower()),
                    name=convert_to_unicode(old_room._name),
                    description=convert_to_unicode(old_room._description),
                    password=convert_to_unicode(old_room._password),
                    custom_server=custom_server,
                    created_by_user=user,
                    created_dt=old_room._creationDate,
                    modified_dt=old_room._modificationDate)
                chatrooms[identifier] = room
                db.session.add(room)
                print cformat('- %{cyan}{}').format(room.name)
                if room.custom_server:
                    print cformat(
                        '  %{blue!}Custom server:%{reset} {}').format(
                            room.custom_server)

            events = set()
            for event in old_room._conferences:
                assoc = ChatroomEventAssociation(
                    event_id=int(event),
                    chatroom=room,
                    hidden=not old_room._showRoom,
                    show_password=old_room._showPass)
                db.session.add(assoc)
                events.add(assoc.event_id)
            if events:
                print cformat('  %{blue!}Events:%{reset} {}').format(', '.join(
                    map(unicode, events)))
            else:
                print cformat('  %{yellow!}no events%{reset}')
Esempio n. 11
0
 def _process(self):
     form = AddChatroomForm(obj=FormDefaults(name=to_unicode(self.event.title)),
                            date=self.event.getAdjustedStartDate())
     if form.validate_on_submit():
         chatroom = Chatroom(created_by_user=session.user)
         event_chatroom = ChatroomEventAssociation(event_id=self.event_id, chatroom=chatroom)
         form.populate_obj(event_chatroom, fields=form.event_specific_fields)
         form.populate_obj(chatroom, skip=form.event_specific_fields)
         chatroom.jid_node = form.jid_node.data
         db.session.add_all((chatroom, event_chatroom))
         db.session.flush()
         create_room(chatroom)
         notify_created(chatroom, self.event, session.user)
         self.event.log(EventLogRealm.management, EventLogKind.positive, 'Chat',
                        'Chatroom created: {}'.format(chatroom.name), session.user)
         flash(_('Chatroom created'), 'success')
         return redirect(url_for_plugin('.manage_rooms', self.event))
     return WPChatEventMgmt.render_template('manage_event_edit.html', self._conf, form=form, event=self.event)
Esempio n. 12
0
 def event_deleted(self, event, **kwargs):
     for event_chatroom in ChatroomEventAssociation.find_for_event(
             event, include_hidden=True):
         chatroom_deleted = event_chatroom.delete()
         notify_deleted(event_chatroom.chatroom, event, None,
                        chatroom_deleted)
Esempio n. 13
0
 def event_deleted(self, event, **kwargs):
     for event_chatroom in ChatroomEventAssociation.find_for_event(event, include_hidden=True):
         chatroom_deleted = event_chatroom.delete()
         notify_deleted(event_chatroom.chatroom, event, None, chatroom_deleted)
Esempio n. 14
0
 def extend_event_menu(self, sender, **kwargs):
     return MenuEntryData(_('Chat Rooms'), 'chatrooms', 'chat.event_page', position=-1,
                          visible=lambda event: bool(ChatroomEventAssociation.find_for_event(event).count()))
Esempio n. 15
0
 def _checkParams(self):
     self.event_chatroom = ChatroomEventAssociation.find_one(event_id=self.event_id,
                                                             chatroom_id=request.view_args['chatroom_id'])
     self.chatroom = self.event_chatroom.chatroom