예제 #1
0
파일: controllers.py 프로젝트: javfg/indico
 def _process_form(self, form, **kwargs):
     saved = False
     if form.validate_on_submit():
         note = EventNote.get_or_create(self.object)
         is_new = note.id is None or note.is_deleted
         is_restored = is_new and note.is_deleted
         # TODO: get render mode from form data once it can be selected
         note.create_revision(RenderMode.html, form.source.data, session.user)
         is_changed = attrs_changed(note, 'current_revision')
         db.session.add(note)
         db.session.flush()
         if is_new:
             if is_restored:
                 signals.event.notes.note_restored.send(note)
             else:
                 signals.event.notes.note_added.send(note)
             logger.info('Note %s created by %s', note, session.user)
             self.event.log(EventLogRealm.participants, LogKind.positive, 'Minutes', 'Added minutes',
                            session.user, data=note.link_event_log_data)
         elif is_changed:
             signals.event.notes.note_modified.send(note)
             logger.info('Note %s modified by %s', note, session.user)
             self.event.log(EventLogRealm.participants, LogKind.change, 'Minutes', 'Updated minutes',
                            session.user, data=note.link_event_log_data)
         saved = is_new or is_changed
     return jsonify_template('events/notes/edit_note.html', form=form, object_type=self.object_type,
                             object=self.object, saved=saved, **kwargs)
예제 #2
0
 def _process(self):
     note = EventNote.get_for_linked_object(self.object, preload_event=False)
     if note is not None:
         note.delete(session.user)
         signals.event.notes.note_deleted.send(note)
         logger.info('Note %s deleted by %s', note, session.user)
         self.event.log(EventLogRealm.participants, EventLogKind.negative, 'Minutes', 'Removed minutes',
                        session.user, data=note.link_event_log_data)
     return redirect(self.event.url)
예제 #3
0
 def _process(self):
     note = EventNote.get_for_linked_object(self.object, preload_event=False)
     if note is not None:
         note.delete(session.user)
         signals.event.notes.note_deleted.send(note)
         logger.info('Note {} deleted by {}'.format(note, session.user))
         self.event.log(EventLogRealm.participants, EventLogKind.negative, 'Minutes',
                        'Removed minutes from {} {}'.format(self.object_type, self.object.getTitle()), session.user)
     return redirect(url_for('event.conferenceDisplay', self.event))
예제 #4
0
 def _process(self):
     note = EventNote.get_for_linked_object(self.object, preload_event=False)
     if note is not None:
         note.delete(session.user)
         signals.event.notes.note_deleted.send(note)
         logger.info("Note {} deleted by {}".format(note, session.user))
         self.event.log(
             EventLogRealm.participants,
             EventLogKind.negative,
             "Minutes",
             "Removed minutes",
             session.user,
             data=note.link_event_log_data,
         )
     return redirect(url_for("event.conferenceDisplay", self.event))
예제 #5
0
 def _process_form(self, form, **kwargs):
     saved = False
     if form.validate_on_submit():
         note = EventNote.get_or_create(self.object)
         is_new = note.id is None or note.is_deleted
         # TODO: get render mode from form data once it can be selected
         note.create_revision(RenderMode.html, form.source.data, session.user)
         is_changed = attrs_changed(note, "current_revision")
         db.session.add(note)
         db.session.flush()
         if is_new:
             signals.event.notes.note_added.send(note)
             logger.info("Note {} created by {}".format(note, session.user))
             self.event.log(
                 EventLogRealm.participants,
                 EventLogKind.positive,
                 "Minutes",
                 "Added minutes",
                 session.user,
                 data=note.link_event_log_data,
             )
         elif is_changed:
             signals.event.notes.note_modified.send(note)
             logger.info("Note {} modified by {}".format(note, session.user))
             self.event.log(
                 EventLogRealm.participants,
                 EventLogKind.change,
                 "Minutes",
                 "Updated minutes",
                 session.user,
                 data=note.link_event_log_data,
             )
         saved = is_new or is_changed
     return jsonify_template(
         "events/notes/edit_note.html",
         form=form,
         object_type=self.object_type,
         object=self.object,
         saved=saved,
         **kwargs
     )
예제 #6
0
 def _process_form(self, form, **kwargs):
     if form.validate_on_submit():
         note = EventNote.get_or_create(self.object)
         is_new = note.id is None or note.is_deleted
         # TODO: get render mode from form data once it can be selected
         note.create_revision(RenderMode.html, form.source.data, session.user)
         is_changed = attrs_changed(note, 'current_revision')
         db.session.add(note)
         db.session.flush()
         if is_new:
             signals.event.notes.note_added.send(note)
             logger.info('Note {} created by {}'.format(note, session.user))
             self.event.log(EventLogRealm.participants, EventLogKind.positive, 'Minutes',
                            'Added minutes to {} {}'.format(self.object_type, self.object.getTitle()), session.user)
         elif is_changed:
             signals.event.notes.note_modified.send(note)
             logger.info('Note {} modified by {}'.format(note, session.user))
             self.event.log(EventLogRealm.participants, EventLogKind.change, 'Minutes',
                            'Updated minutes for {} {}'.format(self.object_type, self.object.getTitle()),
                            session.user)
         return jsonify_data(flash=False)
     return jsonify_template('events/notes/edit_note.html', form=form, object_type=self.object_type,
                             object=self.object, **kwargs)