本文整理汇总了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)
示例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")
示例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)
示例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
示例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))
示例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));
示例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
示例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})
示例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)