예제 #1
0
def edit_title():
    if current_user() == None:
        flash('You must be logged in to access this page', 'warning')
        return redirect(url_for('login'))
    post = Post(request.args['post'])
    if (request.form):
        post.update(request.form['title'], request.form['content'],
                    request.form['tags'])
        return redirect(f'/qaf/{post.qaf_id}/{post.id}')
    return render_template("edit_title.html", post=post)
예제 #2
0
def create_post(id):
    if current_user() == None:  # have to be logged in to make an entry
        flash('You must log in to access this page')
        return redirect(url_for('login'))
    if (request.form):
        entry = request.form
        Post.new_post(current_user().id, entry['title'], entry['content'], id,
                      entry['tags'])
        return redirect("/qaf/" + str(id))
    return render_template("create_post.html", title="Create Post")
예제 #3
0
 def get_posts(self):
     command = 'SELECT id FROM posts WHERE qaf_id = {} ORDER BY time_created DESC'.format(
         self.id)
     data = execute(command).fetchall()
     posts = []
     for post_id in data:
         posts.append(Post(post_id[0]))
     return posts
예제 #4
0
def show_post(qaf_id, post_id):
    if current_user() == None:
        flash('You must be logged in to access this page', 'warning')
        return redirect(url_for('login'))
    if ('comment' in request.form):
        entry = request.form
        Comment.new_comment(current_user().id, entry['comment'], post_id,
                            qaf_id)
    if ('post_id' in request.form):
        return redirect(url_for('edit_title', post=request.form['post_id']))
    if ('comment_id' in request.form):
        return redirect(
            url_for('edit_comment', comment=request.form['comment_id']))

    post = Post(post_id)
    comments = post.get_comments()
    return render_template('post.html',
                           title=post.title,
                           post=post,
                           comments=comments,
                           author=User(post.author_id).username)
예제 #5
0
파일: index.py 프로젝트: feitianyiren/piki
    def get(self):
        path = os.getcwd().replace('tornado', 'wiki')
        files = [
            filename for filename in os.listdir(path)
            if not filename.startswith('_') and filename.endswith('.md')
        ]
        files_time = {}
        for f in files:
            stat_info = os.lstat('{path}/{f}'.format(path=path, f=f))
            files_time[stat_info.st_mtime] = f

        recents = [
            files_time[k] for k in sorted(files_time.keys(), reverse=True)
        ]

        posts = []
        for f in recents[:15]:
            logger.debug('file:{f}'.format(f=f))
            posts.append(Post(f))

        self.render('{theme}/index.html'.format(theme=setting.theme),
                    posts=posts)
예제 #6
0
from util.ar_tracker import ARTracker
from util.post import Post, Gate

ar_tracker = ARTracker('/ar_pose_marker', 'odom')

# See https://7aec5dcb-a-3f6a8980-s-sites.googlegroups.com/a/marssociety.org/urc/home/q-a/ARgates.png

posts = {
    1: Post(0, ar_tracker),
    2: Post(1, ar_tracker),
    3: Post(2, ar_tracker),
}

gates = {
    4: Gate(Post(3, ar_tracker), Post(4, ar_tracker)),
    5: Gate(Post(5, ar_tracker), Post(6, ar_tracker)),
    6: Gate(Post(7, ar_tracker), Post(8, ar_tracker)),
    7: Gate(Post(9, ar_tracker), Post(10, ar_tracker)),
}
예제 #7
0
 def get(self, url):
     post = Post(url)
     self.render('{theme}/post.html'.format(theme=setting.theme), p=post)
예제 #8
0
def downvotePost():
    input = request.args.get("input", 0, type=str)
    print(input)
    Post(int(input)).downvoted()
    return jsonify(result=input)