mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Partially complete refactoring. Adding transactions. Adjusting template locations. CURRENTLY BROKEN
--HG-- extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4044385
This commit is contained in:
@@ -141,7 +141,7 @@
|
||||
<Content Include="Common\Views\Shared\EditorTemplates\OwnerEditorViewModel.ascx" />
|
||||
<Content Include="Themes\Styles\site.css" />
|
||||
<Content Include="Themes\Views\Admin\Install.aspx" />
|
||||
<Content Include="Themes\Views\Shared\document.aspx" />
|
||||
<Content Include="Themes\Views\document.aspx" />
|
||||
<Content Include="Themes\Views\Shared\EditorTemplates\ThemeSiteSettingsRecord.ascx" />
|
||||
<Content Include="Themes\Views\Shared\layout.ascx" />
|
||||
<Content Include="Themes\Views\Shared\user.ascx" />
|
||||
|
||||
@@ -26,14 +26,14 @@ namespace Orchard.Core.Settings.Controllers {
|
||||
public ActionResult Index(string tabName) {
|
||||
var model = new Orchard.Core.Settings.ViewModels.SettingsIndexViewModel {
|
||||
Site = _siteService.GetSiteSettings().As<SiteSettings>() };
|
||||
model.EditorModel = _modelManager.BuildEditorModel(model.Site, tabName);
|
||||
model.EditorModel = _modelManager.BuildEditorModel(model.Site);
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[AcceptVerbs(HttpVerbs.Post)]
|
||||
public ActionResult Index(string tabName, FormCollection input) {
|
||||
var viewModel = new SettingsIndexViewModel { Site = _siteService.GetSiteSettings().As<SiteSettings>() };
|
||||
viewModel.EditorModel = _modelManager.UpdateEditorModel(viewModel.Site.ContentItem, tabName, this);
|
||||
viewModel.EditorModel = _modelManager.UpdateEditorModel(viewModel.Site.ContentItem, this);
|
||||
|
||||
if (!TryUpdateModel(viewModel, input.ToValueProvider())) {
|
||||
return View(viewModel);
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Core.Settings.ViewModels.SettingsIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
<h2>Edit Settings</h2>
|
||||
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<h2>
|
||||
Edit Settings</h2>
|
||||
<%using (Html.BeginForm()) { %>
|
||||
<%= Html.ValidationSummary() %>
|
||||
<%= Html.EditorForModel() %>
|
||||
<%= Html.ValidationSummary() %>
|
||||
<fieldset>
|
||||
<legend>Global Settings</legend>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Save" />
|
||||
<%=Html.LabelFor(x=>x.SiteName) %>
|
||||
<%=Html.EditorFor(x=>x.SiteName) %>
|
||||
<%=Html.ValidationMessage("SiteName", "*") %>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<%=Html.LabelFor(x => x.SuperUser) %>
|
||||
<%=Html.EditorFor(x=>x.SuperUser) %>
|
||||
<%=Html.ValidationMessage("SuperUser", "*") %>
|
||||
</fieldset>
|
||||
<%=Html.EditorFor(s=>s.Id) %>
|
||||
</fieldset>
|
||||
<% foreach (var e in Model.EditorModel.Editors) { %>
|
||||
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
|
||||
<% } %>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Save" />
|
||||
</fieldset>
|
||||
<% } %>
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Core.Themes.ViewModels {
|
||||
public class CreateThemeViewModel : AdminViewModel {
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string Author { get; set; }
|
||||
[Required]
|
||||
public string Description { get; set; }
|
||||
[Required]
|
||||
public string Version { get; set; }
|
||||
[Required]
|
||||
public string Tags { get; set; }
|
||||
[Required]
|
||||
public string Homepage { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,7 @@
|
||||
<Content Include="Content\Images\title_background.gif" />
|
||||
<Content Include="Content\Site2.css" />
|
||||
<Content Include="Content\Site3.css" />
|
||||
<Content Include="Themes\BlueSky\Views\layout.ascx" />
|
||||
<Content Include="Views\Shared\Messages.ascx" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
public ActionResult List() {
|
||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||
var model = new AdminBlogsViewModel {
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, null, "Summary", "Admin/Blog"))
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, "SummaryAdmin"))
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -35,7 +35,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||
var model = new BlogForAdminViewModel {
|
||||
Blog = _contentManager.BuildDisplayModel(blog, null, "Detail", "Admin/Blog")
|
||||
Blog = _contentManager.BuildDisplayModel(blog, "DetailAdmin")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
public ActionResult List() {
|
||||
var model = new BlogsViewModel {
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, null, "Summary"))
|
||||
Blogs = _blogService.Get().Select(b => _contentManager.BuildDisplayModel(b, "Summary"))
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -51,7 +51,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogViewModel {
|
||||
Blog = _contentManager.BuildDisplayModel(blog, null, "Detail")
|
||||
Blog = _contentManager.BuildDisplayModel(blog, "Detail")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -68,7 +68,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new CreateBlogViewModel {
|
||||
Blog = _contentManager.BuildEditorModel(blog, null)
|
||||
Blog = _contentManager.BuildEditorModel(blog)
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -80,7 +80,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (!_authorizer.Authorize(Permissions.CreateBlog, T("Couldn't create blog")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
model.Blog = _contentManager.UpdateEditorModel(_contentManager.New<Blog>("blog"), null, this);
|
||||
model.Blog = _contentManager.UpdateEditorModel(_contentManager.New<Blog>("blog"), this);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
@@ -106,7 +106,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogEditViewModel {
|
||||
Blog = _contentManager.BuildEditorModel(blog, "")
|
||||
Blog = _contentManager.BuildEditorModel(blog)
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -124,7 +124,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogEditViewModel {
|
||||
Blog = _contentManager.UpdateEditorModel(blog, "", this)
|
||||
Blog = _contentManager.UpdateEditorModel(blog, this)
|
||||
};
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
|
||||
var model = new BlogPostViewModel {
|
||||
Blog = blog,
|
||||
BlogPost = _contentManager.BuildDisplayModel(post, null, "Detail")
|
||||
BlogPost = _contentManager.BuildDisplayModel(post, "Detail")
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -95,7 +95,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
if (blog == null)
|
||||
return new NotFoundResult();
|
||||
|
||||
var blogPost = _contentManager.BuildEditorModel(_contentManager.New<BlogPost>("blogpost"), null);
|
||||
var blogPost = _contentManager.BuildEditorModel(_contentManager.New<BlogPost>("blogpost"));
|
||||
blogPost.Item.Blog = blog;
|
||||
|
||||
var model = new CreateBlogPostViewModel {
|
||||
@@ -117,7 +117,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
BlogPost blogPost = _contentManager.Create<BlogPost>("blogpost", bp => { bp.Blog = blog; });
|
||||
model.BlogPost = _contentManager.UpdateEditorModel(blogPost, null, this);
|
||||
model.BlogPost = _contentManager.UpdateEditorModel(blogPost, this);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
@@ -145,7 +145,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogPostEditViewModel {
|
||||
BlogPost = _contentManager.BuildEditorModel(post, null)
|
||||
BlogPost = _contentManager.BuildEditorModel(post)
|
||||
};
|
||||
|
||||
return View(model);
|
||||
@@ -168,7 +168,7 @@ namespace Orchard.Blogs.Controllers {
|
||||
return new NotFoundResult();
|
||||
|
||||
var model = new BlogPostEditViewModel {
|
||||
BlogPost = _contentManager.UpdateEditorModel(post, null, this)
|
||||
BlogPost = _contentManager.UpdateEditorModel(post, this)
|
||||
};
|
||||
|
||||
IValueProvider values = input.ToValueProvider();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Orchard.Blogs.Models {
|
||||
Filters.Add(new ActivatingFilter<CommonAspect>("blog"));
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>("blog"));
|
||||
Filters.Add(new StorageFilter<BlogRecord>(repository));
|
||||
Filters.Add(new ContentItemTemplates<Blog>("Detail", "Summary"));
|
||||
Filters.Add(new ContentItemTemplates<Blog>("Items/Blogs.Blog", "Detail Summary"));
|
||||
|
||||
OnGetEditorViewModel<Blog>((context, blog) =>
|
||||
context.AddEditor(new TemplateViewModel(blog) { TemplateName = "Blog/Fields", ZoneName = "primary", Position = "1" })
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Orchard.Blogs.Models {
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>("blogpost"));
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>("blogpost"));
|
||||
Filters.Add(new StorageFilter<BlogPostRecord>(repository));
|
||||
Filters.Add(new ContentItemTemplates<BlogPost>("Detail", "Summary"));
|
||||
Filters.Add(new ContentItemTemplates<BlogPost>("Items/Blogs.BlogPost", "Detail Summary"));
|
||||
|
||||
OnCreated<BlogPost>((context, bp) => bp.Blog.PostCount++);
|
||||
|
||||
@@ -59,10 +59,15 @@ namespace Orchard.Blogs.Models {
|
||||
switch(context.DisplayType) {
|
||||
case "Detail":
|
||||
context.AddDisplay(
|
||||
//TODO: (erikpo) Need to make templatePath be more convention based so if my controller name has "Admin" in it then "Admin/{type}" is assumed
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, null, "Summary", "Admin/BlogPost")))
|
||||
{
|
||||
TemplateName = "Admin/BlogPost/List",
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, "Summary"))) {
|
||||
TemplateName = "BlogPost/List",
|
||||
ZoneName = "body"
|
||||
});
|
||||
break;
|
||||
case "DetailAdmin":
|
||||
context.AddDisplay(
|
||||
new TemplateViewModel(posts.Select(bp => contentManager.BuildDisplayModel(bp, "SummaryAdmin"))) {
|
||||
TemplateName = "BlogPost/ListAdmin",
|
||||
ZoneName = "body"
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -158,9 +158,8 @@
|
||||
<IISUrl>
|
||||
</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
</CustomServerUrl>
|
||||
<UseCustomServer>True</UseCustomServer>
|
||||
<CustomServerUrl>http://orchard.codeplex.com/</CustomServerUrl>
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace Orchard.DevTools.Controllers {
|
||||
.Select(x => x.GetType())
|
||||
.SelectMany(x => AllTypes(x))
|
||||
.Distinct();
|
||||
model.DisplayModel = _contentManager.BuildDisplayModel(model.Item, null, null);
|
||||
model.EditorModel = _contentManager.BuildEditorModel(model.Item, null);
|
||||
model.DisplayModel = _contentManager.BuildDisplayModel(model.Item, null);
|
||||
model.EditorModel = _contentManager.BuildEditorModel(model.Item);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ using Orchard.Models.ViewModels;
|
||||
namespace Orchard.DevTools.Models {
|
||||
public class DebugLinkHandler : ContentHandler {
|
||||
protected override void BuildDisplayModel(BuildDisplayModelContext context) {
|
||||
context.AddDisplay(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { ZoneName = "recap", Position = "9999" });
|
||||
context.AddDisplay(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { TemplateName="Parts/DevTools.ShowDebugLink", ZoneName = "recap", Position = "9999" });
|
||||
}
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
context.AddEditor(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { ZoneName = "recap", Position = "9999" });
|
||||
context.AddEditor(new TemplateViewModel(new ShowDebugLink { ContentItem = context.ContentItem }) { TemplateName = "Parts/DevTools.ShowDebugLink", ZoneName = "recap", Position = "9999" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@
|
||||
<Content Include="Views\Content\Details.aspx" />
|
||||
<Content Include="Views\Content\Index.aspx" />
|
||||
<Content Include="Views\Home\Index.aspx" />
|
||||
<Content Include="Views\Shared\DisplayTemplates\ShowDebugLink.ascx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\ShowDebugLink.ascx" />
|
||||
<Content Include="Views\DisplayTemplates\Parts\DevTools.ShowDebugLink.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\DevTools.ShowDebugLink.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
@@ -88,6 +88,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Views\Shared\DisplayTemplates\" />
|
||||
<Folder Include="Views\Shared\EditorTemplates\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
|
||||
|
||||
@@ -3,121 +3,100 @@
|
||||
|
||||
<%@ Import Namespace="System.Reflection" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>TwoColumns</title>
|
||||
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="header">
|
||||
<div id="innerheader">
|
||||
<% Html.Include("header"); %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="page">
|
||||
<div id="sideBar">
|
||||
<% Html.Include("Navigation"); %>
|
||||
</div>
|
||||
<div id="main">
|
||||
<h3>
|
||||
Content Item</h3>
|
||||
<p>
|
||||
Id:
|
||||
<%=Model.Item.ContentItem.Id %></p>
|
||||
<p>
|
||||
ContentType:
|
||||
<%=Model.Item.ContentItem.ContentType%> <%=Html.ItemDisplayLink(Model.Item) %> <%=Html.ItemEditLink("edit", Model.Item) %></p>
|
||||
<h3>
|
||||
Content Item Parts</h3>
|
||||
<ul>
|
||||
<%foreach (var partType in Model.PartTypes.OrderBy(x => x.Name)) {%>
|
||||
<li><span style="font-weight: bold;">
|
||||
<%if (partType.IsGenericType) {%><%=Html.Encode(partType.Name +" "+partType.GetGenericArguments().First().Name)%></span>
|
||||
<%=Html.Encode(" (" + partType.GetGenericArguments().First().Namespace + ")")%><%}
|
||||
else {%><%=Html.Encode(partType.Name)%></span>
|
||||
<%=Html.Encode( " (" + partType.Namespace + ")")%><%
|
||||
}
|
||||
|
||||
%>
|
||||
<ul style="margin-left: 20px">
|
||||
<%foreach (var prop in partType.GetProperties().Where(x => x.DeclaringType == partType)) {
|
||||
var value = prop.GetValue(Model.Locate(partType), null);%>
|
||||
<li style="font-weight: normal;">
|
||||
<%=Html.Encode(prop.Name) %>:
|
||||
<%=Html.Encode(value) %>
|
||||
<%var valueItem = value as ContentItem;
|
||||
if (valueItem == null && value is IContent) {
|
||||
valueItem = (value as IContent).ContentItem;
|
||||
}
|
||||
if (valueItem != null) {
|
||||
%><%=Html.ActionLink(valueItem.ContentType + " #" + valueItem.Id, "details", new { valueItem.Id }, new { })%><%
|
||||
}
|
||||
%>
|
||||
<ul style="margin-left: 20px">
|
||||
<%if (value == null || prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string)) { }
|
||||
else if (typeof(IEnumerable).IsAssignableFrom(prop.PropertyType)) {
|
||||
foreach (var item in value as IEnumerable) {
|
||||
%>
|
||||
<li><%=Html.Encode(item.GetType().Name) %>:<%=Html.Encode(item) %></li>
|
||||
<%
|
||||
}
|
||||
|
||||
}
|
||||
else {%>
|
||||
<%foreach (var prop2 in value.GetType().GetProperties().Where(x => x.GetIndexParameters().Count() == 0)) {%>
|
||||
<li>
|
||||
<%=Html.Encode(prop2.Name)%>
|
||||
<%=Html.Encode(prop2.GetValue(value, null))%></li>
|
||||
<%} %>
|
||||
<%} %>
|
||||
</ul>
|
||||
</li>
|
||||
<%} %>
|
||||
</ul>
|
||||
</li>
|
||||
<%}%>
|
||||
</ul>
|
||||
<h3>
|
||||
Displays</h3>
|
||||
<ul>
|
||||
<%foreach (var display in Model.Displays) {%>
|
||||
<li><span style="font-weight: bold">
|
||||
<%=Html.Encode(display.Prefix)%></span>
|
||||
<%=Html.Encode(display.Model.GetType().Name)%>
|
||||
(<%=Html.Encode(display.Model.GetType().Namespace)%>)
|
||||
Prefix:<%=Html.Encode(display.Prefix ?? "(null)")%>
|
||||
Zone:<%=Html.Encode(display.ZoneName ?? "(null)")%>
|
||||
Position:<%=Html.Encode(display.Position ?? "(null)")%>
|
||||
<div style="margin-left: 20px; border: solid 1px black;">
|
||||
<%=Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)%>
|
||||
</div>
|
||||
</li>
|
||||
<%
|
||||
}%>
|
||||
</ul>
|
||||
<h3>
|
||||
Editors</h3>
|
||||
<ul>
|
||||
<%foreach (var editor in Model.Editors) {%>
|
||||
<li><span style="font-weight: bold">
|
||||
<%=Html.Encode(editor.Prefix) %></span>
|
||||
<%=Html.Encode(editor.Model.GetType().Name) %>
|
||||
(<%=Html.Encode(editor.Model.GetType().Namespace) %>)
|
||||
Prefix:<%=Html.Encode(editor.Prefix ?? "(null)")%>
|
||||
Zone:<%=Html.Encode(editor.ZoneName ?? "(null)")%>
|
||||
Position:<%=Html.Encode(editor.Position??"(null)") %>
|
||||
<div style="margin-left: 20px; border: solid 1px black;">
|
||||
<%=Html.EditorFor(x=>editor.Model, editor.TemplateName, editor.Prefix) %>
|
||||
</div>
|
||||
</li>
|
||||
<%
|
||||
}%>
|
||||
</ul>
|
||||
<h3>Content Item</h3>
|
||||
<p>
|
||||
Id:
|
||||
<%=Model.Item.ContentItem.Id %></p>
|
||||
<p>
|
||||
ContentType:
|
||||
<%=Model.Item.ContentItem.ContentType%> <%=Html.ItemDisplayLink(Model.Item) %> <%=Html.ItemEditLink("edit", Model.Item) %></p>
|
||||
|
||||
|
||||
<h3>Content Item Parts</h3>
|
||||
<ul>
|
||||
<%foreach (var partType in Model.PartTypes.OrderBy(x => x.Name)) {%>
|
||||
<li><span style="font-weight: bold;">
|
||||
<%if (partType.IsGenericType) {%><%=Html.Encode(partType.Name +" "+partType.GetGenericArguments().First().Name)%></span>
|
||||
<%=Html.Encode(" (" + partType.GetGenericArguments().First().Namespace + ")")%><%}
|
||||
else {%><%=Html.Encode(partType.Name)%></span>
|
||||
<%=Html.Encode( " (" + partType.Namespace + ")")%><%
|
||||
}
|
||||
|
||||
%>
|
||||
<ul style="margin-left: 20px">
|
||||
<%foreach (var prop in partType.GetProperties().Where(x => x.DeclaringType == partType)) {
|
||||
var value = prop.GetValue(Model.Locate(partType), null);%>
|
||||
<li style="font-weight: normal;">
|
||||
<%=Html.Encode(prop.Name) %>:
|
||||
<%=Html.Encode(value) %>
|
||||
<%var valueItem = value as ContentItem;
|
||||
if (valueItem == null && value is IContent) {
|
||||
valueItem = (value as IContent).ContentItem;
|
||||
}
|
||||
if (valueItem != null) {
|
||||
%><%=Html.ActionLink(valueItem.ContentType + " #" + valueItem.Id, "details", new { valueItem.Id }, new { })%><%
|
||||
}
|
||||
%>
|
||||
<ul style="margin-left: 20px">
|
||||
<%if (value == null || prop.PropertyType.IsPrimitive || prop.PropertyType == typeof(string)) { }
|
||||
else if (typeof(IEnumerable).IsAssignableFrom(prop.PropertyType)) {
|
||||
foreach (var item in value as IEnumerable) {
|
||||
%>
|
||||
<li><%=Html.Encode(item.GetType().Name) %>:<%=Html.Encode(item) %></li>
|
||||
<%
|
||||
}
|
||||
|
||||
}
|
||||
else {%>
|
||||
<%foreach (var prop2 in value.GetType().GetProperties().Where(x => x.GetIndexParameters().Count() == 0)) {%>
|
||||
<li>
|
||||
<%=Html.Encode(prop2.Name)%>
|
||||
<%=Html.Encode(prop2.GetValue(value, null))%></li>
|
||||
<%} %>
|
||||
<%} %>
|
||||
</ul>
|
||||
</li>
|
||||
<%} %>
|
||||
</ul>
|
||||
</li>
|
||||
<%}%>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Displays</h3>
|
||||
<ul>
|
||||
<%foreach (var display in Model.Displays) {%>
|
||||
<li><span style="font-weight: bold">
|
||||
<%=Html.Encode(display.Prefix)%></span>
|
||||
<%=Html.Encode(display.Model.GetType().Name)%>
|
||||
(<%=Html.Encode(display.Model.GetType().Namespace)%>)
|
||||
Prefix:<%=Html.Encode(display.Prefix ?? "(null)")%>
|
||||
Zone:<%=Html.Encode(display.ZoneName ?? "(null)")%>
|
||||
Position:<%=Html.Encode(display.Position ?? "(null)")%>
|
||||
<div style="margin-left: 20px; border: solid 1px black;">
|
||||
<%=Html.DisplayFor(x => display.Model, display.TemplateName, display.Prefix)%>
|
||||
</div>
|
||||
<div id="footer">
|
||||
<% Html.Include("footer"); %>
|
||||
</li>
|
||||
<%
|
||||
}%>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>Editors</h3>
|
||||
<ul>
|
||||
<%foreach (var editor in Model.Editors) {%>
|
||||
<li><span style="font-weight: bold">
|
||||
<%=Html.Encode(editor.Prefix) %></span>
|
||||
<%=Html.Encode(editor.Model.GetType().Name) %>
|
||||
(<%=Html.Encode(editor.Model.GetType().Namespace) %>)
|
||||
Prefix:<%=Html.Encode(editor.Prefix ?? "(null)")%>
|
||||
Zone:<%=Html.Encode(editor.ZoneName ?? "(null)")%>
|
||||
Position:<%=Html.Encode(editor.Position??"(null)") %>
|
||||
<div style="margin-left: 20px; border: solid 1px black;">
|
||||
<%=Html.EditorFor(x=>editor.Model, editor.TemplateName, editor.Prefix) %>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</li>
|
||||
<%
|
||||
}%>
|
||||
</ul>
|
||||
|
||||
@@ -1,27 +1,7 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.DevTools.ViewModels.ContentIndexViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>TwoColumns</title>
|
||||
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
<div id="innerheader">
|
||||
<% Html.Include("header"); %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="page">
|
||||
<div id="sideBar">
|
||||
<% Html.Include("Navigation"); %>
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
<h3>Content Types</h3>
|
||||
<ul>
|
||||
<%foreach(var item in Model.Types.OrderBy(x=>x.Name)){%>
|
||||
@@ -38,13 +18,3 @@
|
||||
<%}%>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<% Html.Include("footer"); %>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -2,37 +2,4 @@
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html"%>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>TwoColumns</title>
|
||||
<link href="<%=ResolveUrl("~/Content/Site2.css") %>" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
<div id="innerheader">
|
||||
<% Html.Include("header"); %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="page">
|
||||
<div id="sideBar">
|
||||
<% Html.Include("Navigation"); %>
|
||||
</div>
|
||||
|
||||
<div id="main">
|
||||
|
||||
<p><%=Html.ActionLink("Contents", "Index", "Content") %></p>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
<% Html.Include("footer"); %>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Data;
|
||||
using Orchard.Models;
|
||||
using Orchard.Models.Driver;
|
||||
using Orchard.Models.ViewModels;
|
||||
using Orchard.Roles.Models.NoRecord;
|
||||
using Orchard.Roles.Records;
|
||||
using Orchard.Roles.Services;
|
||||
using Orchard.Roles.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.UI.Notify;
|
||||
|
||||
namespace Orchard.Roles.Controllers {
|
||||
public class UserRolesDriver : PartDriver<UserRoles> {
|
||||
private readonly IRepository<UserRolesRecord> _userRolesRepository;
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public UserRolesDriver(
|
||||
IRepository<UserRolesRecord> userRolesRepository,
|
||||
IRoleService roleService,
|
||||
INotifier notifier) {
|
||||
_userRolesRepository = userRolesRepository;
|
||||
_roleService = roleService;
|
||||
_notifier = notifier;
|
||||
}
|
||||
|
||||
protected override string Prefix {
|
||||
get {
|
||||
return "UserRoles";
|
||||
}
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(UserRoles userRoles) {
|
||||
var roles =
|
||||
_roleService.GetRoles().Select(
|
||||
x => new UserRoleEntry {
|
||||
RoleId = x.Id,
|
||||
Name = x.Name,
|
||||
Granted = userRoles.Roles.Contains(x.Name)
|
||||
});
|
||||
|
||||
var model = new UserRolesViewModel {
|
||||
User = userRoles.As<IUser>(),
|
||||
UserRoles = userRoles,
|
||||
Roles = roles.ToList(),
|
||||
};
|
||||
return PartialView(model, "Parts/Roles.UserRoles");
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(UserRoles userRoles, IUpdateModel updater) {
|
||||
var model = new UserRolesViewModel {
|
||||
User = userRoles.As<IUser>(),
|
||||
UserRoles = userRoles,
|
||||
};
|
||||
|
||||
if (updater.TryUpdateModel(model, "UserRoles", null, null)) {
|
||||
|
||||
var currentUserRoleRecords = _userRolesRepository.Fetch(x => x.UserId == model.User.Id);
|
||||
var currentRoleRecords = currentUserRoleRecords.Select(x => x.Role);
|
||||
var targetRoleRecords = model.Roles.Where(x => x.Granted).Select(x => _roleService.GetRole(x.RoleId));
|
||||
|
||||
foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x))) {
|
||||
_notifier.Warning(string.Format("Adding role {0} to user {1}", addingRole.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Create(new UserRolesRecord { UserId = model.User.Id, Role = addingRole });
|
||||
}
|
||||
|
||||
foreach (var removingRole in currentUserRoleRecords.Where(x => !targetRoleRecords.Contains(x.Role))) {
|
||||
_notifier.Warning(string.Format("Removing role {0} from user {1}", removingRole.Role.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Delete(removingRole);
|
||||
}
|
||||
|
||||
}
|
||||
return PartialView(model, "Parts/Roles.UserRoles");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,9 @@ using Orchard.UI.Notify;
|
||||
namespace Orchard.Roles.Models {
|
||||
public class UserRolesHandler : ContentHandler {
|
||||
private readonly IRepository<UserRolesRecord> _userRolesRepository;
|
||||
private readonly IRoleService _roleService;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public UserRolesHandler(IRepository<UserRolesRecord> userRolesRepository, IRoleService roleService, INotifier notifier) {
|
||||
public UserRolesHandler(IRepository<UserRolesRecord> userRolesRepository) {
|
||||
_userRolesRepository = userRolesRepository;
|
||||
_roleService = roleService;
|
||||
_notifier = notifier;
|
||||
|
||||
Filters.Add(new ActivatingFilter<UserRoles>("user"));
|
||||
OnLoaded<UserRoles>((context, userRoles) => {
|
||||
@@ -29,51 +25,6 @@ namespace Orchard.Roles.Models {
|
||||
});
|
||||
}
|
||||
|
||||
protected override void BuildEditorModel(BuildEditorModelContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRoles>();
|
||||
if (userRoles != null) {
|
||||
var roles =
|
||||
_roleService.GetRoles().Select(
|
||||
x => new UserRoleEntry {
|
||||
RoleId = x.Id,
|
||||
Name = x.Name,
|
||||
Granted = userRoles.Roles.Contains(x.Name)
|
||||
});
|
||||
|
||||
var viewModel = new UserRolesViewModel {
|
||||
User = userRoles.As<IUser>(),
|
||||
UserRoles = userRoles,
|
||||
Roles = roles.ToList(),
|
||||
};
|
||||
|
||||
context.AddEditor(new TemplateViewModel(viewModel, "UserRoles"));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateEditorModel(UpdateEditorModelContext context) {
|
||||
var userRoles = context.ContentItem.As<UserRoles>();
|
||||
if (userRoles != null) {
|
||||
var viewModel = new UserRolesViewModel();
|
||||
if (context.Updater.TryUpdateModel(viewModel, "UserRoles", null, null)) {
|
||||
|
||||
var currentUserRoleRecords = _userRolesRepository.Fetch(x => x.UserId == context.ContentItem.Id);
|
||||
var currentRoleRecords = currentUserRoleRecords.Select(x => x.Role);
|
||||
var targetRoleRecords = viewModel.Roles.Where(x => x.Granted).Select(x => _roleService.GetRole(x.RoleId));
|
||||
|
||||
foreach (var addingRole in targetRoleRecords.Where(x => !currentRoleRecords.Contains(x))) {
|
||||
_notifier.Warning(string.Format("Adding role {0} to user {1}", addingRole.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Create(new UserRolesRecord { UserId = context.ContentItem.Id, Role = addingRole });
|
||||
}
|
||||
|
||||
foreach (var removingRole in currentUserRoleRecords.Where(x => !targetRoleRecords.Contains(x.Role))) {
|
||||
_notifier.Warning(string.Format("Removing role {0} from user {1}", removingRole.Role.Name, userRoles.As<IUser>().UserName));
|
||||
_userRolesRepository.Delete(removingRole);
|
||||
}
|
||||
|
||||
}
|
||||
context.AddEditor(new TemplateViewModel(viewModel, "UserRoles"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="AdminMenu.cs" />
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\UserRolesDriver.cs" />
|
||||
<Compile Include="Records\PermissionRecord.cs" />
|
||||
<Compile Include="Records\RoleRecord.cs" />
|
||||
<Compile Include="Models\UserRoles.cs" />
|
||||
@@ -82,7 +83,7 @@
|
||||
<Content Include="Views\Admin\Create.aspx" />
|
||||
<Content Include="Views\Admin\Edit.aspx" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
<Content Include="Views\Shared\EditorTemplates\UserRolesViewModel.ascx" />
|
||||
<Content Include="Views\EditorTemplates\Parts\Roles.UserRoles.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Content\Site.css" />
|
||||
<Content Include="Views\Web.config" />
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Roles.ViewModels.UserRolesViewModel>" %>
|
||||
<fieldset>
|
||||
<legend>Roles</legend>
|
||||
<% if (Model.Roles.Count > 0) {
|
||||
var index = 0;
|
||||
foreach (var entry in Model.Roles) {%>
|
||||
<%=Html.Hidden("Roles[" + index + "].RoleId", entry.RoleId)%>
|
||||
<%=Html.Hidden("Roles[" + index + "].Name", entry.Name)%>
|
||||
<label for="<%="Roles[" + index + "]_Granted"%>">
|
||||
<%= Html.CheckBox("Roles[" + index + "].Granted", entry.Granted)%>
|
||||
<%=Html.Encode(entry.Name)%></label>
|
||||
<%++index;
|
||||
}
|
||||
}
|
||||
else {
|
||||
%><p>There are no roles</p><%
|
||||
} %>
|
||||
</fieldset>
|
||||
@@ -32,7 +32,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
Pages = _contentManager.Query<SandboxPage, SandboxPageRecord>()
|
||||
.OrderBy(x => x.Name)
|
||||
.List()
|
||||
.Select(x => _contentManager.BuildDisplayModel(x, null, "SummaryList"))
|
||||
.Select(x => _contentManager.BuildDisplayModel(x, "SummaryList"))
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
public ActionResult Show(int id) {
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageShowViewModel {
|
||||
Page = _contentManager.BuildDisplayModel(page, null, "Detail")
|
||||
Page = _contentManager.BuildDisplayModel(page, "Detail")
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageEditViewModel {
|
||||
Page = _contentManager.BuildEditorModel(page, null)
|
||||
Page = _contentManager.BuildEditorModel(page)
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
@@ -95,7 +95,7 @@ namespace Orchard.Sandbox.Controllers {
|
||||
|
||||
var page = _contentManager.Get<SandboxPage>(id);
|
||||
var model = new PageEditViewModel {
|
||||
Page = _contentManager.UpdateEditorModel(page, null, this)
|
||||
Page = _contentManager.UpdateEditorModel(page, this)
|
||||
};
|
||||
if (!ModelState.IsValid)
|
||||
return View(model);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Orchard.Sandbox.Models {
|
||||
Filters.Add(new ActivatingFilter<RoutableAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPage.ContentType.Name));
|
||||
Filters.Add(new StorageFilter<SandboxPageRecord>(pageRepository) { AutomaticallyCreateMissingRecord = true });
|
||||
Filters.Add(new ContentItemTemplates<SandboxPage>("Summary"));
|
||||
Filters.Add(new ContentItemTemplates<SandboxPage>("Items/Sandbox.Page", "Summary"));
|
||||
|
||||
OnGetItemMetadata<SandboxPage>((context, page) => {
|
||||
context.Metadata.DisplayText = page.Record.Name;
|
||||
|
||||
@@ -102,7 +102,7 @@ namespace Orchard.Tags.Controllers {
|
||||
var tag = _tagService.GetTagByName(tagName);
|
||||
var items =
|
||||
_tagService.GetTaggedContentItems(tag.Id).Select(
|
||||
ic => _contentManager.BuildDisplayModel(ic, null, "SummaryForSearch"));
|
||||
ic => _contentManager.BuildDisplayModel(ic, "SummaryForSearch"));
|
||||
|
||||
var viewModel = new TagsSearchViewModel {
|
||||
TagName = tag.TagName,
|
||||
|
||||
@@ -13,65 +13,64 @@ using Orchard.Users.ViewModels;
|
||||
namespace Orchard.Users.Controllers {
|
||||
|
||||
public class AdminController : Controller, IUpdateModel {
|
||||
|
||||
private readonly IMembershipService _membershipService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly IRepository<UserRecord> _userRepository;
|
||||
private readonly INotifier _notifier;
|
||||
|
||||
public AdminController(
|
||||
IMembershipService membershipService,
|
||||
IContentManager contentManager,
|
||||
IRepository<UserRecord> userRepository,
|
||||
INotifier notifier) {
|
||||
IOrchardServices services,
|
||||
IMembershipService membershipService) {
|
||||
Services = services;
|
||||
_membershipService = membershipService;
|
||||
_contentManager = contentManager;
|
||||
_userRepository = userRepository;
|
||||
_notifier = notifier;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
|
||||
public IUser CurrentUser { get; set; }
|
||||
|
||||
public IOrchardServices Services { get; set; }
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ActionResult Index() {
|
||||
var model = new UsersIndexViewModel();
|
||||
|
||||
var users = _contentManager.Query<User, UserRecord>("user")
|
||||
public ActionResult Index() {
|
||||
var users = Services.ContentManager
|
||||
.Query<User, UserRecord>(Models.User.ContentType.Name)
|
||||
.Where(x => x.UserName != null)
|
||||
.List();
|
||||
|
||||
model.Rows = users.Select(x => new UsersIndexViewModel.Row { User = x }).ToList();
|
||||
var model = new UsersIndexViewModel {
|
||||
Rows = users
|
||||
.Select(x => new UsersIndexViewModel.Row { User = x })
|
||||
.ToList()
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public ActionResult Create() {
|
||||
var user = _contentManager.New("user");
|
||||
var user = Services.ContentManager.New<IUser>(Models.User.ContentType.Name);
|
||||
var model = new UserCreateViewModel {
|
||||
EditorModel = _contentManager.BuildEditorModel(user, null)
|
||||
User = Services.ContentManager.BuildEditorModel(user)
|
||||
};
|
||||
return View(model);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Create(UserCreateViewModel model) {
|
||||
[HttpPost, ActionName("Create")]
|
||||
public ActionResult _Create() {
|
||||
|
||||
var model = new UserCreateViewModel();
|
||||
UpdateModel(model);
|
||||
|
||||
if (model.Password != model.ConfirmPassword) {
|
||||
ModelState.AddModelError("ConfirmPassword", T("Password confirmation must match").ToString());
|
||||
}
|
||||
if (ModelState.IsValid == false) {
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(_contentManager.New("user"), null, this);
|
||||
return View(model);
|
||||
}
|
||||
var user = _membershipService.CreateUser(new CreateUserParams(
|
||||
model.UserName,
|
||||
model.Password,
|
||||
model.Email,
|
||||
null, null, true));
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(user, null, this);
|
||||
|
||||
model.User = Services.ContentManager.UpdateEditorModel(user, this);
|
||||
|
||||
if (model.Password != model.ConfirmPassword) {
|
||||
AddModelError("ConfirmPassword", T("Password confirmation must match"));
|
||||
}
|
||||
|
||||
if (ModelState.IsValid == false) {
|
||||
//TODO: rollback transaction
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
@@ -79,29 +78,33 @@ namespace Orchard.Users.Controllers {
|
||||
}
|
||||
|
||||
public ActionResult Edit(int id) {
|
||||
var model = new UserEditViewModel { User = _contentManager.Get<User>(id) };
|
||||
model.EditorModel = _contentManager.BuildEditorModel(model.User.ContentItem, null);
|
||||
return View(model);
|
||||
return View(new UserEditViewModel {
|
||||
User = Services.ContentManager.BuildEditorModel<User>(id)
|
||||
});
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Edit(int id, FormCollection input) {
|
||||
var model = new UserEditViewModel { User = _contentManager.Get<User>(id) };
|
||||
model.EditorModel = _contentManager.UpdateEditorModel(model.User.ContentItem, null, this);
|
||||
[HttpPost, ActionName("Edit")]
|
||||
public ActionResult _Edit(int id) {
|
||||
var model = new UserEditViewModel {
|
||||
User = Services.ContentManager.UpdateEditorModel<User>(id, this)
|
||||
};
|
||||
|
||||
if (!TryUpdateModel(model, input.ToValueProvider())) {
|
||||
// apply additional model properties that were posted on form
|
||||
UpdateModel(model);
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
Services.TransactionManager.Cancel();
|
||||
return View(model);
|
||||
}
|
||||
|
||||
_notifier.Information(T("User information updated"));
|
||||
Services.Notifier.Information(T("User information updated"));
|
||||
return RedirectToAction("Edit", new { id });
|
||||
}
|
||||
|
||||
|
||||
bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) {
|
||||
return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
|
||||
}
|
||||
void IUpdateModel.AddModelError(string key, LocalizedString errorMessage) {
|
||||
public void AddModelError(string key, LocalizedString errorMessage) {
|
||||
ModelState.AddModelError(key, errorMessage.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Orchard.Users.Controllers {
|
||||
[HandleError]
|
||||
public class HomeController : Controller {
|
||||
public ActionResult Index() {
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ namespace Orchard.Users.Models {
|
||||
public UserHandler(IRepository<UserRecord> repository) {
|
||||
Filters.Add(new ActivatingFilter<User>("user"));
|
||||
Filters.Add(new StorageFilter<UserRecord>(repository));
|
||||
Filters.Add(new ContentItemTemplates<User>("Items/Users.User"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\AdminController.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Models\User.cs" />
|
||||
<Compile Include="Models\UserHandler.cs" />
|
||||
<Compile Include="Models\UserRecord.cs" />
|
||||
@@ -78,10 +77,9 @@
|
||||
<Content Include="Views\Admin\Edit.aspx" />
|
||||
<Content Include="Views\Admin\Create.aspx" />
|
||||
<Content Include="Views\Admin\EditorTemplates\inputPasswordLarge.ascx" />
|
||||
<Content Include="Views\Admin\EditorTemplates\UserEditViewModel.ascx" />
|
||||
<Content Include="Views\Admin\EditorTemplates\inputTextLarge.ascx" />
|
||||
<Content Include="Views\Admin\EditorTemplates\UserCreateViewModel.ascx" />
|
||||
<Content Include="Views\Admin\Index.aspx" />
|
||||
<Content Include="Views\EditorTemplates\Items\Users.User.ascx" />
|
||||
<Content Include="Web.config" />
|
||||
<Content Include="Views\Web.config" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Orchard.Models.ViewModels;
|
||||
using Orchard.Mvc.ViewModels;
|
||||
using Orchard.Security;
|
||||
using Orchard.Users.Models;
|
||||
|
||||
namespace Orchard.Users.ViewModels {
|
||||
public class UserCreateViewModel : AdminViewModel {
|
||||
@@ -18,6 +20,6 @@ namespace Orchard.Users.ViewModels {
|
||||
[Required, DataType(DataType.Password)]
|
||||
public string ConfirmPassword { get; set; }
|
||||
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
public ItemEditorModel<IUser> User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -7,26 +7,23 @@ using Orchard.Users.Models;
|
||||
|
||||
namespace Orchard.Users.ViewModels {
|
||||
public class UserEditViewModel : AdminViewModel {
|
||||
public User User { get; set; }
|
||||
public ItemEditorModel EditorModel { get; set; }
|
||||
|
||||
|
||||
[HiddenInput(DisplayValue = false)]
|
||||
public int Id {
|
||||
get { return User.Id; }
|
||||
get { return User.Item.Id; }
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string UserName {
|
||||
get { return User.As<User>().Record.UserName; }
|
||||
set { User.As<User>().Record.UserName = value; }
|
||||
get { return User.Item.Record.UserName; }
|
||||
set { User.Item.Record.UserName = value; }
|
||||
}
|
||||
|
||||
[Required]
|
||||
public string Email {
|
||||
get { return User.As<User>().Record.Email; }
|
||||
set { User.As<User>().Record.Email = value; }
|
||||
get { return User.Item.Record.Email; }
|
||||
set { User.Item.Record.Email = value; }
|
||||
}
|
||||
|
||||
public ItemEditorModel<User> User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Users.ViewModels.UserCreateViewModel>" %>
|
||||
|
||||
<%@ Import Namespace="Orchard.Security" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<h2>Add User</h2>
|
||||
<%using (Html.BeginForm()) { %>
|
||||
<%= Html.ValidationSummary() %>
|
||||
<%= Html.EditorForModel() %>
|
||||
<%=Html.ValidationSummary() %>
|
||||
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Password, "inputPasswordLarge") %>
|
||||
<%=Html.EditorFor(m=>m.ConfirmPassword, "inputPasswordLarge") %>
|
||||
<%=Html.EditorForItem(Model.User) %>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Create" />
|
||||
</fieldset>
|
||||
<% } %>
|
||||
<% } %>
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Orchard.Users.ViewModels.UserEditViewModel>" %>
|
||||
|
||||
<%@ Import Namespace="Orchard.Security" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<h2>Edit User</h2>
|
||||
<h2>
|
||||
Edit User</h2>
|
||||
<%using (Html.BeginForm()) { %>
|
||||
<ol>
|
||||
<%= Html.ValidationSummary() %>
|
||||
<%= Html.EditorForModel() %>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Save" />
|
||||
</fieldset>
|
||||
<% } %>
|
||||
<%=Html.ValidationSummary() %>
|
||||
<%=Html.EditorFor(m=>m.Id) %>
|
||||
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||
<%=Html.EditorForItem(Model.User) %>
|
||||
<fieldset>
|
||||
<input class="button" type="submit" value="Save" />
|
||||
</fieldset>
|
||||
<% } %>
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Users.ViewModels.UserCreateViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Utility" %>
|
||||
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Password, "inputPasswordLarge") %>
|
||||
<%=Html.EditorFor(m=>m.ConfirmPassword, "inputPasswordLarge") %>
|
||||
<%
|
||||
foreach(var e in Model.EditorModel.Editors) {
|
||||
var editor = e;%>
|
||||
<%=Html.EditorFor(m => editor.Model, editor.TemplateName, editor.Prefix)%>
|
||||
<% } %>
|
||||
@@ -1,8 +0,0 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Orchard.Users.ViewModels.UserEditViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Utility" %>
|
||||
<%=Html.EditorFor(m=>m.Id) %>
|
||||
<%=Html.EditorFor(m=>m.UserName, "inputTextLarge") %>
|
||||
<%=Html.EditorFor(m=>m.Email, "inputTextLarge") %>
|
||||
<% foreach(var e in Model.EditorModel.Editors) {%>
|
||||
<%=Html.EditorFor(m => e.Model, e.TemplateName, e.Prefix)%>
|
||||
<%} %>
|
||||
@@ -0,0 +1,5 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ItemEditorModel<User>>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<%@ Import Namespace="Orchard.Models.ViewModels" %>
|
||||
<%@ Import Namespace="Orchard.Users.Models" %>
|
||||
<%=Html.EditorZonesAny() %>
|
||||
16
src/Orchard.Web/Themes/BlueSky/Views/layout.ascx
Normal file
16
src/Orchard.Web/Themes/BlueSky/Views/layout.ascx
Normal file
@@ -0,0 +1,16 @@
|
||||
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<BaseViewModel>" %>
|
||||
<%@ Import Namespace="Orchard.Mvc.ViewModels"%>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
|
||||
<% Html.RegisterStyle(ResolveUrl("~/Themes/BlueSky/Styles/site.css")); %>
|
||||
|
||||
<div class="page">
|
||||
<div id="header">
|
||||
<div id="title"><h1>My MVC Application</h1></div>
|
||||
<%Html.Zone("header"); Html.Zone("menu"); %>
|
||||
</div>
|
||||
<div id="main">
|
||||
<%Html.Zone("content", () => Html.RenderBody() );%>
|
||||
<div id="footer"><%Html.Zone("footer");%></div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user