Adds publishById method to contentController
This commit is contained in:
@@ -531,8 +531,25 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
|
||||
*/
|
||||
publish: function (content, isNew, files) {
|
||||
return saveContentItem(content, "publish" + (isNew ? "New" : ""), files);
|
||||
},
|
||||
|
||||
publishById: function(id){
|
||||
|
||||
if (!id) {
|
||||
throw "id cannot be null";
|
||||
}
|
||||
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.post(
|
||||
umbRequestHelper.getApiUrl(
|
||||
"contentApiBaseUrl",
|
||||
"PostPublishById",
|
||||
[{ id: id }])),
|
||||
'Failed to publish content with id ' + id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -282,6 +282,30 @@ namespace Umbraco.Web.Editors
|
||||
return display;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Publishes a document with a given ID
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// The CanAccessContentAuthorize attribute will deny access to this method if the current user
|
||||
/// does not have Publish access to this node.
|
||||
/// </remarks>
|
||||
///
|
||||
[EnsureUserPermissionForContent("id", 'P')]
|
||||
public HttpResponseMessage PostPublishById(int id)
|
||||
{
|
||||
var foundContent = Services.ContentService.GetById(id);
|
||||
if (foundContent == null)
|
||||
{
|
||||
return HandleContentNotFound(id, false);
|
||||
}
|
||||
|
||||
Services.ContentService.Publish(foundContent, UmbracoUser.Id);
|
||||
return Request.CreateResponse(HttpStatusCode.OK);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves an item to the recycle bin, if it is already there then it will permanently delete it
|
||||
/// </summary>
|
||||
@@ -292,6 +316,7 @@ namespace Umbraco.Web.Editors
|
||||
/// does not have Delete access to this node.
|
||||
/// </remarks>
|
||||
[EnsureUserPermissionForContent("id", 'D')]
|
||||
[HttpDelete]
|
||||
public HttpResponseMessage DeleteById(int id)
|
||||
{
|
||||
//TODO: We need to check if the user is allowed to do this!
|
||||
|
||||
Reference in New Issue
Block a user