當前位置: 首頁>>代碼示例>>Python>>正文


Python Course.query方法代碼示例

本文整理匯總了Python中models.Course.query方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.query方法的具體用法?Python Course.query怎麽用?Python Course.query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Course的用法示例。


在下文中一共展示了Course.query方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
 def get(self):
     logging.info("Starting to clean the datastore")
     courses = Course.query()
     for key in courses.iter(keys_only=True):
         files = File.query(ancestor=key)
         if files.get() is None:
             key.delete()
             logging.info("Deleting: " + key.string_id())
     logging.info("Done cleaning the datastore")
開發者ID:rosefiji,項目名稱:fiji-files,代碼行數:11,代碼來源:cron_handler.py

示例2: get

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
    def get(self):
#        self.addcourses()
        s = Source.query()

        if s.count(limit=1) == 0:
            self.redirect('/addsource')
        else:
            c = Course.query()

            context = {'courses': c, 'sources': s}
            self.render('classes.html', context)
開發者ID:joshz,項目名稱:testbulk,代碼行數:13,代碼來源:main.py

示例3: post

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
    def post(self):
        fields = ['source', 'number', 'dept', 'name', 'level', 'description']
        p = self.get_params_dict(fields)
        s = Source.query()
        c = Course.query()

        errors, p, kn = self.prepare_course(p, fields)
        context = {'errors': errors, 'sources': s, 'courses': c}

        if not errors:
            Course.get_or_insert(kn, **p)
            self.redirect('/')
        else:
            self.render('classes.html', context)
開發者ID:joshz,項目名稱:testbulk,代碼行數:16,代碼來源:main.py

示例4: export_courses

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
def export_courses():
    """
    export_courses

    get all courses from the database
    return all courses as a dictionary of course dictionaries
    """
    courses = Course.query().fetch()
    dictionary = {}

    for course in courses:
        dictionary[course.department + "" + course.number] = course.to_dict()

    return dictionary
開發者ID:joey9z,項目名稱:368_Project,代碼行數:16,代碼來源:main.py

示例5: check_db

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
def check_db():
    """ 
    check_db

    Compares the database entries with the entire list of courses
    Returns a list of courses that failed to insert into the database
    """
    
    with open("courses_2016.json") as data:
        data = data.read()

        courses = json.loads(data)
        course_keys_in_db = Course.query().fetch(keys_only=True)

        db_list = []
        failures = []

        for course in course_keys_in_db:
            db_list.append(course.id())
        failures = [i for i in courses if i.replace(" ","") not in db_list]

        return failures
開發者ID:joey9z,項目名稱:368_Project,代碼行數:24,代碼來源:main.py

示例6: get

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import query [as 別名]
 def get(self, dept):
     template = main.jinja_env.get_template("templates/main.html")
     values = {"departments": models.DEPARTMENT_NAMES, "types": models.FILE_TYPES}
     values["dept"] = dept
     termcodes = []
     this_year = date.today().year + 1
     this_month = date.today().month
     for year in range(this_year, this_year - 3, -1):
         yearcode = year * 100
         for quarter, value in [('Spring', 30), ("Winter", 20), ("Fall", 10)]:
             termcodes.append({"term":quarter + " " + str(year - 1) + "-" + str(year) ,"code":yearcode + value})
     values["termcodes"] = termcodes
     if 1 <= this_month <= 2:
         # Winter Quarter
         values["termcodes"] = termcodes[4:]
     elif 3 <= this_month <= 6:
         # Spring Quarter
         values["termcodes"] = termcodes[3:]
     elif 7 <= this_month <= 8:
         # Summer
         pass
     elif 9 <= this_month <= 11:
         # Fall Quarter
         values["termcodes"] = termcodes[2:]
     elif this_month == 12:
         # Winter Quarter
         values["termcodes"] = termcodes[1:]
     course_keys = Course.query(Course.department == dept)
     courses = []
     files = {}
     for course_key in course_keys.iter(keys_only=True):
         courses.append(course_key.string_id())
         files[course_key.string_id()] = File.query(ancestor=course_key)
     courses.sort()
     values["courses"] = courses
     values["files"] = files
     self.response.out.write(template.render(values))
開發者ID:rosefiji,項目名稱:fiji-files,代碼行數:39,代碼來源:main_handler.py


注:本文中的models.Course.query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。