mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-03 20:13:52 +08:00
- Based on UI review, adding a few elements to easily edit/delete single comments to the comments admin, as well as marking as spam/approving radio buttons to the comment edit view.
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4042237
This commit is contained in:
@@ -250,7 +250,8 @@ namespace Orchard.Comments.Controllers {
|
|||||||
Email = comment.Email,
|
Email = comment.Email,
|
||||||
Id = comment.Id,
|
Id = comment.Id,
|
||||||
Name = comment.Author,
|
Name = comment.Author,
|
||||||
SiteName = comment.SiteName
|
SiteName = comment.SiteName,
|
||||||
|
Status = comment.Status,
|
||||||
};
|
};
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
|
|
||||||
@@ -269,7 +270,7 @@ namespace Orchard.Comments.Controllers {
|
|||||||
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't edit comment")))
|
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't edit comment")))
|
||||||
return new HttpUnauthorizedResult();
|
return new HttpUnauthorizedResult();
|
||||||
|
|
||||||
_commentService.UpdateComment(viewModel.Id, viewModel.Name, viewModel.Email, viewModel.SiteName, viewModel.CommentText);
|
_commentService.UpdateComment(viewModel.Id, viewModel.Name, viewModel.Email, viewModel.SiteName, viewModel.CommentText, viewModel.Status);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
catch (Exception exception) {
|
catch (Exception exception) {
|
||||||
@@ -278,6 +279,20 @@ namespace Orchard.Comments.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ActionResult Delete(int id) {
|
||||||
|
try {
|
||||||
|
if (!_authorizer.Authorize(Permissions.ModerateComment, T("Couldn't delete comment")))
|
||||||
|
return new HttpUnauthorizedResult();
|
||||||
|
int commentedOn = _commentService.GetComment(id).CommentedOn;
|
||||||
|
_commentService.DeleteComment(id);
|
||||||
|
return RedirectToAction("Details", new { id = commentedOn });
|
||||||
|
}
|
||||||
|
catch (Exception exception) {
|
||||||
|
_notifier.Error(T("Deleting comment failed: " + exception.Message));
|
||||||
|
return Index(new CommentIndexOptions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private CommentEntry CreateCommentEntry(Comment comment) {
|
private CommentEntry CreateCommentEntry(Comment comment) {
|
||||||
return new CommentEntry {
|
return new CommentEntry {
|
||||||
Comment = comment,
|
Comment = comment,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace Orchard.Comments.Services {
|
|||||||
Comment GetComment(int id);
|
Comment GetComment(int id);
|
||||||
IContentDisplayInfo GetDisplayForCommentedContent(int id);
|
IContentDisplayInfo GetDisplayForCommentedContent(int id);
|
||||||
void CreateComment(Comment comment);
|
void CreateComment(Comment comment);
|
||||||
void UpdateComment(int id, string name, string email, string siteName, string commentText);
|
void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status);
|
||||||
void MarkCommentAsSpam(int commentId);
|
void MarkCommentAsSpam(int commentId);
|
||||||
void DeleteComment(int commentId);
|
void DeleteComment(int commentId);
|
||||||
bool CommentsClosedForCommentedContent(int id);
|
bool CommentsClosedForCommentedContent(int id);
|
||||||
@@ -82,12 +82,13 @@ namespace Orchard.Comments.Services {
|
|||||||
_commentRepository.Create(comment);
|
_commentRepository.Create(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateComment(int id, string name, string email, string siteName, string commentText) {
|
public void UpdateComment(int id, string name, string email, string siteName, string commentText, CommentStatus status) {
|
||||||
Comment comment = GetComment(id);
|
Comment comment = GetComment(id);
|
||||||
comment.Author = name;
|
comment.Author = name;
|
||||||
comment.Email = email;
|
comment.Email = email;
|
||||||
comment.SiteName = siteName;
|
comment.SiteName = siteName;
|
||||||
comment.CommentText = commentText;
|
comment.CommentText = commentText;
|
||||||
|
comment.Status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkCommentAsSpam(int commentId) {
|
public void MarkCommentAsSpam(int commentId) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Orchard.Mvc.ViewModels;
|
using Orchard.Mvc.ViewModels;
|
||||||
|
using Orchard.Comments.Models;
|
||||||
|
|
||||||
namespace Orchard.Comments.ViewModels {
|
namespace Orchard.Comments.ViewModels {
|
||||||
public class CommentsEditViewModel : AdminViewModel {
|
public class CommentsEditViewModel : AdminViewModel {
|
||||||
@@ -7,5 +8,6 @@ namespace Orchard.Comments.ViewModels {
|
|||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
public string SiteName { get; set; }
|
public string SiteName { get; set; }
|
||||||
public string CommentText { get; set; }
|
public string CommentText { get; set; }
|
||||||
|
public CommentStatus Status { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,9 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= commentEntry.Comment.CommentDate %></td>
|
<td><%= commentEntry.Comment.CommentDate %></td>
|
||||||
<td><%=Html.ActionLink("Edit", "Edit", new {commentEntry.Comment.Id}, new {@class="floatRight topSpacer"}) %>
|
<td>
|
||||||
|
<%=Html.ActionLink("Edit", "Edit", new {commentEntry.Comment.Id}) %> |
|
||||||
|
<%=Html.ActionLink("Delete", "Delete", new {id = commentEntry.Comment.Id, redirectToAction = "Details"}) %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<CommentsEditViewModel>" %>
|
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<CommentsEditViewModel>" %>
|
||||||
|
<%@ Import Namespace="Orchard.Comments.Models"%>
|
||||||
<%@ Import Namespace="Orchard.Comments.ViewModels"%>
|
<%@ Import Namespace="Orchard.Comments.ViewModels"%>
|
||||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||||
<% Html.Include("Header"); %>
|
<% Html.Include("Header"); %>
|
||||||
<% Html.BeginForm(); %>
|
<% Html.BeginForm(); %>
|
||||||
<%= Html.ValidationSummary() %>
|
<%= Html.ValidationSummary() %>
|
||||||
<div class="yui-g">
|
<div class="yui-g">
|
||||||
<h2 class="separator">Add a Comment</h2>
|
<h2 class="separator">Edit a Comment</h2>
|
||||||
<h3>Information</h3>
|
<h3>Information</h3>
|
||||||
<ol>
|
<ol>
|
||||||
<li>
|
<li>
|
||||||
@@ -27,6 +28,17 @@
|
|||||||
<%= Model.CommentText %>
|
<%= Model.CommentText %>
|
||||||
</textarea>
|
</textarea>
|
||||||
</li>
|
</li>
|
||||||
|
<h3>Status</h3>
|
||||||
|
<li>
|
||||||
|
<label for="Status_Approved">
|
||||||
|
<%=Html.RadioButton("Status", "Approved", (Model.Status == CommentStatus.Approved), new { id = "Status_Approved" }) %> Approved
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="Status_Spam">
|
||||||
|
<%=Html.RadioButton("Status", "Spam", (Model.Status == CommentStatus.Spam), new { id = "Status_Spam" }) %> Mark As Spam
|
||||||
|
</label>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="submit" class="button" value="Save" />
|
<input type="submit" class="button" value="Save" />
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
<col id="Col4" />
|
<col id="Col4" />
|
||||||
<col id="Col5" />
|
<col id="Col5" />
|
||||||
<col id="Col6" />
|
<col id="Col6" />
|
||||||
|
<col id="Col7" />
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -50,6 +51,7 @@
|
|||||||
<th scope="col">Comment</th>
|
<th scope="col">Comment</th>
|
||||||
<th scope="col">Date</th>
|
<th scope="col">Date</th>
|
||||||
<th scope="col">Commented On</th>
|
<th scope="col">Commented On</th>
|
||||||
|
<th scope="col"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<%
|
<%
|
||||||
@@ -71,7 +73,13 @@
|
|||||||
<% } %>
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
<td><%= commentEntry.Comment.CommentDate %></td>
|
<td><%= commentEntry.Comment.CommentDate %></td>
|
||||||
<td><%=Html.ActionLink(commentEntry.CommentedOn, "Details", new {id = commentEntry.Comment.CommentedOn}, new {@class="floatRight topSpacer"}) %></td>
|
<td>
|
||||||
|
<%=Html.ActionLink(commentEntry.CommentedOn, "Details", new {id = commentEntry.Comment.CommentedOn}) %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%=Html.ActionLink("Edit", "Edit", new {commentEntry.Comment.Id}) %> |
|
||||||
|
<%=Html.ActionLink("Delete", "Delete", new {id = commentEntry.Comment.Id, redirectToAction = "Index"}) %>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<%
|
<%
|
||||||
commentIndex++;
|
commentIndex++;
|
||||||
|
|||||||
Reference in New Issue
Block a user