本文整理汇总了Python中utilities.render_template函数的典型用法代码示例。如果您正苦于以下问题:Python render_template函数的具体用法?Python render_template怎么用?Python render_template使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_template函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render
def render(self):
if self.debug:
return render_template('index_debug.html',
lti_dump=g.lti.dump_all())
if g.lti.is_instructor():
return render_template('index_instructor.html')
return render_template('index_student.html')
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:8,代码来源:index.py
示例2: answerQuestion
def answerQuestion(self, uID, qID, qText, timerD, questionStartTime):
if answer.AnswerModel.check_answer_exists(uID, qID):
aID = answer.AnswerModel.get_answer_id(uID, qID)
if self.timeLeft(timerD, questionStartTime):
return render_template('answer.html', questionID=qID, userID=uID, questionText=qText, timerDuration=timerD, date=time.mktime(questionStartTime.timetuple()), go="true")
else:
return render_template('answer.html', questionID=qID, userID=uID, questionText=qText, timerDuration=timerD, date=time.mktime(questionStartTime.timetuple()), go="false")
else:
#answer.AnswerModel.save(qID, uID, "")
return render_template('answer.html', questionID=qID, userID=uID, questionText=qText, timerDuration=timerD, date=time.mktime(questionStartTime.timetuple()), go="true")
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:10,代码来源:answer.py
示例3: render
def render(self):
if self.debug:
return render_template('index_debug.html',
lti_dump=g.lti.dump_all())
if g.lti.is_instructor():
return render_template('question_list.html')
else:
UserModel.save(g.lti.get_user_id(), g.lti.get_user_name())
return render_template('index_student.html')
开发者ID:klaplong,项目名称:SWE_2013_Groep2,代码行数:10,代码来源:index.py
示例4: get_list_asked
def get_list_asked():
"""Retrieves questions asked by the user currently logged in."""
if g.lti.is_instructor():
# TODO: pagination, etc..... same goes for get_questions
session.commit()
return render_template('question_list.html',
questions=session.query(Question).filter_by(user_id=g.lti.get_user_id() ) )
else:
session.commit()
return render_template('question_list.html',
questions=session.query(Question).filter_by(user_id=g.lti.get_user_id() ) )
开发者ID:matthijsbos,项目名称:SWE_2013_Groep2,代码行数:11,代码来源:question.py
示例5: get_list_to_answer
def get_list_to_answer():
"""Retrieves questions to be answered by the instructor (all questions )"""
if g.lti.is_instructor():
# TODO: pagination, etc..... same goes for get_questions
session.commit()
return render_template('answer_student_questions.html',
questions=session.query(Question).\
filter(Question.course_id == g.lti.get_course_id() ).\
filter(Question.course_id != g.lti.get_user_id() )) #Filter questions by instructor
#Only instructors can answer these questions
else:
return render_template('access_restricted.html')
开发者ID:matthijsbos,项目名称:SWE_2013_Groep2,代码行数:13,代码来源:question.py
示例6: renderanswerform
def renderanswerform():
try:
questionid = int(request.values['question_id'])
question = Question.by_id(questionid)
except:
return abort(404)
return render_template('student_answer.html', question = question)
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:7,代码来源:answer.py
示例7: post
def post(self):
t_values = {}
current_link_id = self.request.POST['current_link_id']
link_title = self.request.POST['link_title']
link_target = self.request.POST['link_target']
link_sequence = self.request.POST['link_sequence']
logging.info("LinkManager post: current_link_id = %s, link_title = %s, link_target = %s, link_sequence = %s" % (current_link_id, link_title, 'link_target', 'link_sequence'))
if current_link_id:
# edit existed link
link = Link.get_by_id(long(current_link_id))
link.title = link_title
link.target = link_target
link.sequence = long(link_sequence)
link.put()
t_values['alert_message'] = "link %s has been updated" % (link.title)
else:
# create new link
link = Link(title=link_title, target=link_target, sequence=long(link_sequence))
link.put()
t_values['alert_message'] = "link %s has been added" % (link.title)
# find all links
links = Link.all().order("-date")
t_values["links"] = links
return self.response.out.write(render_template("links.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:26,代码来源:admin.py
示例8: get
def get(self, page_slug=""):
if page_slug:
t_values = {}
posts = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').filter("slug =", page_slug)
if posts.count() == 1:
logging.warning("find one page with slug=%s" % (page_slug))
posts = posts.fetch(limit=1)
post = posts[0]
t_values['post'] = post
# dump(post)
# find all comments
comments = Comment.all().filter("entry =", post).order("date")
t_values['comments'] = comments
else:
logging.warning("%d entries share the same slug %s" % (posts.count(), page_slug))
links = Link.all().order("date")
t_values['links'] = links
categories = Category.all()
t_values['categories'] = categories
pages = Entry.all().filter("is_external_page =", True).filter("entrytype =", 'page').order("date")
t_values['pages'] = pages
return self.response.out.write(render_template("page.html", t_values, "basic", False))
else:
self.redirect(uri_for("weblog.index"))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:30,代码来源:weblog.py
示例9: get
def get(self, page_id="", operation=""):
t_values = {}
logging.info("PageManager get: page_id = %s, operation = %s" % (page_id, operation))
# find current_post based on page_id
if page_id:
current_post = Entry.get_by_id(long(page_id))
if current_post:
logging.info("find post %s from post id %s" % (page_id, current_post.title))
if operation == "edit":
t_values['current_post'] = current_post
elif operation == "publish":
current_post.is_external_page = True
current_post.put()
t_values['alert_message'] = "Post %s has been changed to public" % (current_post.title)
elif operation == "unpublish":
current_post.is_external_page = False
current_post.put()
t_values['alert_message'] = "Post %s has been changed to private" % (current_post.title)
elif operation == "delete":
current_post.delete()
t_values['alert_message'] = "Post %s has been changed to deleted" % (current_post.title)
# show all posts
posts = Entry.all().filter("entrytype =", 'page')
t_values['posts'] = posts
return self.response.out.write(render_template("pages.html", t_values, "", True))
开发者ID:loongw,项目名称:another-gae-blog,代码行数:27,代码来源:admin.py
示例10: get_list
def get_list():
questions = Question.get_filtered()
for question in questions:
if question is not None and question.activate_time is not None:
if question.get_time_left() < 0:
question.answerable = False
session.commit()
return render_template('question_list.html', questions=questions)
开发者ID:matthijsbos,项目名称:SWE_2013_Groep2,代码行数:8,代码来源:question.py
示例11: saveReviewAnswer
def saveReviewAnswer(self):
questionID = int(self.request.form['questionID'])
userID = self.request.form['userID']
reviewAnswer = self.request.form['reviewAnswer']
edit = int(self.request.form['edit'])
answer.AnswerModel.savereview(
questionID, userID, reviewAnswer, edit)
return render_template('answersaved.html', flag='true')
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:8,代码来源:answer.py
示例12: import_data
def import_data():
if 'file' not in request.files or not request.files['file']:
return render_template('error.html', error="No file given.")
#answers = request.form.get('answers', False) == 'on'
data = request.files['file'].read()
data = yaml.load(data)
return Question.import_course(g.lti.get_user_id(), g.lti.get_course_id(),
data) #, answers)
开发者ID:klaplong,项目名称:SWE_2013_Groep2,代码行数:9,代码来源:flaskapplication.py
示例13: get_list_table
def get_list_table(limit,offset):
(questions, curpage, maxpages, startpage, pagecount) = Question.get_filtered_offset(limit,offset,orderby='created')
for question in questions:
if question is not None and question.activate_time is not None:
if question.get_time_left() < 0:
question.answerable = False
session.commit()
return render_template('question_list_tbl.html', questions=questions,
currentpage=curpage,startpage=startpage,pagecount=pagecount,maxpages=maxpages)
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:11,代码来源:question.py
示例14: render_filtered_by_questionid
def render_filtered_by_questionid(self,questionid):
postdata = self.request.form
args = {"questionID": questionid}
if self.request.method == "POST":
if "userID" in postdata and len(postdata["userID"]) > 0:
args["userID"] = postdata["userID"]
if "id" in postdata and len(postdata["id"]) > 0:
args["id"] = postdata["id"]
return render_template('answerfilter_by_questionid.html', answers=answer.AnswerModel.get_filtered(**args))
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:11,代码来源:answer.py
示例15: get_pagination
def get_pagination():
curpage = int(request.args['currentpage'])
startpage = int(request.args['startpage'])
pagecount = int(request.args['pagecount'])
maxpages = int(request.args['maxpages'])
return render_template('pagination.html',
currentpage=curpage,
startpage=startpage,
pagecount=pagecount,
maxpages=maxpages)
开发者ID:klaplong,项目名称:SWE_2013_Groep2,代码行数:11,代码来源:flaskapplication.py
示例16: _export_feeds
def _export_feeds(self, options, args):
'''Exports feeds to OPML file'''
if not args:
raise CommandError('no output OPML file given')
filename = args[0]
#@@TODO Use a 'http_datetime' filter in template instead
timestamp = format_http_datetime(datetime.utcnow())
groups = [ (group.title, self.get_group_feeds(group)) for group in self.get_groups() ]
with open(filename, 'w') as f:
f.write(render_template(os.path.join(template_dir, 'export.xml'), locals()))
开发者ID:abyth,项目名称:coldsweat,代码行数:13,代码来源:commands.py
示例17: review
def review():
answer = Schedule.get_answer(g.lti.get_user_id())
if answer == None:
return "No answers to review."
fsession['reviewanswer'] = answer.id
enabledtags = AnswerTag.get_tag_ids(answer.id)
reviews = Review.get_list(answer.id)
return render_template('reviewanswer.html', answer=answer,
tags=Tag.get_all(), enabledtags=enabledtags,
reviews=reviews)
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:13,代码来源:review.py
示例18: _export_saved_entries
def _export_saved_entries(self, options, args):
'''Exports saved entries to Atom file'''
if not args:
raise CommandError('no output Atom file given')
filename = args[0]
timestamp = datetime.utcnow()
q = self.get_saved_entries()
guid = FEED_TAG_URI % (timestamp.year, make_sha1_hash(self.user.email or self.user.username))
version = VERSION_STRING
with open(filename, 'w') as f:
f.write(render_template(os.path.join(template_dir, 'export-saved.xml'), locals(), filters))
开发者ID:abyth,项目名称:coldsweat,代码行数:14,代码来源:commands.py
示例19: import_course
def import_course(user_id, course_id, data): #, import_answers):
for question in data:
qid = QuestionController.create_question(question['question'],
user_id, course_id, False, 0, True, True, True)
# In order to import answers, you need a unique user id for every
# answer. This introduces a lot of bugs and is therefore not active.
#if import_answers and 'answers' in question:
# start_time = datetime.now();
# for answer in question['answers']:
# AnswerController().saveAnswer(user_id, qid, 0, start_time,
# answer)
questions = map(lambda x: x['question'], data)
return render_template('import.html', questions=questions)
开发者ID:matthijsbos,项目名称:SWE_2013_Groep2,代码行数:14,代码来源:question.py
示例20: lobby
def lobby(self):
def randpop(array):
return array.pop(randrange(0,len(array)))
def getotheranswers(userID,questionID):
allanswers = (AnswerModel.get_all())
allanswerchoices = (AnswerChoiceModel.get_all())
validAnswers = []
for currentanswer in allanswers:
# if relevant answer and not submitted by the current user
if currentanswer.userID != userID and currentanswer.questionID == questionID:
shouldadd = True
for currentanswerchoice in allanswerchoices:
# if answer was not rated before by the current user
if (currentanswerchoice.best_answer_id == currentanswer.id or currentanswerchoice.other_answer_id == currentanswer.id) and currentanswerchoice.user_id == userID:
break
else: validAnswers.append(currentanswer.id)
return validAnswers
def getuncommons(answers):
answerchoices = (AnswerChoiceModel.get_all())
cnt = Counter()
for answer in answers:
cnt[answer] = 0
for answerchoice in answerchoices:
if answerchoice.best_answer_id in answers:
cnt[answerchoice.best_answer_id] += 1
if answerchoice.other_answer_id in answers:
cnt[answerchoice.other_answer_id] += 1
if len(cnt) > 1:
return [cnt.most_common()[-1][0],cnt.most_common()[-2][0]]
else: return False
userID = g.lti.get_user_id()
questionID = int(request.values['question_id'])
validAnswers = getotheranswers(userID,questionID)
print validAnswers
uncommons = getuncommons(validAnswers)
print uncommons
if uncommons == False:
return render_template('choicelobby.html',question=questionID)
else:
#return redirect('/answerchoice?questionid='+str(questionID)+'&answerid1='+str(randpop(validAnswers))+'&answerid2='+str(randpop(validAnswers)))
return redirect('/answerchoice?questionid='+str(questionID)+'&answerid1='+str(randpop(uncommons))+'&answerid2='+str(randpop(uncommons)))
开发者ID:muzzi11,项目名称:SWE_2013_Groep2,代码行数:48,代码来源:answerchoice.py
注:本文中的utilities.render_template函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论