allow admin update default rate provider and default currency for stores (#5918)

* allow admin update default rate provider and default currency for stores

* Updated PR on allowing server admin to update currency

* update server settings to select default currency

* revert standard default currency

* clean up

* Minor rewording

---------

Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
Chukwuleta Tobechi
2024-05-10 07:26:04 +01:00
committed by GitHub
parent 84df96429c
commit 11b38a7a4c
4 changed files with 13 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ using BTCPayServer.Abstractions.Models;
using BTCPayServer.Client;
using BTCPayServer.Data;
using BTCPayServer.Models.StoreViewModels;
using BTCPayServer.Services;
using BTCPayServer.Services.Rates;
using BTCPayServer.Services.Stores;
using Microsoft.AspNetCore.Authorization;
@@ -20,6 +21,7 @@ namespace BTCPayServer.Controllers
public class UIUserStoresController : Controller
{
private readonly StoreRepository _repo;
private readonly SettingsRepository _settingsRepository;
private readonly UserManager<ApplicationUser> _userManager;
private readonly RateFetcher _rateFactory;
public string CreatedStoreId { get; set; }
@@ -27,11 +29,13 @@ namespace BTCPayServer.Controllers
public UIUserStoresController(
UserManager<ApplicationUser> userManager,
StoreRepository storeRepository,
RateFetcher rateFactory)
RateFetcher rateFactory,
SettingsRepository settingsRepository)
{
_repo = storeRepository;
_userManager = userManager;
_rateFactory = rateFactory;
_settingsRepository = settingsRepository;
}
[HttpGet]
@@ -62,7 +66,7 @@ namespace BTCPayServer.Controllers
var vm = new CreateStoreViewModel
{
IsFirstStore = !(stores.Any() || skipWizard),
DefaultCurrency = StoreBlob.StandardDefaultCurrency,
DefaultCurrency = (await _settingsRepository.GetSettingAsync<PoliciesSettings>())?.DefaultCurrency ?? StoreBlob.StandardDefaultCurrency,
Exchanges = GetExchangesSelectList(null)
};