Beispiel #1
0
def uploads():
    if "file" not in request.files:
        raise APIException(403, "No files")
    file = request.files["file"]
    if file.filename == "":
        raise APIException(403, "No files selected")

    filename = "{}-{}.jpg".format(current_user.username, str(datetime.utcnow().timestamp()))
    file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
    current_user.profile_filename = filename
    db.session.add(current_user)
    db.session.commit()

    return "uploads/{}".format(filename)
Beispiel #2
0
 def get(self, user_id, address_id, **kwargs):
     address = api.get_user_address(user_id, address_id)
     if address is None:
         raise APIException(404, 'Not found')
     address = api.update_user_address(user_id, address_id)
     address_data = formatter.make(address, formatting.address_format)
     return address_data
Beispiel #3
0
    def post(self):
        data = request.get_json()
        username = data.get("username")
        password = data.get("password")
        authenticated = api.authenticate(username, password)
        if not authenticated:
            raise APIException(401, "Unauthorized")

        return authenticated
Beispiel #4
0
    def post(self):
        data = request.get_json()
        username = data.get("username")
        password = data.get("password")
        if api.authenticate(username, password):
            user_data = formatter.make(current_user, formatting.user_format)

            return user_data

        raise APIException(401, "Incorrect login")
Beispiel #5
0
    def get(self, user_id, address_id, **kwargs):
        address = api.get_user_address(user_id, address_id)
        if address is None:
            raise APIException(404, 'Not found')

        address_transactions = api.get_user_address_transactions(
            user_id, address_id)
        address_transactions_data = list(
            map(
                lambda adtx: formatter.make(
                    adtx, formatting.address_transaction_format),
                address_transactions))

        return address_transactions_data
Beispiel #6
0
    def get(self):
        if not current_user.is_authenticated:
            raise APIException(401, "Unauthorized")
        user_data = formatter.make(current_user, formatting.user_format)

        return user_data