当前位置: 首页>>代码示例>>Python>>正文


Python notes.EventNote类代码示例

本文整理汇总了Python中indico.modules.events.notes.models.notes.EventNote的典型用法代码示例。如果您正苦于以下问题:Python EventNote类的具体用法?Python EventNote怎么用?Python EventNote使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了EventNote类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: migrate_event_notes

    def migrate_event_notes(self):
        self.print_step('migrating event notes')

        janitor_user = User.get_one(self.janitor_user_id)
        self.print_msg('Using janitor user {}'.format(janitor_user), always=True)
        for event, obj, minutes, special_prot in committing_iterator(self._iter_minutes()):
            if special_prot:
                self.print_warning(
                    cformat('%{yellow!}{} minutes have special permissions; skipping them').format(obj),
                    event_id=event.id
                )
                continue
            path = get_archived_file(minutes, self.archive_dirs)[1]
            if path is None:
                self.print_error(cformat('%{red!}{} minutes not found on disk; skipping them').format(obj),
                                 event_id=event.id)
                continue
            with open(path, 'r') as f:
                data = convert_to_unicode(f.read()).strip()
            if not data:
                self.print_warning(cformat('%{yellow}{} minutes are empty; skipping them').format(obj),
                                   always=False, event_id=event.id)
                continue
            note = EventNote(linked_object=obj)
            note.create_revision(RenderMode.html, data, janitor_user)
            db.session.add(note)
            if not self.quiet:
                self.print_success(cformat('%{cyan}{}').format(obj), event_id=event.id)
开发者ID:OmeGak,项目名称:indico,代码行数:28,代码来源:event_notes.py

示例2: _getParams

 def _getParams(self):
     super(NoteExportHook, self)._getParams()
     event = self._obj = Event.get(self._pathParams['event_id'], is_deleted=False)
     if event is None:
         raise HTTPAPIError('No such event', 404)
     session_id = self._pathParams.get('session_id')
     if session_id:
         self._obj = Session.query.with_parent(event).filter_by(id=session_id).first()
         if self._obj is None:
             raise HTTPAPIError("No such session", 404)
     contribution_id = self._pathParams.get('contribution_id')
     if contribution_id:
         contribution = self._obj = (Contribution.query.with_parent(event)
                                     .filter_by(id=contribution_id, is_deleted=False)
                                     .first())
         if contribution is None:
             raise HTTPAPIError("No such contribution", 404)
         subcontribution_id = self._pathParams.get('subcontribution_id')
         if subcontribution_id:
             self._obj = SubContribution.query.with_parent(contribution).filter_by(id=subcontribution_id,
                                                                                   is_deleted=False).first()
             if self._obj is None:
                 raise HTTPAPIError("No such subcontribution", 404)
     self._note = EventNote.get_for_linked_object(self._obj, preload_event=False)
     if self._note is None or self._note.is_deleted:
         raise HTTPAPIError("No such note", 404)
开发者ID:DirkHoffmann,项目名称:indico,代码行数:26,代码来源:api.py

示例3: clone

 def clone(self, new_event, options):
     from indico.modules.events.notes.models.notes import EventNote
     if 'notes' not in options:
         return
     for old_note in self.find_notes():
         revision = old_note.current_revision
         new_note = EventNote(link_type=old_note.link_type,
                              event_id=new_event.id,
                              session_id=old_note.session_id,
                              contribution_id=old_note.contribution_id,
                              subcontribution_id=old_note.subcontribution_id)
         new_note.create_revision(render_mode=revision.render_mode,
                                  source=revision.source,
                                  user=revision.user)
         db.session.add(new_note)
         db.session.flush()
         logger.info('Added note during event cloning: {}'.format(new_note))
开发者ID:,项目名称:,代码行数:17,代码来源:

示例4: _process

 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)
开发者ID:bkolobara,项目名称:indico,代码行数:9,代码来源:controllers.py

示例5: _process

 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))
开发者ID:maaceroo,项目名称:indico,代码行数:9,代码来源:controllers.py

示例6: test_get_or_create

def test_get_or_create(db, dummy_user, dummy_event, create_event):
    note = EventNote.get_or_create(dummy_event)
    assert note is not None
    assert not inspect(note).persistent  # new object
    note.create_revision(RenderMode.html, 'test', dummy_user)
    note.is_deleted = True
    db.session.flush()
    # get deleted one
    assert EventNote.get_or_create(dummy_event) == note
    assert inspect(note).persistent
    note.is_deleted = False
    db.session.flush()
    # same if it's not deleted
    assert EventNote.get_or_create(dummy_event) == note
    assert inspect(note).persistent
    # other event should create a new one
    other = EventNote.get_or_create(create_event(123))
    other.create_revision(RenderMode.html, 'test', dummy_user)
    assert other != note
    assert not inspect(other).persistent
开发者ID:maaceroo,项目名称:indico,代码行数:20,代码来源:notes_test.py

示例7: _process

 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))
开发者ID:mdoucet,项目名称:indico,代码行数:15,代码来源:controllers.py

示例8: _process_form

 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
     )
开发者ID:mdoucet,项目名称:indico,代码行数:41,代码来源:controllers.py

示例9: _process_form

 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)
开发者ID:maaceroo,项目名称:indico,代码行数:23,代码来源:controllers.py

示例10: _getParams

 def _getParams(self):
     super(NoteExportHook, self)._getParams()
     event = self._obj = ConferenceHolder().getById(self._pathParams['event_id'], True)
     if event is None:
         raise HTTPAPIError('No such event', 404)
     session_id = self._pathParams.get('session_id')
     if session_id:
         session = self._obj = event.getSessionById(session_id)
         if session is None:
             raise HTTPAPIError("No such session", 404)
     contribution_id = self._pathParams.get('contribution_id')
     if contribution_id:
         contribution = self._obj = session.getContributionById(contribution_id)
         if contribution is None:
             raise HTTPAPIError("No such contribution", 404)
     subcontribution_id = self._pathParams.get('subcontribution_id')
     if subcontribution_id:
         subcontribution = self._obj = contribution.getSubContributionById(subcontribution_id)
         if subcontribution is None:
             raise HTTPAPIError("No such subcontribution", 404)
     self._note = EventNote.get_for_linked_object(self._obj)
     if self._note is None or self._note.is_deleted:
         raise HTTPAPIError("No such note", 404)
开发者ID:maaceroo,项目名称:indico,代码行数:23,代码来源:api.py

示例11: test_get_for_linked_object_preload

def test_get_for_linked_object_preload(note, dummy_user, mocker, preload):
    note.create_revision(RenderMode.html, 'test', dummy_user)
    assert EventNote.get_for_linked_object(note.linked_object, preload_event=preload)
    query = mocker.patch.object(EventNote, 'query', new=PropertyMock())
    EventNote.get_for_linked_object(note.linked_object)
    assert query.called == (not preload)
开发者ID:maaceroo,项目名称:indico,代码行数:6,代码来源:notes_test.py

示例12: has_data

 def has_data(self):
     return EventNote.has_rows()
开发者ID:MichelCordeiro,项目名称:indico,代码行数:2,代码来源:event_notes.py

示例13: _delete_event_notes

def _delete_event_notes(event, **kwargs):
    from indico.modules.events.notes.models.notes import EventNote
    EventNote.find(event_id=event.id).update({EventNote.is_deleted: True})
    db.session.expire_all()
开发者ID:,项目名称:,代码行数:4,代码来源:

示例14: has_note

 def has_note(self):
     return EventNote.get_for_linked_object(self, preload_event=self.PRELOAD_EVENT_NOTES) is not None
开发者ID:bkolobara,项目名称:indico,代码行数:2,代码来源:notes.py

示例15: find_notes

 def find_notes(self):
     from indico.modules.events.notes.models.notes import EventNote
     return EventNote.find(event_id=self.event.id, is_deleted=False)
开发者ID:,项目名称:,代码行数:3,代码来源:


注:本文中的indico.modules.events.notes.models.notes.EventNote类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。