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


Python Course.all方法代碼示例

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


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

示例1: setUp

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()

        # should all return None, because this is simply creating data and is all meant to be correct
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teacher', 't'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'teachertwo', 'ttwo'))
        self.assertIsNone(User.register(None, '[email protected]', 'pwd', 'pwd', 'student', 's'))

        self.teacher = User.all().filter('email =', '[email protected]').get()
        self.teacher2 = User.all().filter('email =', '[email protected]').get()
        self.student = User.all().filter('email =', '[email protected]' ).get()

        self.assertIsNotNone(self.teacher)
        self.assertIsNone(self.teacher.make_teacher())
        self.assertIsNotNone(self.teacher2)
        self.assertIsNone(self.teacher2.make_teacher())

        self.assertIsNone(Course.create(self.teacher, 'public', ''))
        self.public = Course.all().filter('name =', 'Public').get()
        self.assertIsNotNone(self.public)
        self.assertIsNone(Course.create(self.teacher, 'private', 'on'))
        self.private = Course.all().filter('name =', 'Private').get()
        self.assertIsNotNone(self.private)
開發者ID:matts1,項目名稱:MajorWork-appengine,代碼行數:27,代碼來源:basetest.py

示例2: updateSummary

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

    logging.info("UPDATING SUMMARY")
    query = Summary.all()
    db.delete(query)
    courses = Course.all()
    items = []
    
    for course in courses:
        item = {}
        item['name'] = course.name
        item['id'] = course.cid
        item['hasSept'] = course.hasSeptemberResults
        item['hasFebr'] = course.hasFebruaryResults
        item['hasJune'] = course.hasJuneResults
        item['recent'] = course.nTimesUpdated
        item['addedJune'] = str(course.added_june)
        item['addedSept'] = str(course.added_sept)
        item['addedFebr'] = str(course.added_febr)
        items.append(item)
    
    summary = Summary()
    summary.courses = simplejson.dumps(items)
    summary.put()
    logging.info("FINISHED UPDATING SUMMARY")
開發者ID:ihasb33r,項目名稱:dtps-students,代碼行數:27,代碼來源:update.py

示例3: test_creation

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
 def test_creation(self):
     self.assertIsNotNone(
         Course.create(self.teacher, '', ''),
         'Empty course name'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'pub', ''),
         'Create public course'
     )
     self.assertIsNotNone(
         Course.create(self.teacher, 'Pub', ''),
         'Recreate public course (bad)'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'Pub2', None),
         'Create public course'
     )
     self.assertIsNone(
         Course.create(self.teacher, 'pvt', 'on'),
         'Create private course'
     )
     for name, private in [('Pvt', True), ('Pub', False), ('Pub2', False)]:
         course = Course.all().filter('name =', name).get()
         self.assertIsNotNone(course)
         if private:
             self.assertIsNotNone(course.code)
         else:
             self.assertIsNone(course.code)
         self.assertEqual(course.teacher.email, self.teacher.email)
開發者ID:matts1,項目名稱:MajorWork-appengine,代碼行數:31,代碼來源:courses.py

示例4: get

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
    def get(self):
        from models import *

        from google.appengine.ext import db
        db.delete(Course.all())
        db.delete(Offerings.all())

        import re
        rx_department = re.compile(r'[A-Z]+')
        import csv
        reader = csv.DictReader(open('resources/dump.csv'))
        try:
            for course in reader:
                name = course['name']
                number = course['number']
                description = course['description'][:500]
                match = rx_department.match(number)
                department = number
                if match:
                    department = match.group(0)
                entry = Course(name=name, number=number, description=description, department=department)
                entry.put()

                for item in ['winter', 'spring', 'fall', 'summer']:
                    if 1 < len(course[item]):
                        offering = Offerings(course=entry, offered=item)
                        offering.put()
        except KeyError, e:
            pass
開發者ID:sampwing,項目名稱:cmpe231_project,代碼行數:31,代碼來源:main.py

示例5: get

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
    def get(self):
        query_text = cgi.escape(self.request.get("query"))
        q = Course.all().search(query_text).fetch(50)
        courses = []
        for course in q:
            coursevals = {'courseName': course.courseName,
                          'lat': course.latitude,
                          'lon': course.longitude,
                          'numholes': course.numberHoles,
                          'id': course.courseId,
                          'description': course.description.replace('\n', '<br />'),
                          'city': course.city,
                          'state': course.state,
                          'zip' : course.zip,
                          'teeType': course.teeType,
                          'basketType': course.basketType,
                          'holesLT300': course.holesLT300,
                          'holesBW300400': course.holesBW300400,
                          'holesGT400': course.holesGT400 }
            courses.append(coursevals)

        template_vals = {'courses': courses,
                         'query_text': query_text,
                         'gmaps_api_key': GMAPS_API_KEY,
                         'facebook': self.get_facebook() }
        path = os.path.join(os.path.dirname(__file__), 'templates/searchpage.html')
        self.response.out.write(template.render(path, template_vals))
開發者ID:posborne,項目名稱:discgolfhub.com,代碼行數:29,代碼來源:discgolfhub.py

示例6: post

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
    def post(self):
        from models import Course, Progress
        user = users.get_current_user()
        course_numbers = (self.request.get_all('courses[]'))
        current_user = User.all().filter('email =', user.email()).get()
        myclasses = []
        myclasses2 = []
        for classy in course_numbers:
            test = [x.strip() for x in classy.split(',')]
            myclasses.append(test)
        for classy in myclasses:
            coursename = classy[0].replace(" ", "")
            coursetime = classy[1]
            myclasses2.append((coursename,coursetime))

        # [u'Fall12,PHYS 5A,Fall12,PHYS 5L,Fall12,CMPS 12B,Fall12,CMPS 12L,Fall12,CMPE 16,',
        #  u'Winter13,HCI 131 ,Winter13,CMPS 101 ,Winter13,DANM 250,Winter13,Math 21 ,',
        #  u'Spring13,PHYSC 5C,Spring13,PHYSC 5L,Spring13,AMS 131,',
        #  u'Summer13,CMPS109,Summer13,Math 24,']
        # myclasses = filter(None, myclasses)
        # test = [x.strip() for x in myclasses[0].split(',')]
        progCheck = Progress.all().filter('user =', current_user).fetch(limit=1000)
        db.delete(progCheck)

        for course_number in myclasses:

            coursename = course_number[0].replace(" ", "")
            quarter = course_number[1][:-2]
            year = int(course_number[1][-2:])
            course = Course.all().filter('number =',coursename).get()
            progress = Progress(user=current_user, course=course, completed=True, quarter=quarter, year=year)
            if (course != None):
                progress.put()


            # if (course != None):
            #     quarter = course_number[1][:-2]
            #     year = int(course_number[1][-2:])
            #     # need to figure out how to query for specific course
            #     # so that we can remove it if neccessary
            #     progress = Progress(user=current_user, course=course, completed=True, quarter=quarter, year=year)
            #     progCheck = Progress.all().filter('user =', current_user).filter('course =', course).fetch(limit=20)
            #     # if (progCheck.quarter != quarter):
            #     #     progress.put()
            #     #     #then remove the old class here too....
                log = ""
            #     if not progCheck:
            #         progress.put()
            #         log = "progCheck==None , " + str(course_number)
            #     else:
            #         if not any(quarter == chances.quarter for chances in progCheck):
            #             progress.put()
            #         # for chances in progCheck:
            #         #     if (chances.quarter != quarter):
            #         #         itsHere


                # progress.put()
        self.response.write(log + str(myclasses2));
開發者ID:sampwing,項目名稱:cmpe231_project,代碼行數:61,代碼來源:main.py

示例7: join_course

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
 def join_course(self, course_id, code=None):
     from models import Course, UserCourse  # do this because users.py & courses.py import each other
     if code is not None:
         course = Course.all().filter('code =', code).get()
     elif course_id is not None:
         course = Course.get_by_id(course_id)
     else:
         return ''
     if course is None:
         return 'Invalid code'
     if UserCourse.all().filter('user =', self).filter('course =', course).get():
         return 'You are already in the course'
     if course.teacher.key().id() == self.key().id():
         return 'You teach that course'
     UserCourse(user=self, course=course).put()
     return course
開發者ID:matts1,項目名稱:MajorWork-appengine,代碼行數:18,代碼來源:users.py

示例8: forum_discussions_page

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
def forum_discussions_page(request, page):
  discussions=Course.all()
  p=Paginator(discussions, settings.ITEMS_PER_PAGE)
  return render_to_response('tasteofhome/discussions.html', {'discussions': discussions, 'categories': forum_categories(), 'paginator': p})
開發者ID:motord,項目名稱:Taste,代碼行數:6,代碼來源:views.py

示例9: courses_taught

# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import all [as 別名]
 def courses_taught(self):
     from models import Course  # do this because users.py & courses.py import each other
     return Course.all().filter('teacher =', self)
開發者ID:matts1,項目名稱:MajorWork-appengine,代碼行數:5,代碼來源:users.py


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