コード例 #1
0
ファイル: main.py プロジェクト: splerp/udacity-projects
    def post(self):
        title, summary, contents, image = self.getThese(
            "entry_title", "entry_summary", "entry_contents", "entry_image")

        user_name = get_current_username(self.request.cookies)
        user = get_user_entity_from_username(user_name)

        # Validate post and retrieve errors.
        error_messages = validate_blog_post(title, summary, contents,
                                            user_name)

        new_id = None

        if len(error_messages) == 0:

            # Create new blog post.
            post = BlogPost(title=title,
                            owner=user,
                            contents=contents,
                            summary=summary,
                            title_image=image if image != "" else None)
            post.put()
            new_id = post.key()

        # Render page with all required information.
        self.render("entry_new.html",
                    True,
                    new_id=new_id,
                    error_messages=error_messages,
                    entry_title=title,
                    entry_summary=summary,
                    entry_contents=contents)
コード例 #2
0
ファイル: main.py プロジェクト: splerp/udacity-projects
    def post(self):
        title, summary, contents, image = self.getThese(
            "entry_title",
            "entry_summary",
            "entry_contents",
            "entry_image")

        user_name = get_current_username(self.request.cookies)
        user = get_user_entity_from_username(user_name)

        # Validate post and retrieve errors.
        error_messages = validate_blog_post(
            title,
            summary,
            contents,
            user_name)

        new_id = None

        if len(error_messages) == 0:

            # Create new blog post.
            post = BlogPost(
                title=title,
                owner=user,
                contents=contents,
                summary=summary,
                title_image=image if image != "" else None)
            post.put()
            new_id = post.key()

        # Render page with all required information.
        self.render(
            "entry_new.html",
            True,
            new_id=new_id,
            error_messages=error_messages,
            entry_title=title,
            entry_summary=summary,
            entry_contents=contents)
コード例 #3
0
ファイル: main.py プロジェクト: splerp/udacity-projects
    def post(self):
        delete_users, delete_posts = self.getThese("delete_users",
                                                   "delete_posts")

        if delete_users is not None:
            users = SiteUser.all()
            for user in users:
                user.delete()

        if delete_posts is not None:
            posts = BlogPost.all()
            print "Post is", posts
            for one_post in posts:
                one_post.delete()

        self.render("admin.html", True)
コード例 #4
0
ファイル: main.py プロジェクト: splerp/udacity-projects
    def post(self):
        delete_users, delete_posts = self.getThese(
            "delete_users",
            "delete_posts")

        if delete_users is not None:
            users = SiteUser.all()
            for user in users:
                user.delete()

        if delete_posts is not None:
            posts = BlogPost.all()
            print "Post is", posts
            for one_post in posts:
                one_post.delete()

        self.render("admin.html", True)