From bf5ce9cdb08aa2ee25124c2880484f791b3528c6 Mon Sep 17 00:00:00 2001 From: pavelbannov Date: Thu, 8 Sep 2022 16:35:52 +0300 Subject: [PATCH] Quota: admin replaced with manager --- .../EF/Model/Tenant/DbQuota.cs | 6 ++-- .../Quota/Features/CountAdminFeature.cs | 3 +- ...0141345_CoreDbContext_Upgrade1.Designer.cs | 6 ++-- .../20220830141345_CoreDbContext_Upgrade1.cs | 32 +++++++++++++++-- .../CoreDbContextModelSnapshot.cs | 6 ++-- ...0141345_CoreDbContext_Upgrade1.Designer.cs | 6 ++-- .../20220830141345_CoreDbContext_Upgrade1.cs | 34 ++++++++++++++++--- .../CoreDbContextModelSnapshot.cs | 6 ++-- .../ApiModels/ResponseDto/QuotaDto.cs | 3 +- web/ASC.Web.Api/Core/QuotaHelper.cs | 20 +++++------ .../PublicResources/Resource.Designer.cs | 26 +++++++------- .../PublicResources/Resource.resx | 4 +-- 12 files changed, 101 insertions(+), 51 deletions(-) diff --git a/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs b/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs index 44227d0546..4d71fb7819 100644 --- a/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs +++ b/common/ASC.Core.Common/EF/Model/Tenant/DbQuota.cs @@ -62,7 +62,7 @@ public static class DbQuotaExtension Name = "trial", Description = null, MaxFileSize = 100, - Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", Price = decimal.Parse("0,00"), ProductId = null, Visible = false @@ -73,7 +73,7 @@ public static class DbQuotaExtension Name = "admin", Description = null, MaxFileSize = 1024, - Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", Price = decimal.Parse("30,00"), ProductId = "1002", Visible = true @@ -84,7 +84,7 @@ public static class DbQuotaExtension Name = "startup", Description = null, MaxFileSize = 100, - Features = "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", + Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", Price = decimal.Parse("0,00"), ProductId = null, Visible = false diff --git a/common/ASC.Core.Common/Quota/Features/CountAdminFeature.cs b/common/ASC.Core.Common/Quota/Features/CountAdminFeature.cs index 84d9792e48..9717ed0b6c 100644 --- a/common/ASC.Core.Common/Quota/Features/CountAdminFeature.cs +++ b/common/ASC.Core.Common/Quota/Features/CountAdminFeature.cs @@ -29,11 +29,12 @@ namespace ASC.Core.Common.Quota.Features; public class CountManagerFeature : TenantQuotaFeatureCount { public override bool Paid { get => true; } - public override string Name { get => "admin"; } + public override string Name { get => "manager"; } public CountManagerFeature(TenantQuota tenantQuota) : base(tenantQuota) { } } + public class CountManagerChecker : ITenantQuotaFeatureChecker { private readonly ITenantQuotaFeatureStatisticCount _tenantQuotaFeatureStatistic; diff --git a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs index 99001894e4..43af83fca7 100644 --- a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs +++ b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs @@ -78,7 +78,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb new { Tenant = -1, - Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 100L, Name = "trial", Price = 0.00m, @@ -87,7 +87,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb new { Tenant = -2, - Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 1024L, Name = "admin", Price = 30.00m, @@ -97,7 +97,7 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb new { Tenant = -3, - Features = "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", + Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", MaxFileSize = 100L, Name = "startup", Price = 0.00m, diff --git a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs index d61899ad37..c4e9e74f51 100644 --- a/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs +++ b/migrations/mysql/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs @@ -1,3 +1,29 @@ +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; @@ -61,17 +87,17 @@ namespace ASC.Migrations.MySql.Migrations.CoreDb keyColumn: "tenant", keyValue: -1, columns: new[] { "features", "max_file_size", "name", "product_id" }, - values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", 100L, "trial", null }); + values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 100L, "trial", null }); migrationBuilder.InsertData( table: "tenants_quota", columns: new[] { "tenant", "description", "features", "max_file_size", "name", "product_id" }, - values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", 100L, "startup", null }); + values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", 100L, "startup", null }); migrationBuilder.InsertData( table: "tenants_quota", columns: new[] { "tenant", "description", "features", "max_file_size", "name", "price", "product_id", "visible" }, - values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", 1024L, "admin", 30.00m, "1002", true }); + values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 1024L, "admin", 30.00m, "1002", true }); } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs b/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs index dd313ec9af..bc3c37acb3 100644 --- a/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs +++ b/migrations/mysql/CoreDbContext/CoreDbContextModelSnapshot.cs @@ -76,7 +76,7 @@ namespace ASC.Migrations.MySql.Migrations new { Tenant = -1, - Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 100L, Name = "trial", Price = 0.00m, @@ -85,7 +85,7 @@ namespace ASC.Migrations.MySql.Migrations new { Tenant = -2, - Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 1024L, Name = "admin", Price = 30.00m, @@ -95,7 +95,7 @@ namespace ASC.Migrations.MySql.Migrations new { Tenant = -3, - Features = "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", + Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", MaxFileSize = 100L, Name = "startup", Price = 0.00m, diff --git a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs index 488134a4cd..937c297cfe 100644 --- a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs +++ b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.Designer.cs @@ -73,7 +73,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb new { Tenant = -1, - Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 100L, Name = "trial", Price = 0.00m, @@ -82,7 +82,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb new { Tenant = -2, - Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 1024L, Name = "admin", Price = 30.00m, @@ -92,7 +92,7 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb new { Tenant = -3, - Features = "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", + Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", MaxFileSize = 100L, Name = "startup", Price = 0.00m, diff --git a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs index 64998d666f..7f6a2273b6 100644 --- a/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs +++ b/migrations/postgre/CoreDbContext/20220830141345_CoreDbContext_Upgrade1.cs @@ -1,5 +1,31 @@ -using System; +// (c) Copyright Ascensio System SIA 2010-2022 +// +// This program is a free software product. +// You can redistribute it and/or modify it under the terms +// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software +// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended +// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of +// any third-party rights. +// +// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty +// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see +// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html +// +// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021. +// +// The interactive user interfaces in modified source and object code versions of the Program must +// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3. +// +// Pursuant to Section 7(b) of the License you must retain the original Product logo when +// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under +// trademark law for use of our trademarks. +// +// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing +// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 +// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + using Microsoft.EntityFrameworkCore.Migrations; + using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -67,19 +93,19 @@ namespace ASC.Migrations.PostgreSql.Migrations.CoreDb keyColumn: "tenant", keyValue: -1, columns: new[] { "features", "max_file_size", "name", "product_id" }, - values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", 100L, "trial", null }); + values: new object[] { "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 100L, "trial", null }); migrationBuilder.InsertData( schema: "onlyoffice", table: "tenants_quota", columns: new[] { "tenant", "description", "features", "max_file_size", "name", "visible" }, - values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", 100L, "startup", false }); + values: new object[] { -3, null, "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", 100L, "startup", false }); migrationBuilder.InsertData( schema: "onlyoffice", table: "tenants_quota", columns: new[] { "tenant", "description", "features", "max_file_size", "name", "price", "product_id", "visible" }, - values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", 1024L, "admin", 30.00m, "1002", true }); + values: new object[] { -2, null, "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", 1024L, "admin", 30.00m, "1002", true }); } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs b/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs index 2b9aca86fa..1a1c4b8f7b 100644 --- a/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs +++ b/migrations/postgre/CoreDbContext/CoreDbContextModelSnapshot.cs @@ -71,7 +71,7 @@ namespace ASC.Migrations.PostgreSql.Migrations new { Tenant = -1, - Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "trial,audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 100L, Name = "trial", Price = 0.00m, @@ -80,7 +80,7 @@ namespace ASC.Migrations.PostgreSql.Migrations new { Tenant = -2, - Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,admin:1", + Features = "audit,ldap,sso,whitelabel,restore,total_size:10995116277760,manager:1", MaxFileSize = 1024L, Name = "admin", Price = 30.00m, @@ -90,7 +90,7 @@ namespace ASC.Migrations.PostgreSql.Migrations new { Tenant = -3, - Features = "free,audit,ldap,sso,restore,total_size:2147483648,admin:5,rooms:3", + Features = "free,audit,ldap,sso,restore,total_size:2147483648,manager:5,rooms:3", MaxFileSize = 100L, Name = "startup", Price = 0.00m, diff --git a/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaDto.cs b/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaDto.cs index ae40080e61..07ebdfb751 100644 --- a/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaDto.cs +++ b/web/ASC.Web.Api/ApiModels/ResponseDto/QuotaDto.cs @@ -83,7 +83,6 @@ public class FeatureUsedDto public class FeaturePriceRangeDto { - public object Value { get; set; } - public object Min { get; set; } + public object Step { get; set; } public object Max { get; set; } } diff --git a/web/ASC.Web.Api/Core/QuotaHelper.cs b/web/ASC.Web.Api/Core/QuotaHelper.cs index 21f8e09f6b..3bbdc68dd8 100644 --- a/web/ASC.Web.Api/Core/QuotaHelper.cs +++ b/web/ASC.Web.Api/Core/QuotaHelper.cs @@ -35,6 +35,7 @@ public class QuotaHelper private readonly RegionHelper _regionHelper; private readonly IServiceProvider _serviceProvider; private const int Max = 999; + public QuotaHelper(TenantManager tenantManager, RegionHelper regionHelper, IServiceProvider serviceProvider) { _tenantManager = tenantManager; @@ -44,18 +45,17 @@ public class QuotaHelper public IEnumerable GetQuotas() { - var tenantQuota = _tenantManager.GetTenantQuota(_tenantManager.GetCurrentTenant().Id); var quotaList = _tenantManager.GetTenantQuotas(false); var priceInfo = _tenantManager.GetProductPriceInfo(); var currentRegion = _regionHelper.GetCurrentRegionInfo(); - return quotaList.Select(x => ToQuotaDto(x, tenantQuota, priceInfo, currentRegion)).ToList(); + return quotaList.Select(x => ToQuotaDto(x, priceInfo, currentRegion)).ToList(); } - private QuotaDto ToQuotaDto(TenantQuota quota, TenantQuota tenantQuota, IDictionary> priceInfo, RegionInfo currentRegion) + private QuotaDto ToQuotaDto(TenantQuota quota, IDictionary> priceInfo, RegionInfo currentRegion) { var price = GetPrice(quota, priceInfo, currentRegion); - var features = GetFeatures(quota, tenantQuota, GetPriceString(price, currentRegion)); + var features = GetFeatures(quota, GetPriceString(price, currentRegion)); return new QuotaDto { @@ -100,7 +100,7 @@ public class QuotaHelper return string.Format("{0}{1}", currentRegion.CurrencySymbol, priceString); } - private IEnumerable GetFeatures(TenantQuota quota, TenantQuota tenantQuota, string price) + private IEnumerable GetFeatures(TenantQuota quota, string price) { var assembly = GetType().Assembly; @@ -152,9 +152,8 @@ public class QuotaHelper { result.Price.Range = new FeaturePriceRangeDto { - Value = length.Value, - Min = tenantQuota.GetFeature(length.Name).Value, // must set to used quota - Max = Max * length.Value, + Step = length.Value, + Max = Max * length.Value }; } } @@ -171,9 +170,8 @@ public class QuotaHelper { result.Price.Range = new FeaturePriceRangeDto { - Value = count.Value, - Min = tenantQuota.GetFeature(count.Name).Value, - Max = Max * count.Value, + Step = count.Value, + Max = Max * count.Value }; } } diff --git a/web/ASC.Web.Core/PublicResources/Resource.Designer.cs b/web/ASC.Web.Core/PublicResources/Resource.Designer.cs index 5240acd435..9bdb19cc55 100644 --- a/web/ASC.Web.Core/PublicResources/Resource.Designer.cs +++ b/web/ASC.Web.Core/PublicResources/Resource.Designer.cs @@ -2157,30 +2157,30 @@ namespace ASC.Web.Core.PublicResources { } } + /// + /// Looks up a localized string similar to Tracking user logins & action. + /// + public static string TariffsFeature_audit { + get { + return ResourceManager.GetString("TariffsFeature_audit", resourceCulture); + } + } + /// /// Looks up a localized string similar to Number of managers. /// - public static string TariffsFeature_admin_price_count { + public static string TariffsFeature_manager_price_count { get { - return ResourceManager.GetString("TariffsFeature_admin_price_count", resourceCulture); + return ResourceManager.GetString("TariffsFeature_manager_price_count", resourceCulture); } } /// /// Looks up a localized string similar to {0} per manager/month. /// - public static string TariffsFeature_admin_price_per { + public static string TariffsFeature_manager_price_per { get { - return ResourceManager.GetString("TariffsFeature_admin_price_per", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Tracking user logins & action. - /// - public static string TariffsFeature_audit { - get { - return ResourceManager.GetString("TariffsFeature_audit", resourceCulture); + return ResourceManager.GetString("TariffsFeature_manager_price_per", resourceCulture); } } diff --git a/web/ASC.Web.Core/PublicResources/Resource.resx b/web/ASC.Web.Core/PublicResources/Resource.resx index c95af91943..2d11644572 100644 --- a/web/ASC.Web.Core/PublicResources/Resource.resx +++ b/web/ASC.Web.Core/PublicResources/Resource.resx @@ -825,10 +825,10 @@ Virtual room {0} invitations sent successfully. - + Number of managers - + {0} per manager/month