Exemplo n.º 1
0
def create(request):
    new_entry = BlogEntry(
        title = 'test title2',
        content = 'test content'
    )
    new_entry.save()  
    return HttpResponse("New blog entry added!")
Exemplo n.º 2
0
 def create_blog_post(self, owner, name='random_post', published=True, personal=False, tags='tag'):
     entry = BlogEntry(title=name,
                       slug=name,
                       content='{} content'.format(name),
                       tags=tags,
                       published=published,
                       personal=personal,
                       date_published=now(),
                       owner=owner)
     entry.save()
     return entry
Exemplo n.º 3
0
 def create_blog_post(self,
                      owner,
                      name='random_post',
                      published=True,
                      personal=False,
                      tags='tag'):
     entry = BlogEntry(title=name,
                       slug=name,
                       content='{} content'.format(name),
                       tags=tags,
                       published=published,
                       personal=personal,
                       date_published=now(),
                       owner=owner)
     entry.save()
     return entry
Exemplo n.º 4
0
def new_post():
    form = BlogEntryForm(request.form)
    if request.method == 'POST' and form.validate():
        blog_entry = BlogEntry(parent=utils.get_parent_key())
        blog_entry.title = form.title.data
        blog_entry.body = form.body.data
        tag_str = form.tags.data
        blog_entry.tags = map(lambda x: x.strip(), tag_str.split(','))
        blog_entry.save()
        return redirect(url_for('index'))

    return render_template('new_post.html', form=form)
Exemplo n.º 5
0
    def test_representations(self):
        title = 'EntryTitle'
        content = '<p> awesome html </p>'
        created_on = datetime.now
        created_by = User.objects.get(pk=1)
        status = BlogEntry.DRAFT
        blogentry = BlogEntry(
            title=title,
            content=content,
            status=status,
            created_on=created_on,
            created_by=created_by,
        )
        representation = "< BlogEntry title='{}' created_by='{}' status='{}' >".format(
            title, created_by, status)

        self.assertEqual(str(blogentry), representation)
        self.assertEqual(repr(blogentry), representation)
Exemplo n.º 6
0
def delete_post(blog_id):
    blog = BlogEntry.get_by_id(int(blog_id), parent=utils.get_parent_key())
    return render_template('single.html', blog=blog)
Exemplo n.º 7
0
def single_page(blog_id, slug=None):
    blog = BlogEntry.get_by_id(int(blog_id), parent=utils.get_parent_key())
    return render_template('single.html', blog=blog)
Exemplo n.º 8
0
def admin():
    blog_query = BlogEntry.query(ancestor=utils.get_parent_key())
    blogs = blog_query.fetch()
    return render_template('admin.html', blogs=blogs)
Exemplo n.º 9
0
def index():
    """Return a friendly HTTP greeting."""
    blog_query = BlogEntry.query(ancestor=utils.get_parent_key())
    bolgs = blog_query.fetch(5)
    return render_template('index.html', blogs=bolgs)