H
H
hardwellZero2015-03-08 16:08:33
Flask
hardwellZero, 2015-03-08 16:08:33

One-time user action?

Hello.
I wrote my little blog with ̶ ̶b̶l̶e̶k̶d̶zh̶e̶k̶o̶m̶ ̶i̶ ̶d̶a̶m̶a̶m̶i̶ with posts and comments.
Now I want to make "pluses" to the comments, but I don't know how to implement it better.
Now the comment table looks like this:

Commentary:
    id
    text
    author_name
    id_post

I plan to add a 'like' field here, and make it 0 by default.
And what to do next, I do not know. It is also necessary to check somehow the user voted for this comment or not.
Make a button for voting.
What do you advise?

UPD.
Whether will correct to check through session?
Example from google.
@app.route('/votes/', methods=['POST'])
def create_vote():
    if session.get('voted'):
        return jsonify(error='Already voted.'), 401

    vote = Vote(constituency_id=request.form.get('constituency_id'),
                party_id=request.form.get('party_id'))
    db.session.add(vote)
    db.session.commit()

    session['voted'] = True

    return jsonify(vote)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Muxalich, 2015-03-08
@muxalich

отдельную бд заведи под id новости и id пользователя.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question