Пример #1
0
def getAccountInfo():
    """
    Allows user to see their account information
    """
    return render_template(
        'user_page.html',
        user=Users.query.get(get_current_user()),
        items=Items.query.filter_by(userID=get_current_user()),
        get_user_fname=get_user_fname)
Пример #2
0
def deleteItem(itemID, userID):
    """Deletes a row within a table"""
    if int(get_current_user()) == int(userID):
        row = Items.query.get([itemID, userID])
        db.session.delete(row)
        db.session.commit()
        return redirect('/user-page')
    return render_template('404.html')
Пример #3
0
def viewItem(itemID):
    item = get_item(itemID)
    return render_template('viewItem.html',
                           key=stripe_keys['publishable_key'],
                           item=item,
                           get_item_cost=get_item_cost,
                           get_username=get_user_fname,
                           page_viewer=get_current_user())
Пример #4
0
def submitPost():
    """
    Handle requests to the /submitpost route
    Allows users to post items
    """
    form = ItemForm()
    print('User Id', get_current_user())
    if form.validate_on_submit():
        itemID = db.session.query(db.func.max(Items.itemID)).scalar() + 1
        cost = form.cost.data * 100 # All money will be dealt with as integers for easy storage. All items price in cents
        new_item = Items(name=form.name.data, category=form.category.data,
                         description=form.description.data, cost=cost,
                         itemID=itemID, postedDate=strftime("%Y-%m-%d", gmtime()),
                         userID=get_current_user(), sold=False)
        create(new_item)
        return redirect('/listing')
    # load make_post template
    return render_template('make_post.html', form=form, title='Submit Post') #, get_username=get_username)
Пример #5
0
def add_room():
    if not request.is_json:
        return jsonify({"msg": "Missing JSON in request"}), 400

    contactId = request.json.get('id', None)
    contactName = request.json.get('name', None)
    lastMessage = request.json.get('last_message', None)

    room = ChatService.addRoom(get_current_user(), contactId, contactName,
                               lastMessage)
    return jsonify(room), 200
Пример #6
0
def get_profile():
    """ This api for the user get their information.

        Returns:

        Examples::

    """

    current_user = get_current_user()

    return send_result(data=current_user)
Пример #7
0
def room(roomId):
    data = ChatService.getRoom(roomId, get_current_user())
    return jsonify(data), 200
Пример #8
0
def contacts():
    data = ChatService.getContacts(get_current_user())
    # groups = [row for row in data if row['type'] == 'group']
    # friends = [row for row in data if row['type'] == 'friend']
    return jsonify(data), 200
Пример #9
0
 def inner(*args, **kwargs):
     current_user = get_current_user()
     if not current_user["is_admin"]:
         return send_error(message='You do not have permission')
     return func(*args, **kwargs)