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

Add AutorouteSettings.AllowSetAsHomePage to control whether user can set a content to display on a home page #8424

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 @@ -18,6 +18,7 @@ public class AutorouteSettings {
public AutorouteSettings() {
PerItemConfiguration = false;
AllowCustomPattern = true;
AllowSetAsHomePage = true;
UseCulturePattern = false;
AutomaticAdjustmentOnEdit = false;
PatternDefinitions = "[]";
Expand All @@ -27,6 +28,7 @@ public AutorouteSettings() {

public bool PerItemConfiguration { get; set; }
public bool AllowCustomPattern { get; set; }
public bool AllowSetAsHomePage { get; set; }
public bool UseCulturePattern { get; set; }
public bool AutomaticAdjustmentOnEdit { get; set; }
public bool? IsDefault { get; set; }
Expand Down Expand Up @@ -100,6 +102,7 @@ public List<DefaultPattern> DefaultPatterns {
public void Build(ContentTypePartDefinitionBuilder builder) {
builder.WithSetting("AutorouteSettings.PerItemConfiguration", PerItemConfiguration.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AllowCustomPattern", AllowCustomPattern.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AllowSetAsHomePage", AllowSetAsHomePage.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.UseCulturePattern", UseCulturePattern.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", AutomaticAdjustmentOnEdit.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("AutorouteSettings.PatternDefinitions", PatternDefinitions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
<div>
@Html.CheckBoxFor(m => m.AllowCustomPattern)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowCustomPattern)">@T("Allow custom patterns")</label>
<span class="hint">@T("Allow the user to change the pattern on each item")</span>
<span class="hint">@T("Allow the user to change the pattern on each item.")</span>
</div>
</fieldset>
<fieldset>
<div>
@Html.CheckBoxFor(m => m.AllowSetAsHomePage)
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.AllowSetAsHomePage)">@T("Allow \"Set as home page\"")</label>
<span class="hint">@T("Allow the user to set a content item of this type as the home page.")</span>
<span class="hint">@T("NOTE: Certain combinations of content type definitions and permission settings can create circumstances for non-Admin users with Dashboard access to remove the home page without the ability to set another one. Use this option with caution.")</span>
</div>
</fieldset>
<fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

</fieldset>
@if (!Model.IsHomePage) {
if (AuthorizedFor(Permissions.SetHomePage)) {
if (AuthorizedFor(Permissions.SetHomePage) && Model.Settings.AllowSetAsHomePage) {
<fieldset>
<span class="checkbox-and-label">
@Html.CheckBoxFor(m => m.PromoteToHomePage)
Expand Down