Exemple #1
0
 def delete(self):
     data = request.json
     stock_market = get_by_id(cls=StockMarket,
                              object_id=data['stock_market_id'])
     stock_market.is_terminate_all_required = True
     stock_market.save()
     create_action_log("Terminated all orders", data['screen'])
     return 200
Exemple #2
0
 def delete(self):
     """
     Method to stop trading
     :return:
     """
     data = request.json
     stock_market = get_by_id(StockMarket, data['stock_market_id'])
     stock_market.is_trading_active = False
     stock_market.save()
     create_action_log("Stopped Trading", data['screen'])
     return 200
Exemple #3
0
 def post(self):
     """
     Method to start trading
     :return:
     """
     data = request.json
     stock_market = get_by_id(StockMarket, data['stock_market_id'])
     stock_market.is_trading_active = True
     stock_market.save()
     create_action_log("Started Trading", data['screen'])
     return 200
Exemple #4
0
 def get(self, user_id):
     """
     Method return info about one user
     :return: info about user with this id and status
     """
     user_data = get_by_id(User, user_id)
     user = {
         "first_name": user_data.first_name,
         "last_name": user_data.last_name,
         "email": user_data.email,
         "id": user_data.id
     }
     return user, 200
Exemple #5
0
    def put(self):
        """
        Method for updating info about user
        :return:
        """
        data = request.json
        try:
            edit_user = get_by_id(User, data['id'])
        except:
            BadRequest("ID not found in request")
        action = ""
        if "email" in data:
            action = "Updated email from {0} to {1} for {2}.".format(
                edit_user.email, data['email'], edit_user.full_name)
            edit_user.email = data['email']

        if "first_name" in data:
            action = "Updated first name from {0} to {1} for {2}.".format(
                edit_user.first_name, data['first_name'], edit_user.email)
            edit_user.first_name = data['first_name']
        if "last_name" in data:
            action = "Updated last name from {0} to {1} for {2}.".format(
                edit_user.last_name, data['last_name'], edit_user.email)
            edit_user.last_name = data['last_name']
        if "first_name" in data or "last_name" in data:
            edit_user.full_name = edit_user.get_full_name()
        edit_user.save()

        if "roles" in data:
            action = "Updated rights from {0} to {1} for {2}.".format(
                ", ".join(edit_user.get_user_roles_names_list),
                ", ".join(data['roles']), edit_user.full_name)
            for role in data['roles']:
                edit_user.add_role(role)
        create_action_log(action, "UsersManagement")
        return 200