Esempio n. 1
0
    def post(self):
   
        if authenticatedUser(sessions.Session()):

            blogpost = BlogPostModel(
                title = self.request.get('title'),
                content = self.request.get('content'))
            
            blogpost.put();
            
            self.redirect('/')
            
        else:
            
            self.redirect('/login/')
Esempio n. 2
0
def home():
    storage = Storage()

    if request.method == 'POST':
        form = BlogPostForm(request.form)
        if form.validate():
            model = BlogPostModel(form.data)
            storage.appending(model.model_to_dict())
        else:
            logger.error('Someone have submitted an incorrect form!')
    else:
        form = BlogPostForm()
    return render_template(
        'home.html',
        form=form,
        items=storage.posts,
    )
Esempio n. 3
0
    def get(self,id):

        user = authenticatedUser(sessions.Session())
        blogpost = BlogPostModel.get_by_id(int(id), parent=None)

        template_values = {
            'menulinks': menuLinks(),
            'user': user,
            'post': blogpost,          
        }

        path = os.path.join(os.path.dirname(__file__), 'editPost.html')
        self.response.out.write(template.render(path, template_values))
Esempio n. 4
0
def home():
    storage = Storage()
    all_items = storage.items

    if request.method == 'POST':
        form = ContactForm(request.form)
        if form.validate():
            model = BlogPostModel(form.data)
            all_items.append(model)
            storage.dump_to_json_file()
            form = ContactForm()
    else:
        form = ContactForm()

    return render_template('home.html', form=form, items=all_items)
Esempio n. 5
0
    def post(self,id):
   
        if authenticatedUser(sessions.Session()):

            blogpost = BlogPostModel.get_by_id(int(id), parent=None)
            blogpost.title = self.request.get('title')
            blogpost.content = self.request.get('content')
            blogpost.updated = DateTimeProperty.now()
            blogpost.put()
            
            self.redirect('/')
            
        else:
            
            self.redirect('/login/')
Esempio n. 6
0
def home():
    storage = Storage()
    all_items = storage.items

    if request.method == 'POST':
        form = BlogPostForm(request.form)
        if form.validate():
            model = BlogPostModel(form.data, len(all_items) + 1)
            all_items.append(model)
            storage.save()
        else:
            logger.error('Someone have submitted an incorrect form!')
    else:
        form = BlogPostForm()

    return render_template(
        'home.html',
        form=form,
        items=all_items,
    )
Esempio n. 7
0
    def get(self,id):

        blogpost = BlogPostModel.get_by_id(int(id), parent=None)
        db.delete(blogpost)

        self.redirect('/')