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


Python Searcher.search_courses方法代码示例

本文整理汇总了Python中searcher.Searcher.search_courses方法的典型用法代码示例。如果您正苦于以下问题:Python Searcher.search_courses方法的具体用法?Python Searcher.search_courses怎么用?Python Searcher.search_courses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在searcher.Searcher的用法示例。


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

示例1: __init__

# 需要导入模块: from searcher import Searcher [as 别名]
# 或者: from searcher.Searcher import search_courses [as 别名]
class SubmitNote:
    """The following can be used to submit a note"""

    def __init__(self, access_course, access_note, access_user, access_enrollment):
        """ to initialize a submit note instance """
        self.access_course = access_course
        self.access_note = access_note
        self.access_user = access_user
        self.access_enrollment = access_enrollment
        self.searcher = Searcher(self.access_course, self.access_note, self.access_user)
        self.userControl = userControl = UserControl(self.access_user, self.access_enrollment)

    """in later iterations we will add a userID, and a file directly fileID, for now they are the same as a note"""

    def submit_note(self, start_date, end_date, notes, user_id, department, number, section=None):
        possible_courses = self.searcher.search_courses(
            CourseSearchParams(department=department, number=number, section=section)
        )

        user = self.access_user.get_user(user_id)

        if len(possible_courses) == 1 and (
            user.role == User.ROLE_ADMIN
            or (
                user.role == User.ROLE_SUBMITTER
                and self.userControl.is_user_enrolled(user_id, possible_courses[0].id) == True
            )
        ):
            notesUploadFile = self.access_note.store_notes_file(notes.file, notes.filename)

            note = Note(start_date, end_date, notesUploadFile, possible_courses[0].id, user_id, datetime.now())
            """with our note object created, submit to our db."""
            """our note is submitted"""
            return self.access_note.insert_note(note)
        else:
            # was not able to submit note
            return None

    def update_note_file(self, note_id, user_id, notes):
        user = self.access_user.get_user(user_id)
        note = self.access_note.get_note(note_id)
        note.notes = self.access_note.store_notes_file(notes.file, notes.filename)
        note.modified_by = user_id
        note.modified_on = datetime.now()
        return self.access_note.update_note(note)

    def remove_note(self, note_id):
        return self.access_note.delete_note(note_id)
开发者ID:Hippocrates,项目名称:comp4350-classnotes,代码行数:50,代码来源:submit_note.py


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