Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AC-1646] Rename LimitCollectionCdOwnerAdmin column #3300

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class OrganizationCollectionManagementUpdateRequestModel

public virtual Organization ToOrganization(Organization existingOrganization)
{
existingOrganization.LimitCollectionCdOwnerAdmin = LimitCreateDeleteOwnerAdmin;
existingOrganization.LimitCollectionCreationDeletion = LimitCreateDeleteOwnerAdmin;
return existingOrganization;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public OrganizationResponseModel(Organization organization, string obj = "organi
SmServiceAccounts = organization.SmServiceAccounts;
MaxAutoscaleSmSeats = organization.MaxAutoscaleSmSeats;
MaxAutoscaleSmServiceAccounts = organization.MaxAutoscaleSmServiceAccounts;
LimitCollectionCdOwnerAdmin = organization.LimitCollectionCdOwnerAdmin;
LimitCollectionCreationDeletion = organization.LimitCollectionCreationDeletion;
}

public Guid Id { get; set; }
Expand Down Expand Up @@ -98,7 +98,7 @@ public OrganizationResponseModel(Organization organization, string obj = "organi
public int? SmServiceAccounts { get; set; }
public int? MaxAutoscaleSmSeats { get; set; }
public int? MaxAutoscaleSmServiceAccounts { get; set; }
public bool LimitCollectionCdOwnerAdmin { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
}

public class OrganizationSubscriptionResponseModel : OrganizationResponseModel
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Models/Response/ProfileOrganizationResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails orga
FamilySponsorshipToDelete = organization.FamilySponsorshipToDelete;
FamilySponsorshipValidUntil = organization.FamilySponsorshipValidUntil;
AccessSecretsManager = organization.AccessSecretsManager;
LimitCollectionCdOwnerAdmin = organization.LimitCollectionCdOwnerAdmin;
LimitCollectionCreationDeletion = organization.LimitCollectionCreationDeletion;

if (organization.SsoConfig != null)
{
Expand Down Expand Up @@ -114,5 +114,5 @@ public ProfileOrganizationResponseModel(OrganizationUserOrganizationDetails orga
public DateTime? FamilySponsorshipValidUntil { get; set; }
public bool? FamilySponsorshipToDelete { get; set; }
public bool AccessSecretsManager { get; set; }
public bool LimitCollectionCdOwnerAdmin { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private async Task CanCreateAsync(AuthorizationHandlerContext context, Collectio
CurrentContextOrganization org)
{
// If false, all organization members are allowed to create collections
if (!org.LimitCollectionCdOwnerAdmin)
if (!org.LimitCollectionCreationDeletion)
{
context.Succeed(requirement);
return;
Expand Down Expand Up @@ -104,7 +104,7 @@ await _currentContext.ProviderUserForOrgAsync(org.Id))
}

// The limit collection management setting is enabled and we are not an Admin (above condition), fail
if (org.LimitCollectionCdOwnerAdmin)
if (org.LimitCollectionCreationDeletion)
{
context.Fail();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Context/CurrentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ public async Task<bool> ViewAssignedCollections(Guid orgId)
var org = GetOrganization(orgId);
if (org != null)
{
canCreateNewCollections = !org.LimitCollectionCdOwnerAdmin || org.Permissions.CreateNewCollections;
canCreateNewCollections = !org.LimitCollectionCreationDeletion || org.Permissions.CreateNewCollections;
}
return await EditAssignedCollections(orgId)
|| await DeleteAssignedCollections(orgId)
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Context/CurrentContextOrganization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public CurrentContextOrganization(OrganizationUserOrganizationDetails orgUser)
Type = orgUser.Type;
Permissions = CoreHelpers.LoadClassFromJsonData<Permissions>(orgUser.Permissions);
AccessSecretsManager = orgUser.AccessSecretsManager && orgUser.UseSecretsManager;
LimitCollectionCdOwnerAdmin = orgUser.LimitCollectionCdOwnerAdmin;
LimitCollectionCreationDeletion = orgUser.LimitCollectionCreationDeletion;
}

public Guid Id { get; set; }
public OrganizationUserType Type { get; set; }
public Permissions Permissions { get; set; } = new();
public bool AccessSecretsManager { get; set; }
public bool LimitCollectionCdOwnerAdmin { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
}
2 changes: 1 addition & 1 deletion src/Core/Entities/Organization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class Organization : ITableObject<Guid>, ISubscriber, IStorable, IStorabl
/// <summary>
/// Refers to the ability for an organization to limit collection creation and deletion to owners and admins only
/// </summary>
public bool LimitCollectionCdOwnerAdmin { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }

public void SetNewId()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ public class OrganizationUserOrganizationDetails
public bool UsePasswordManager { get; set; }
public int? SmSeats { get; set; }
public int? SmServiceAccounts { get; set; }
public bool LimitCollectionCdOwnerAdmin { get; set; }
public bool LimitCollectionCreationDeletion { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public Organization ToOrganization()
RevisionDate = RevisionDate,
MaxAutoscaleSeats = MaxAutoscaleSeats,
OwnersNotifiedOfAutoscaling = OwnersNotifiedOfAutoscaling,
LimitCollectionCdOwnerAdmin = LimitCollectionCdOwnerAdmin,
LimitCollectionCreationDeletion = LimitCollectionCreationDeletion,
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected override void OnModelCreating(ModelBuilder builder)
eGroup.Property(c => c.Id).ValueGeneratedNever();
eInstallation.Property(c => c.Id).ValueGeneratedNever();
eOrganization.Property(c => c.Id).ValueGeneratedNever();
eOrganization.Property(c => c.LimitCollectionCdOwnerAdmin)
eOrganization.Property(c => c.LimitCollectionCreationDeletion)
.ValueGeneratedNever()
.HasDefaultValue(true);
eOrganizationSponsorship.Property(c => c.Id).ValueGeneratedNever();
Expand Down
8 changes: 4 additions & 4 deletions src/Sql/dbo/Stored Procedures/Organization_Create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@MaxAutoscaleSmSeats INT= null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCdOwnerAdmin BIT = 0
@LimitCollectionCreationDeletion BIT = 0
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -110,7 +110,7 @@ BEGIN
[MaxAutoscaleSmSeats],
[MaxAutoscaleSmServiceAccounts],
[SecretsManagerBeta],
[LimitCollectionCdOwnerAdmin]
[LimitCollectionCreationDeletion]
)
VALUES
(
Expand Down Expand Up @@ -166,6 +166,6 @@ BEGIN
@MaxAutoscaleSmSeats,
@MaxAutoscaleSmServiceAccounts,
@SecretsManagerBeta,
@LimitCollectionCdOwnerAdmin
@LimitCollectionCreationDeletion
)
END
END
4 changes: 2 additions & 2 deletions src/Sql/dbo/Stored Procedures/Organization_Update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
@MaxAutoscaleSmSeats INT = null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCdOwnerAdmin BIT = 1
@LimitCollectionCreationDeletion BIT = 1
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -110,7 +110,7 @@ BEGIN
[MaxAutoscaleSmSeats] = @MaxAutoscaleSmSeats,
[MaxAutoscaleSmServiceAccounts] = @MaxAutoscaleSmServiceAccounts,
[SecretsManagerBeta] = @SecretsManagerBeta,
[LimitCollectionCdOwnerAdmin] = @LimitCollectionCdOwnerAdmin
[LimitCollectionCreationDeletion] = @LimitCollectionCreationDeletion
WHERE
[Id] = @Id
END
2 changes: 1 addition & 1 deletion src/Sql/dbo/Tables/Organization.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
[MaxAutoscaleSmSeats] INT NULL,
[MaxAutoscaleSmServiceAccounts] INT NULL,
[SecretsManagerBeta] BIT NOT NULL CONSTRAINT [DF_Organization_SecretsManagerBeta] DEFAULT (0),
[LimitCollectionCdOwnerAdmin] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCdOwnerAdmin] DEFAULT (1),
[LimitCollectionCreationDeletion] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCreationDeletion] DEFAULT (1),
CONSTRAINT [PK_Organization] PRIMARY KEY CLUSTERED ([Id] ASC)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SELECT
O.[UsePasswordManager],
O.[SmSeats],
O.[SmServiceAccounts],
O.[LimitCollectionCdOwnerAdmin]
O.[LimitCollectionCreationDeletion]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public async Task CanCreateAsync_Success(

organization.Type = userType;
organization.Permissions.CreateNewCollections = createNewCollection;
organization.LimitCollectionCdOwnerAdmin = limitCollectionCreateDelete;
organization.LimitCollectionCreationDeletion = limitCollectionCreateDelete;

var context = new AuthorizationHandlerContext(
new[] { CollectionOperations.Create },
Expand Down Expand Up @@ -104,7 +104,7 @@ public async Task CanDeleteAsync_Success(

organization.Type = userType;
organization.Permissions.DeleteAnyCollection = deleteAnyCollection;
organization.LimitCollectionCdOwnerAdmin = limitCollectionCreateDelete;
organization.LimitCollectionCreationDeletion = limitCollectionCreateDelete;

var context = new AuthorizationHandlerContext(
new[] { CollectionOperations.Delete },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
--Add column 'LimitCollectionCdOwnerAdmin' to 'Organization' table
IF COL_LENGTH('[dbo].[Organization]', 'LimitCollectionCdOwnerAdmin') IS NULL
--Add column 'LimitCollectionCreationDeletion' to 'Organization' table
IF COL_LENGTH('[dbo].[Organization]', 'LimitCollectionCreationDeletion') IS NULL
BEGIN
ALTER TABLE
[dbo].[Organization]
ADD
[LimitCollectionCdOwnerAdmin] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCdOwnerAdmin] DEFAULT (1)
[LimitCollectionCreationDeletion] BIT NOT NULL CONSTRAINT [DF_Organization_LimitCollectionCreationDeletion] DEFAULT (1)
END
GO


/**
ORGANIZATION STORED PROCEDURES
*/
--Alter `Organization_Create` sproc to include `LimitCollectionCdOwnerAdmin` column and default value

--Alter `Organization_Create` sproc to include `LimitCollectionCreationDeletion` column and default value
CREATE OR ALTER PROCEDURE [dbo].[Organization_Create]
@Id UNIQUEIDENTIFIER OUTPUT,
@Identifier NVARCHAR(50),
Expand Down Expand Up @@ -67,7 +67,7 @@ CREATE OR ALTER PROCEDURE [dbo].[Organization_Create]
@MaxAutoscaleSmSeats INT= null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCdOwnerAdmin BIT = 0
@LimitCollectionCreationDeletion BIT = 0
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -126,7 +126,7 @@ BEGIN
[MaxAutoscaleSmSeats],
[MaxAutoscaleSmServiceAccounts],
[SecretsManagerBeta],
[LimitCollectionCdOwnerAdmin]
[LimitCollectionCreationDeletion]
)
VALUES
(
Expand Down Expand Up @@ -182,12 +182,12 @@ BEGIN
@MaxAutoscaleSmSeats,
@MaxAutoscaleSmServiceAccounts,
@SecretsManagerBeta,
@LimitCollectionCdOwnerAdmin
@LimitCollectionCreationDeletion
)
END
GO

--Alter `Organization_Update` sproc to include `LimitCollectionCdOwnerAdmin` column
--Alter `Organization_Update` sproc to include `LimitCollectionCreationDeletion` column
CREATE OR ALTER PROCEDURE [dbo].[Organization_Update]
@Id UNIQUEIDENTIFIER,
@Identifier NVARCHAR(50),
Expand Down Expand Up @@ -241,7 +241,7 @@ CREATE OR ALTER PROCEDURE [dbo].[Organization_Update]
@MaxAutoscaleSmSeats INT = null,
@MaxAutoscaleSmServiceAccounts INT = null,
@SecretsManagerBeta BIT = 0,
@LimitCollectionCdOwnerAdmin BIT = 1
@LimitCollectionCreationDeletion BIT = 1
AS
BEGIN
SET NOCOUNT ON
Expand Down Expand Up @@ -300,7 +300,7 @@ BEGIN
[MaxAutoscaleSmSeats] = @MaxAutoscaleSmSeats,
[MaxAutoscaleSmServiceAccounts] = @MaxAutoscaleSmServiceAccounts,
[SecretsManagerBeta] = @SecretsManagerBeta,
[LimitCollectionCdOwnerAdmin] = @LimitCollectionCdOwnerAdmin
[LimitCollectionCreationDeletion] = @LimitCollectionCreationDeletion
WHERE
[Id] = @Id
END
Expand All @@ -310,8 +310,8 @@ GO
/**
ORGANIZATION VIEWS
*/
--Add 'LimitCollectionCdOwnerAdmin` to OrganizationUserOrganizationDetailsView

--Add 'LimitCollectionCreationDeletion` to OrganizationUserOrganizationDetailsView
CREATE OR ALTER VIEW [dbo].[OrganizationUserOrganizationDetailsView]
AS
SELECT
Expand Down Expand Up @@ -359,7 +359,7 @@ SELECT
O.[UsePasswordManager],
O.[SmSeats],
O.[SmServiceAccounts],
O.[LimitCollectionCdOwnerAdmin]
O.[LimitCollectionCreationDeletion]
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
Expand All @@ -386,7 +386,7 @@ GO
/**
PROVIDER VIEWS - not directly modified, but access Organization table
*/

--Manually refresh ProviderOrganizationOrganizationDetailsView
IF OBJECT_ID('[dbo].[ProviderOrganizationOrganizationDetailsView]') IS NOT NULL
BEGIN
Expand All @@ -399,4 +399,4 @@ IF OBJECT_ID('[dbo].[ProviderUserProviderOrganizationDetailsView]') IS NOT NULL
BEGIN
EXECUTE sp_refreshsqlmodule N'[dbo].[ProviderUserProviderOrganizationDetailsView]';
END
GO
GO

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class LimitCollectionCreateDelete : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "LimitCollectionCdOwnerAdmin",
name: "LimitCollectionCreationDeletion",
table: "Organization",
type: "tinyint(1)",
nullable: false,
Expand All @@ -22,7 +22,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LimitCollectionCdOwnerAdmin",
name: "LimitCollectionCreationDeletion",
table: "Organization");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(100)
.HasColumnType("varchar(100)");

b.Property<bool>("LimitCollectionCdOwnerAdmin")
b.Property<bool>("LimitCollectionCreationDeletion")
.HasColumnType("tinyint(1)")
.HasDefaultValue(true);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class LimitCollectionCreateDelete : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "LimitCollectionCdOwnerAdmin",
name: "LimitCollectionCreationDeletion",
table: "Organization",
type: "boolean",
nullable: false,
Expand All @@ -22,7 +22,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "LimitCollectionCdOwnerAdmin",
name: "LimitCollectionCreationDeletion",
table: "Organization");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasMaxLength(100)
.HasColumnType("character varying(100)");

b.Property<bool>("LimitCollectionCdOwnerAdmin")
b.Property<bool>("LimitCollectionCreationDeletion")
.HasColumnType("boolean")
.HasDefaultValue(true);

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading