Ejemplo n.º 1
0
 def get(self):
     values = {"page_title": self.page_title()}
     values['courses'] = COURSE_LIST
     user = users.get_current_user()
     if user:
         rosebotics_student = RoseboticsStudent.get_by_id(
             user.email().lower())
         if rosebotics_student is None:
             rosebotics_student = RoseboticsStudent(id=user.email().lower())
             rosebotics_student.put()
         values["logout_url"] = users.create_logout_url("/")
         values["rosebotics_student"] = rosebotics_student
         most_recent_course = recent_track_utils.get_most_recent_course(
             rosebotics_student.key)
         if most_recent_course is not None:
             values["most_recent_track"] = most_recent_course
         values.update(
             recent_track_utils.get_recent_tracks(rosebotics_student.key))
     elif self.requires_oauth():
         self.redirect("/courses")
         return
     else:
         values["login_url"] = users.create_login_url("/courses")
     self.update_values(user, values)
     template = jinja_env.get_template(self.template_file())
     self.response.out.write(template.render(values))
Ejemplo n.º 2
0
 def get(self, *args, **kwargs):
     editor_type = self.get_argument("editor_type", None)
     editor_tmpl = "editor/cm_" + editor_type + ".html"
     context = self.get_template_namespace()
     self.write({
             "html":      jinja_env.get_template(editor_tmpl).render(context),
         })
     self.flush()
Ejemplo n.º 3
0
 def render(self, template, context=None):
     """Renders template using jinja2"""
     if not context:
         context = {}
     context.update(self.get_template_namespace())
     self.write(jinja_env.get_template(template).render(context))
     # Always set _xsrf cookie
     self.xsrf_token
     self.flush()
Ejemplo n.º 4
0
 def render(self, template, context=None):
     """Renders template using jinja2"""
     if not context:
         context = {}
     context.update(self.get_template_namespace())
     self.write(jinja_env.get_template(template).render(context))
     # Always set _xsrf cookie
     self.xsrf_token
     self.flush()
Ejemplo n.º 5
0
def create_pdf_bill(context,
                    filename,
                    template_name='documents/bill_pdf.html'):
    context['MEDIA_ROOT'] = '/home/kpx/billbuilder/billbuilder'
    html = jinja_env.get_template(template_name).render(context)
    result = StringIO.StringIO()
    pisa.pisaDocument(StringIO.StringIO(html.encode('utf-8')),
                      result,
                      show_error_as_pdf=True,
                      encoding='UTF-8')
    open(filename, 'wb').write(result.getvalue())
Ejemplo n.º 6
0
 def get(self):
   values = {"page_title": self.page_title()}
   values['courses'] = COURSE_LIST
   user = users.get_current_user()
   if user:
     rosebotics_student = RoseboticsStudent.get_by_id(user.email().lower())
     if rosebotics_student is None:
       rosebotics_student = RoseboticsStudent(id=user.email().lower())
       rosebotics_student.put()
     values["logout_url"] = users.create_logout_url("/")
     values["rosebotics_student"] = rosebotics_student
     most_recent_course = recent_track_utils.get_most_recent_course(rosebotics_student.key)
     if most_recent_course is not None:
       values["most_recent_track"] = most_recent_course
     values.update(recent_track_utils.get_recent_tracks(rosebotics_student.key))
   elif self.requires_oauth():
     self.redirect("/courses")
     return
   else:
     values["login_url"] = users.create_login_url("/courses")
   self.update_values(user, values)
   template = jinja_env.get_template(self.template_file())
   self.response.out.write(template.render(values))
Ejemplo n.º 7
0
def create_pdf_bill(context, filename, template_name='documents/bill_pdf.html'):
    context['MEDIA_ROOT'] = '/home/kpx/billbuilder/billbuilder'
    html = jinja_env.get_template(template_name).render(context)
    result = StringIO.StringIO()
    pisa.pisaDocument(StringIO.StringIO(html.encode('utf-8')), result, show_error_as_pdf=True, encoding='UTF-8')
    open(filename, 'wb').write(result.getvalue())    
Ejemplo n.º 8
0
def create_bill(context, template_name='documents/bill.html'):
    return jinja_env.get_template(template_name).render(context)
Ejemplo n.º 9
0
 def render(self, template):
     self.context.update(self.get_template_namespace())
     self.write(jinja_env.get_template(template).render(self.context))
     self.xsrf_token
     self.flush()
Ejemplo n.º 10
0
def send_html_mail(email, subject, template_name, context):
    send_mail(email, subject, jinja_env.get_template(template_name).render(context))
Ejemplo n.º 11
0
 def render(self, template_name, context=None, **kwargs):
     if not context:
         context = {}
     context.update(self.get_template_namespace())
     self.write(jinja_env.get_template(template_name).render(context))
Ejemplo n.º 12
0
 def render_str(self, template, **params):
     t = jinja_env.get_template(template)
     params['user'] = self.user if self.user else None
     return t.render(params)
Ejemplo n.º 13
0
 def render(self, template):
     self.context.update(self.get_template_namespace())
     self.write(jinja_env.get_template(template).render(self.context))
     self.xsrf_token
     self.flush()
Ejemplo n.º 14
0
def create_bill(context, template_name='documents/bill.html'):
    return jinja_env.get_template(template_name).render(context)
Ejemplo n.º 15
0
 def render_template(self, template_name):
     # render template using jinja2
     self.context.update(self.get_template_namespace())
     return jinja_env.get_template(template_name).render(self.context)