예제 #1
0
def retrieve_posts_right(area, issue, affiliation=1):
    thread = dao.retrieve_posts_right(area, issue, affiliation)

    if thread != None:
        data = []
        for item in thread:
            post_username = item[0]
            post_affiliation = dao.partyID_to_party(item[1])
            post_text = item[2]
            time_and_date = item[3]
            post_votes = item[4]
            page = dao.pageID_to_page(item[5])
            post_title = item[6]
            post_id = item[7]
            data.append({
                'post_username': post_username,
                'post_affiliation': post_affiliation,
                'post_text': post_text,
                'time_and_date': time_and_date,
                'post_votes': post_votes,
                'page': page,
                'post_title': post_title,
                'post_id': post_id
            })
        return data
예제 #2
0
def retrieve_thread(post_id):
    thread = dao.retrieve_thread(post_id)

    if thread != None:
        postdict = {}
        postdict['post_username'] = thread[0]
        postdict['post_affiliation'] = dao.partyID_to_party(thread[1])
        postdict['post_text'] = thread[2]
        postdict['time_and_date'] = thread[3]
        postdict['post_votes'] = thread[4]
        postdict['page'] = dao.pageID_to_page(thread[5])
        postdict['post_title'] = thread[6]
        postdict['post_id'] = thread[7]
        return postdict
예제 #3
0
def login():
    _json = request.json

    _email = _json['email']
    _password = _json['password']

    if _email and _password:
        user = dao.login(_email, _password)

        if user != None:
            session['username'] = user[0]
            session['first'] = user[1]
            session['last'] = user[2]
            session['email'] = user[3]
            session['party'] = dao.partyID_to_party(user[4])
            session['date'] = user[6]
            resp = jsonify({'message': 'User logged in successfully'})
            resp.status_code = 200
            return resp

    resp = jsonify({'message': 'Bad Request - invalid credentials'})
    resp.status_code = 400
    return resp
예제 #4
0
 def test_partyID_to_party(self):
     response = dao.partyID_to_party(1)
     self.assertEqual("Republican", response)