def create(request): new_entry = BlogEntry( title = 'test title2', content = 'test content' ) new_entry.save() return HttpResponse("New blog entry added!")
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
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)
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)
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)
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)
def admin(): blog_query = BlogEntry.query(ancestor=utils.get_parent_key()) blogs = blog_query.fetch() return render_template('admin.html', blogs=blogs)
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)