mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Changing comments to work with MVC 2 RC2 model validation approach
email is no longer required (it's not required by logged in users by default) name is provided as hidden --HG-- branch : dev
This commit is contained in:
@@ -5,7 +5,6 @@ namespace Orchard.Comments.ViewModels {
|
|||||||
public class CommentsCreateViewModel : AdminViewModel {
|
public class CommentsCreateViewModel : AdminViewModel {
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
|
||||||
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; }
|
||||||
|
|||||||
@@ -1,42 +1,60 @@
|
|||||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
|
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<HasComments>" %>
|
||||||
<%@ Import Namespace="Orchard.Comments.Models"%>
|
<%@ Import Namespace="Orchard.Security" %>
|
||||||
<h2 id="comments"><%=_Encoded("{0} Comment{1}", Model.Comments.Count, Model.Comments.Count == 1 ? "" : "s")%></h2><%
|
<%@ Import Namespace="Orchard.Comments.Models" %>
|
||||||
if (Model.Comments.Count > 0) { Html.RenderPartial("ListOfComments", Model.Comments); }
|
<h2 id="comments">
|
||||||
if (Model.CommentsActive == false) { %>
|
<%=_Encoded("{0} Comment{1}", Model.Comments.Count, Model.Comments.Count == 1 ? "" : "s")%></h2>
|
||||||
<p><%=_Encoded("Comments have been disabled for this content.") %></p><%
|
<%
|
||||||
} else { %>
|
if (Model.Comments.Count > 0) { Html.RenderPartial("ListOfComments", Model.Comments); }
|
||||||
<% using(Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comment" })) { %>
|
if (Model.CommentsActive == false) { %>
|
||||||
<%=Html.ValidationSummary() %>
|
<p>
|
||||||
<%
|
<%=_Encoded("Comments have been disabled for this content.") %></p>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
else { %>
|
||||||
|
<% using (Html.BeginForm("Create", "Comment", new { area = "Orchard.Comments" }, FormMethod.Post, new { @class = "comment" })) { %>
|
||||||
|
<%=Html.ValidationSummary() %>
|
||||||
|
<%
|
||||||
if (!Request.IsAuthenticated) { %>
|
if (!Request.IsAuthenticated) { %>
|
||||||
<fieldset class="who">
|
<fieldset class="who">
|
||||||
<div>
|
<div>
|
||||||
<label for="Name"><%=_Encoded("Name") %></label>
|
<label for="Name">
|
||||||
<input id="Name" class="text" name="Name" type="text" />
|
<%=_Encoded("Name") %></label>
|
||||||
</div>
|
<input id="Name" class="text" name="Name" type="text" />
|
||||||
<div>
|
</div>
|
||||||
<label for="Email"><%=_Encoded("Email") %></label>
|
<div>
|
||||||
<input id="Email" class="text" name="Email" type="text" />
|
<label for="Email">
|
||||||
</div>
|
<%=_Encoded("Email") %></label>
|
||||||
<div>
|
<input id="Email" class="text" name="Email" type="text" />
|
||||||
<label for="SiteName"><%=_Encoded("Url") %></label>
|
</div>
|
||||||
<input id="SiteName" class="text" name="SiteName" type="text" />
|
<div>
|
||||||
</div>
|
<label for="SiteName">
|
||||||
</fieldset><%
|
<%=_Encoded("Url") %></label>
|
||||||
|
<input id="SiteName" class="text" name="SiteName" type="text" />
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var currentUser = Html.Resolve<IAuthenticationService>().GetAuthenticatedUser();
|
||||||
|
%>
|
||||||
|
<%=Html.Hidden("Name", currentUser.UserName ?? "")%>
|
||||||
|
<%=Html.Hidden("Email", currentUser.Email ?? "")%>
|
||||||
|
<%
|
||||||
|
}%>
|
||||||
|
<fieldset class="what">
|
||||||
|
<div>
|
||||||
|
<label for="CommentText">
|
||||||
|
<% if (Request.IsAuthenticated) { %><%=T("Hi, {0}!", Html.Encode(Page.User.Identity.Name)) %><br />
|
||||||
|
<% } %><%=_Encoded("Leave a comment") %></label>
|
||||||
|
<textarea id="CommentText" rows="10" cols="30" name="CommentText"></textarea>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input type="submit" class="button" value="<%=_Encoded("Submit Comment") %>" />
|
||||||
|
<%=Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
|
||||||
|
<%=Html.Hidden("ReturnUrl", Context.Request.Url) %>
|
||||||
|
<%=Html.AntiForgeryTokenOrchard() %>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<%
|
||||||
|
}
|
||||||
} %>
|
} %>
|
||||||
<fieldset class="what">
|
|
||||||
<div>
|
|
||||||
<label for="CommentText"><% if (Request.IsAuthenticated) { %><%=T("Hi, {0}!", Html.Encode(Page.User.Identity.Name)) %><br /><% } %><%=_Encoded("Leave a comment") %></label>
|
|
||||||
<textarea id="CommentText" rows="10" cols="30" name="CommentText"></textarea>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<input type="submit" class="button" value="<%=_Encoded("Submit Comment") %>" />
|
|
||||||
<%=Html.Hidden("CommentedOn", Model.ContentItem.Id) %>
|
|
||||||
<%=Html.Hidden("ReturnUrl", Context.Request.Url) %>
|
|
||||||
<%=Html.AntiForgeryTokenOrchard() %>
|
|
||||||
</div>
|
|
||||||
</fieldset><%
|
|
||||||
}
|
|
||||||
} %>
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user