當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。