Every city and town by ordinance may accept any money or property donated, devised, or bequeathed to it and carry out the terms of the donation, devise, or bequest, if within the powers granted by law. If no terms or conditions are attached to the donation, devise, or bequest, the city or town may expend or use it for any municipal purpose.