Skip to content

Commit

Permalink
Видеть при подаче заявки как игрок (#2922)
Browse files Browse the repository at this point in the history
* Пофиксить неймспейс

* Видеть при подаче заявки как игрок
  • Loading branch information
leotsarev authored Nov 21, 2024
1 parent b062806 commit b3209f5
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/JoinRpg.Domain/AccessArgumentsFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using JoinRpg.DataModel;
using JoinRpg.PrimitiveTypes;

namespace JoinRpg.Domain;

Expand Down
1 change: 1 addition & 0 deletions src/JoinRpg.Domain/CharacterFields/FieldWithValue.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using JoinRpg.Helpers;
using JoinRpg.PrimitiveTypes;
using JoinRpg.PrimitiveTypes.ProjectMetadata;

namespace JoinRpg.Domain;
Expand Down
7 changes: 7 additions & 0 deletions src/JoinRpg.Portal/Views/Claim/Add.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
}
}

@if (Model.HasMasterAccess)
{
<div class="alert alert-info">
Несмотря на то, что у вас есть мастерские права, форма заявки показывается так, как ее видят игроки (мастерские поля не видны).
</div>
}

@if (Model.ClaimApplyRules != null)
{
<div>@Model.ClaimApplyRules</div>
Expand Down
27 changes: 12 additions & 15 deletions src/JoinRpg.PrimitiveTypes/AccessArguments.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
namespace JoinRpg.Domain;
namespace JoinRpg.PrimitiveTypes;

public record class AccessArguments(
/// <summary>
/// true if a user is logged in, he is a master of this game, he has access to the character or claim
/// </summary>
bool MasterAccess,
/// <summary>
/// true if a user is logged in and he is assigned with the character
/// </summary>
bool PlayerAccessToCharacter,
/// <summary>
/// true if a user is logged in and he is the owner of the claim
/// </summary>
bool PlayerAccesToClaim,
bool EditAllowed)
{
/// <summary>
/// true if a user is logged in, he is a master of this game, he has access to the character or claim
/// </summary>
public bool MasterAccess { get; } = MasterAccess;

/// <summary>
/// true if a user is logged in and he is assigned with the character
/// </summary>
public bool PlayerAccessToCharacter { get; } = PlayerAccessToCharacter;

/// <summary>
/// true if a user is logged in and he is the owner of the claim
/// </summary>
public bool PlayerAccesToClaim { get; } = PlayerAccesToClaim;

/// <summary>
/// true if there is master or player access to the character
Expand All @@ -31,5 +26,7 @@ public record class AccessArguments(
/// </summary>
public bool AnyAccessToClaim { get; } = PlayerAccesToClaim || PlayerAccesToClaim;

public AccessArguments WithoutMasterAccess() => this with { MasterAccess = false };

public override string ToString() => $"AccessArguments(MasterAccess:{MasterAccess}, CharacterAccess:{PlayerAccessToCharacter}, PlayerAccesToClaim:{PlayerAccesToClaim}";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using JoinRpg.DataModel;
using JoinRpg.Domain;
using JoinRpg.Helpers;

namespace JoinRpg.PrimitiveTypes.ProjectMetadata;
Expand Down
7 changes: 6 additions & 1 deletion src/JoinRpg.WebPortal.Models/Claims/AddClaimViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public AddClaimViewModel Fill(Character claimSource, int playerUserId, ProjectIn
TargetName = claimSource.CharacterName;
Description = claimSource.Description.ToHtmlString();
ClaimApplyRules = claimSource.Project.Details.ClaimApplyRules.ToHtmlString();
Fields = new CustomFieldsViewModel(claimSource, projectInfo, AccessArgumentsFactory.CreateForAdd(claimSource, playerUserId), overrideValues: overrideValues);
var accessArguments = AccessArgumentsFactory.CreateForAdd(claimSource, playerUserId);
HasMasterAccess = accessArguments.MasterAccess;
Fields = new CustomFieldsViewModel(claimSource, projectInfo, accessArguments.WithoutMasterAccess(), overrideValues: overrideValues);
return this;
}
Expand All @@ -75,4 +78,6 @@ public AddClaimViewModel Fill(Character claimSource, int playerUserId, ProjectIn
public bool IsProjectRelatedReason { get; private set; }

public bool ProjectAllowsMultipleCharacters { get; private set; }

public bool HasMasterAccess { get; private set; }
}
1 change: 1 addition & 0 deletions src/JoinRpg.WebPortal.Models/Claims/ClaimStatusView.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using JoinRpg.DataModel;
using JoinRpg.Domain;
using JoinRpg.PrimitiveTypes;

namespace JoinRpg.Web.Models;

Expand Down
1 change: 1 addition & 0 deletions src/JoinRpg.WebPortal.Models/CustomFieldsViewModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using JoinRpg.Domain;
using JoinRpg.Helpers.Web;
using JoinRpg.Markdown;
using JoinRpg.PrimitiveTypes;
using JoinRpg.PrimitiveTypes.ProjectMetadata;
using JoinRpg.Web.Helpers;

Expand Down

0 comments on commit b3209f5

Please sign in to comment.