示例#1
0
文件: dev.py 项目: rclanan/radar
def create_posts(n):
    for x in range(n):
        d = random_date(date(2008, 1, 1), date.today())

        post = Post()
        post.title = '%s Newsletter' % d.strftime('%b %Y')
        post.body = generate_lorem_ipsum(n=3, html=False)
        post.published = d
        db.session.add(post)
示例#2
0
文件: news.py 项目: rclanan/radar
def add_post():
    if not current_user.has_edit_news_permission:
        abort(403)

    form = PostForm()

    if form.validate_on_submit():
        post = Post()
        post.published = datetime.now()
        form.populate_obj(post)
        db.session.add(post)
        db.session.commit()

        return redirect(url_for('news.view_post', post_id=post.id))

    context = dict(
        form=form,
    )

    return render_template('edit_post.html', **context)
示例#3
0
文件: posts.py 项目: renalreg/radar
def create_posts(n):
    for x in range(n):
        d = random_date(date(2008, 1, 1), date.today() - timedelta(days=1))

        post = Post()
        post.title = '%s Newsletter' % d.strftime('%b %Y')
        post.body = generate_lorem_ipsum(n=3, html=False)
        post.published_date = d
        add(post)

    post = Post()
    post.title = 'New RaDaR Conditions'
    post.body = 'RaDaR is now open to two new conditions - Calciphylaxis and IgA Nephropathy. '\
        'No new approvals are needed for these conditions and patients are registered in the normal fashion.'
    post.published_date = date.today()
    add(post)