OrchardCMS / Orchard

Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
https://orchardproject.net
BSD 3-Clause "New" or "Revised" License
2.37k stars 1.12k forks source link

NotDraftable ContentItem with a PublishLaterPart and no publish date set, do not Publish automatically on save #4674

Open orchardbot opened 9 years ago

orchardbot commented 9 years ago

@StanleyGoldman created: https://orchard.codeplex.com/workitem/20845

Repro Steps: Cook Core Recipe Modify Page ContentItem defintion to remove Draftable Create a New Page Hit Save Observe that the page is drafted, not published

The Issue is because of the faulty logic around the usage of IPublishingControlAspect. The EditPost method of \src\Orchard.Web\Core\Contents\Controllers\AdminController.cs [HttpPost, ActionName("Edit")] [Mvc.FormValueRequired("submit.Save")] public ActionResult EditPOST(int id, string returnUrl) { return EditPOST(id, returnUrl, contentItem => { if (!contentItem.Has() && !contentItem.TypeDefinition.Settings.GetModel().Draftable) _contentManager.Publish(contentItem); }); }

Should read like such... var isDraftable = contentItem.TypeDefinition.Settings.GetModel().Draftable; var scheduledToPublishLater = contentItem.Has() && contentItem.As().ScheduledPublishUtc.Value.HasValue; if (!isDraftable && !scheduledToPublishLater) { ... }

orchardbot commented 9 years ago

@StanleyGoldman commented:

Pull Request

orchardbot commented 9 years ago

@sebastienros commented:

If I understand correctly, it has PublishLaterPart but because it's not draftable it should be published right now, but having PublishLaterPart conflicts and creates a draft ?

If this is the case, maybe there should be a warning in the editor when PublishLaterPart is attached to a type which is not draftable.

orchardbot commented 9 years ago

@StanleyGoldman commented:

In the editor upon creating an instance of said ContentItem?

orchardbot commented 9 years ago

@StanleyGoldman commented:

I can add that to the pull request a bit later tonight.

orchardbot commented 9 years ago

@sebastienros commented:

please do

orchardbot commented 9 years ago

@StanleyGoldman commented:

And I have one more question...

Based on this conversation, I think the boolean condition above should change. Currently, even though the ContentItem is not Draftable, the bug leaves the ContentItem in a draft state.

So, what should become of the ContentItem? Should we publish it or leave it as a draft? And what if they set a time in PublishLaterPart?

orchardbot commented 9 years ago

@sebastienros commented:

If not draftable, the draft should be removed.

If it's not draftable we should not take the PublishLaterPart into account, and display the warning.

orchardbot commented 9 years ago

@StanleyGoldman commented:

Updated Pull Request