コード例 #1
0
    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,
        }
コード例 #2
0
    def get(self):
        projects = PortfolioProject.all().order("-date_created")

        return {
            "admin_section": "admin-projects-portfolio",
            "projects": projects,
        }
コード例 #3
0
    def post(self):
        project = PortfolioProject.get_by_id(long(self.request.params.get("project_id", None)))
        teaser = ImageRecord.get_by_id(long(self.request.params.get("teaser_id", None)))
        project.image = teaser
        project.save()

        self.response.headers['Content-Type'] = 'application/json'
        self.response.out.write(json.dumps({
            "teaser": images.get_serving_url(teaser.image.key(), 800, False)
            }))
コード例 #4
0
    def get(self, project_id, extra=""):
        project = PortfolioProject.get_by_id(long(project_id))
        form = PortfolioProjectForm(obj = project)
        form.technologies.choices = [(tech.key().id(), tech.title) for tech in Technology.all().fetch(None)]

        return {
            "admin_section": "admin-projects-portfolio",
            "form": form,
            "success": extra == "saved",
            "upload_url": blobstore.create_upload_url(webapp2.uri_for('image-upload')),
            "project": project,
        }
コード例 #5
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,
        }
コード例 #6
0
    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,
        }
コード例 #7
0
    def get(self, project_id):
        project = PortfolioProject.get_by_id(long(project_id))

        return {"section": "portfolio", "project": project}