示例#1
0
  def render_form(self, collection=None):
    context = simpleTALES.Context(allowPythonPath=True)

    context.addGlobal("title", "Manage Survival KIT Orders")
    context.addGlobal("root", '/manage/')
    context.addGlobal("orders", Order.uncollected())
    context.addGlobal("download", collection)
    context.addGlobal("collections", Collection.all().order('created'))
    context.addGlobal("release_dates", ReleaseDate.all().order('date'))
    context.addGlobal("exchange_types", ExchangeType.all().order('type'))   
    context.addGlobal("instructions", Instruction.all().order('topic'))

    return self.render_html("secretary.pt", self.macros_from("master.pt", context))
示例#2
0
    def render_form(self, collection=None):
        context = simpleTALES.Context(allowPythonPath=True)

        context.addGlobal("title", "Manage Survival KIT Orders")
        context.addGlobal("root", "/manage/")
        context.addGlobal("orders", Order.uncollected())
        context.addGlobal("download", collection)
        context.addGlobal("collections", Collection.all().order("created"))
        context.addGlobal("release_dates", ReleaseDate.all().order("date"))
        context.addGlobal("exchange_types", ExchangeType.all().order("type"))
        context.addGlobal("instructions", Instruction.all().order("topic"))

        return self.render_html("secretary.pt", self.macros_from("master.pt", context))
示例#3
0
 def post(self, model):
   if model in ['Collection']:
     collection = self.create('Collection', {'created': datetime.datetime.now()}).put()
     for order in self.request.get_all('order'):
       order = Order.get(order)
       order.collection = collection
       order.put()
     self.response.out.write(self.render_form(collection))
   elif model in ['ReleaseDate', 'ExchangeType', 'Instruction']:
     values = self.extract(model, self.request)
     errors = self.validate(model, values)
     if not errors:
       self.create(model, values).put()
       self.redirect("/manage/")
     else:
       self.response.out.write(htmlfill.render(self.render_form(), values, errors,
                                               force_defaults=False, encoding='utf-8'))
   else:
     self.error(404)
示例#4
0
 def post(self, model):
     if model in ["Collection"]:
         collection = self.create("Collection", {"created": datetime.datetime.now()}).put()
         for order in self.request.get_all("order"):
             order = Order.get(order)
             order.collection = collection
             order.put()
         self.response.out.write(self.render_form(collection))
     elif model in ["ReleaseDate", "ExchangeType", "Instruction"]:
         values = self.extract(model, self.request)
         errors = self.validate(model, values)
         if not errors:
             self.create(model, values).put()
             self.redirect("/manage/")
         else:
             self.response.out.write(
                 htmlfill.render(self.render_form(), values, errors, force_defaults=False, encoding="utf-8")
             )
     else:
         self.error(404)