def post(self): """HTML POST handler. POSTS to this page are monster creation requests. Using the request parameters, call the handler for each answered question, then redirect to the view page for the newly created monster.""" template_values = self.build_template_values() if template_values[handlers.base.PROFILE_KEY]: self.___builder = CoreMonsterBuilder() for question in CoreMonsterBuilder.questions(): self.answer(question) monster = self.___builder.Build() monster.creator = template_values[handlers.base.PROFILE_KEY] product = self.request.get('product') if product: monster.product = int(product) license = self.request.get('license') if license: monster.license = configuration.site.licenses[license] monster.put() self.redirect(self.uri_for("monster", entity_id=monster.key().id())) else: self.forbidden()
def get(self): """HTML GET handler. Renders a form for inputing the information used to create a monster under a specific set of rules. The rules are specified by the MonsterBuilder being used.""" template_values = self.build_template_values() template_values['questions']= CoreMonsterBuilder.questions() product = self.request.get('product') if product: product = Product.get_by_id(int(product)) if product.creator.account != template_values[handlers.base.USER_KEY]: return self.forbidden() template_values['product'] = product template = configuration.site.jinja_environment.get_template('monster/create.html') self.response.write(template.render(template_values))