def post(self): form = PortfolioProjectForm(self.request.POST) form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)] if form.validate(): project = PortfolioProject(**form.data) project.save() self.redirect_to("admin-projects-edit-extra", project_id = project.key().id(), extra="saved") return { "admin_section": "admin-projects-new", "form": form, }
def post(self, project_id, extra=""): project = PortfolioProject.get_by_id(long(project_id)) form = PortfolioProjectForm(self.request.POST) form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)] success = False if form.validate(): form.populate_obj(project) project.save() success = True return { "admin_section": "admin-projects-portfolio", "form": form, "success": success, "project": project, }