Skip to content

Commit

Permalink
set_match_message api
Browse files Browse the repository at this point in the history
  • Loading branch information
n0thingness committed Mar 30, 2018
1 parent 58c545f commit b67b642
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,29 @@ def clear_match():
surname=""
)

@APP.route('/api/v1/users/match/message', methods=['POST'])
@auth.login_required
def set_match_message():
message = request.json.get('data')
matched_user = None
matched_id = -1
matched_name = ""
matched_surname = ""
matched_message = ""
if g.user.matchedUser is not None:
g.user.matchedMessage = message;
matched_id = g.user.matchedUser
matched_user = User_DB.query.get(matched_id)
if matched_user is not None:
matched_name = matched_user.name
matched_surname = matched_user.surname
DB.session.commit()
return jsonify(
id=matched_id,
name=matched_name,
surname=matched_surname
)


@APP.route('/api/v1/location/<string:gid>/checkin', methods=['GET'])
@auth.login_required
Expand Down
28 changes: 28 additions & 0 deletions migrations/versions/a96d2d790f16_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""empty message
Revision ID: a96d2d790f16
Revises: 3ce6811d877c
Create Date: 2018-03-30 15:58:49.953020
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'a96d2d790f16'
down_revision = '3ce6811d877c'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('matchedMessage', sa.String(length=256), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'matchedMessage')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions user_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class User_DB(DB.Model):
checkInLocation = DB.Column(DB.String(255), ForeignKey('locations.gid')) #user.currentLocation for actual location object
# Foreign Key creates a pointer to the matched user
matchedUser = DB.Column(DB.Integer, ForeignKey('users.id'))
matchedMessage = DB.Column(DB.String(256))

# result_all = DB.Column(JSON)
# result_no_stop_words = DB.Column(JSON)
Expand Down

0 comments on commit b67b642

Please sign in to comment.