コード例 #1
0
ファイル: index.py プロジェクト: mattiskan/personal_site
def create(request):
    new_entry = BlogEntry(
        title = 'test title2',
        content = 'test content'
    )
    new_entry.save()  
    return HttpResponse("New blog entry added!")
コード例 #2
0
ファイル: tests.py プロジェクト: itkpi/itkpimail
 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
コード例 #3
0
ファイル: tests.py プロジェクト: jsdelivrbot/itkpimail
 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
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #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)
コード例 #8
0
def admin():
    blog_query = BlogEntry.query(ancestor=utils.get_parent_key())
    blogs = blog_query.fetch()
    return render_template('admin.html', blogs=blogs)
コード例 #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)