def post(self):
        form = ProjectCategoryForm(self.request.POST)

        if form.validate():
            title = form.data["title"]
            slug = title.lower().replace(" ", "-")
            category = ProjectCategory(title = title, slug = slug)
            category.put()

        self.redirect_to('admin-projects-categories')
    def get(self):
        categories = ProjectCategory.all()

        return {
            "admin_section": "admin-projects-categories",
            "categories": categories,
        }
示例#3
0
    def get(self, category=None, technology=None):
        cur_technology = cur_category = None
        categories = ProjectCategory.all()

        if category:
            cur_category = ProjectCategory.all().filter("slug =", category).get()
            projects = PortfolioProject.all().filter("category =", cur_category).order("-date_created")
        elif technology:
            cur_technology = Technology.all().filter("slug =", technology).get()
            projects = PortfolioProject.all().filter("technologies =", cur_technology.key()).order("-date_created")
        else:
            projects = PortfolioProject.all().order("-date_created")
            cur_category = None

        return {
            "section": "portfolio",
            "projects": projects,
            "cur_category": cur_category,
            "cur_technology": cur_technology,
            "categories": categories,
        }
    def post(self, category_id):
        form = ProjectCategoryForm(self.request.POST)

        if form.validate():
            slug = form.data["title"].lower().replace(" ", "-")
            category = ProjectCategory.get(long(category_id))
            form.populate_obj(category)
            category.put()

        return {
            "result": {
               "id": category.key().id(),
               "title": category.title,
               "slug": category.slug,
           }
        }