--HG--
branch : dev
This commit is contained in:
Renaud Paquay 2010-07-21 18:01:49 -07:00
commit 5eb8808653
23 changed files with 120 additions and 98 deletions

View File

@ -1,4 +1,5 @@
using Orchard.Data.Migration; using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Orchard.Core.Navigation.DataMigrations { namespace Orchard.Core.Navigation.DataMigrations {
public class NavigationDataMigration : DataMigrationImpl { public class NavigationDataMigration : DataMigrationImpl {
@ -20,5 +21,14 @@ namespace Orchard.Core.Navigation.DataMigrations {
return 1; return 1;
} }
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Blog", cfg => cfg.WithPart("MenuPart"));
ContentDefinitionManager.AlterTypeDefinition("Page", cfg => cfg.WithPart("MenuPart"));
ContentDefinitionManager.AlterTypeDefinition("MenuItem", cfg => cfg.WithPart("MenuPart"));
return 2;
}
} }
} }

View File

@ -8,9 +8,6 @@ namespace Orchard.Core.Navigation.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class MenuPartHandler : ContentHandler { public class MenuPartHandler : ContentHandler {
public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) { public MenuPartHandler(IRepository<MenuPartRecord> menuPartRepository) {
Filters.Add(new ActivatingFilter<MenuPart>("Blog"));
Filters.Add(new ActivatingFilter<MenuPart>("Page"));
Filters.Add(new ActivatingFilter<MenuPart>("MenuItem"));
Filters.Add(StorageFilter.For(menuPartRepository)); Filters.Add(StorageFilter.For(menuPartRepository));
OnInitializing<MenuPart>((ctx, x) => { OnInitializing<MenuPart>((ctx, x) => {

View File

@ -13,13 +13,6 @@ namespace Futures.Widgets.Controllers {
IRepository<HasWidgetsRecord> hasWidgetRepository, IRepository<HasWidgetsRecord> hasWidgetRepository,
IRepository<WidgetRecord> widgetRepository) { IRepository<WidgetRecord> widgetRepository) {
// marking the "Site" content type as a widget container
Filters.Add(new ActivatingFilter<HasWidgets>("Site"));
// adding parts to the "HtmlWidget" content type
Filters.Add(new ActivatingFilter<Widget>("HtmlWidget"));
Filters.Add(new ActivatingFilter<BodyAspect>("HtmlWidget"));
// providing standard storage support for widget records // providing standard storage support for widget records
Filters.Add(StorageFilter.For(hasWidgetRepository)); Filters.Add(StorageFilter.For(hasWidgetRepository));
Filters.Add(StorageFilter.For(widgetRepository)); Filters.Add(StorageFilter.For(widgetRepository));

View File

@ -1,4 +1,5 @@
using Orchard.Data.Migration; using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Futures.Widgets.DataMigrations { namespace Futures.Widgets.DataMigrations {
public class WidgetsDataMigration : DataMigrationImpl { public class WidgetsDataMigration : DataMigrationImpl {
@ -19,5 +20,20 @@ namespace Futures.Widgets.DataMigrations {
return 1; return 1;
} }
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Site",
cfg => cfg
.WithPart("HasWidgets")
);
ContentDefinitionManager.AlterTypeDefinition("HtmlWidget",
cfg => cfg
.WithPart("Widget")
.WithPart("BodyAspect")
);
return 2;
}
} }
} }

View File

@ -29,12 +29,31 @@ namespace Orchard.Blogs.DataMigrations {
} }
public int UpdateFrom1() { public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.WithPart("Blog")
.WithPart("CommonAspect")
.WithPart("IsRoutable")
);
ContentDefinitionManager.AlterTypeDefinition("BlogPost",
cfg => cfg
.WithPart("BlogPost")
.WithPart("CommonAspect")
.WithPart("PublishLaterPart")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
);
return 2;
}
public int UpdateFrom2() {
ContentDefinitionManager.AlterPartDefinition(typeof(Blog).Name, cfg => cfg ContentDefinitionManager.AlterPartDefinition(typeof(Blog).Name, cfg => cfg
.WithLocation(new Dictionary<string, ContentLocation> { .WithLocation(new Dictionary<string, ContentLocation> {
{"Editor", new ContentLocation { Zone = "primary", Position = "1" }} {"Editor", new ContentLocation { Zone = "primary", Position = "1" }}
})); }));
return 3;
return 2;
} }
} }
} }

View File

@ -1,29 +1,22 @@
using System; using System.Web.Routing;
using System.Web.Routing;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers; using Orchard.ContentManagement.Drivers;
using Orchard.Core.Routable.Services;
using Orchard.Localization; using Orchard.Localization;
namespace Orchard.Blogs.Drivers { namespace Orchard.Blogs.Drivers {
[UsedImplicitly] [UsedImplicitly]
public class BlogPostDriver : ContentItemDriver<BlogPost> { public class BlogPostDriver : ContentItemDriver<BlogPost> {
public IOrchardServices Services { get; set; } public IOrchardServices Services { get; set; }
private readonly IBlogPostService _blogPostService;
private readonly IRoutableService _routableService;
public readonly static ContentType ContentType = new ContentType { public readonly static ContentType ContentType = new ContentType {
Name = "BlogPost", Name = "BlogPost",
DisplayName = "Blog Post" DisplayName = "Blog Post"
}; };
public BlogPostDriver(IOrchardServices services, IBlogService blogService, IBlogPostService blogPostService, IRoutableService routableService) { public BlogPostDriver(IOrchardServices services) {
Services = services; Services = services;
_blogPostService = blogPostService;
_routableService = routableService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }

View File

@ -1,18 +1,12 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Core.Routable.Models;
using Orchard.Data; using Orchard.Data;
namespace Orchard.Blogs.Handlers { namespace Orchard.Blogs.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class BlogHandler : ContentHandler { public class BlogHandler : ContentHandler {
public BlogHandler(IRepository<BlogRecord> repository) { public BlogHandler(IRepository<BlogRecord> repository) {
Filters.Add(new ActivatingFilter<Blog>(BlogDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(BlogDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(BlogDriver.ContentType.Name));
Filters.Add(StorageFilter.For(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }

View File

@ -2,14 +2,10 @@ using System;
using System.Linq; using System.Linq;
using System.Web.Routing; using System.Web.Routing;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models; using Orchard.Blogs.Models;
using Orchard.Blogs.Services; using Orchard.Blogs.Services;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Core.PublishLater.Models;
using Orchard.Core.Routable.Models;
using Orchard.Localization; using Orchard.Localization;
namespace Orchard.Blogs.Handlers { namespace Orchard.Blogs.Handlers {
@ -23,13 +19,6 @@ namespace Orchard.Blogs.Handlers {
_orchardServices = orchardServices; _orchardServices = orchardServices;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Filters.Add(new ActivatingFilter<BlogPost>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<PublishLaterPart>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(BlogPostDriver.ContentType.Name));
Action<Blog> updateBlogPostCount = Action<Blog> updateBlogPostCount =
(blog => { (blog => {
// Ensure we get the "right" set of published posts for the blog // Ensure we get the "right" set of published posts for the blog

View File

@ -1,4 +1,3 @@
using Orchard.Data.Conventions;
using Orchard.ContentManagement.Records; using Orchard.ContentManagement.Records;
namespace Orchard.Blogs.Models { namespace Orchard.Blogs.Models {

View File

@ -1,4 +1,5 @@
using System; using System;
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration; using Orchard.Data.Migration;
namespace Orchard.Comments.DataMigrations { namespace Orchard.Comments.DataMigrations {
@ -43,5 +44,20 @@ namespace Orchard.Comments.DataMigrations {
return 1; return 1;
} }
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("Comment",
cfg => cfg
.WithPart("Comment")
.WithPart("CommonAspect")
);
ContentDefinitionManager.AlterTypeDefinition("Blog",
cfg => cfg
.WithPart("HasCommentsContainer")
);
return 2;
}
} }
} }

View File

@ -9,8 +9,6 @@ namespace Orchard.Comments.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class CommentHandler : ContentHandler { public class CommentHandler : ContentHandler {
public CommentHandler(IRepository<CommentRecord> commentsRepository) { public CommentHandler(IRepository<CommentRecord> commentsRepository) {
Filters.Add(new ActivatingFilter<Comment>(CommentDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(CommentDriver.ContentType.Name));
Filters.Add(StorageFilter.For(commentsRepository)); Filters.Add(StorageFilter.For(commentsRepository));
} }
} }

View File

@ -1,12 +0,0 @@
using JetBrains.Annotations;
using Orchard.Comments.Models;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class HasCommentsContainerHandler : ContentHandler {
public HasCommentsContainerHandler() {
Filters.Add(new ActivatingFilter<HasCommentsContainer>("Blog"));
}
}
}

View File

@ -82,7 +82,6 @@
<Compile Include="Handlers\CommentHandler.cs" /> <Compile Include="Handlers\CommentHandler.cs" />
<Compile Include="Models\CommentStatus.cs" /> <Compile Include="Models\CommentStatus.cs" />
<Compile Include="Models\HasCommentsContainer.cs" /> <Compile Include="Models\HasCommentsContainer.cs" />
<Compile Include="Handlers\HasCommentsContainerHandler.cs" />
<Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" /> <Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" />
<Compile Include="Feeds\CommentedOnFeedQuery.cs" /> <Compile Include="Feeds\CommentedOnFeedQuery.cs" />
<Compile Include="Feeds\CommentFeedItemBuilder.cs" /> <Compile Include="Feeds\CommentFeedItemBuilder.cs" />

View File

@ -12,5 +12,11 @@ namespace Orchard.Media.DataMigrations {
return 1; return 1;
} }
public int UpdateFrom1() {
// Filters.Add(new ActivatingFilter<MediaSettings>("Site"));
return 2;
}
} }
} }

View File

@ -7,7 +7,6 @@ namespace Orchard.Media.Handlers {
[UsedImplicitly] [UsedImplicitly]
public class MediaSettingsHandler : ContentHandler { public class MediaSettingsHandler : ContentHandler {
public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) { public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<MediaSettings>("Site"));
Filters.Add(StorageFilter.For(repository) ); Filters.Add(StorageFilter.For(repository) );
OnInitializing<MediaSettings>(DefaultSettings); OnInitializing<MediaSettings>(DefaultSettings);
} }

View File

@ -6,6 +6,7 @@ using Orchard.Localization;
using Orchard.Modules.ViewModels; using Orchard.Modules.ViewModels;
using Orchard.Mvc.Results; using Orchard.Mvc.Results;
using Orchard.Packaging; using Orchard.Packaging;
using Orchard.Reports.Services;
using Orchard.UI.Notify; using Orchard.UI.Notify;
namespace Orchard.Modules.Controllers { namespace Orchard.Modules.Controllers {
@ -13,16 +14,19 @@ namespace Orchard.Modules.Controllers {
private readonly IModuleService _moduleService; private readonly IModuleService _moduleService;
private readonly IDataMigrationManager _dataMigrationManager; private readonly IDataMigrationManager _dataMigrationManager;
private readonly IPackageManager _packageManager; private readonly IPackageManager _packageManager;
private readonly IReportsCoordinator _reportsCoordinator;
public AdminController(IOrchardServices services, public AdminController(IOrchardServices services,
IModuleService moduleService, IModuleService moduleService,
IDataMigrationManager dataMigrationManager, IDataMigrationManager dataMigrationManager,
IPackageManager packageManager) { IPackageManager packageManager,
IReportsCoordinator reportsCoordinator) {
Services = services; Services = services;
_moduleService = moduleService; _moduleService = moduleService;
_dataMigrationManager = dataMigrationManager; _dataMigrationManager = dataMigrationManager;
_packageManager = packageManager; _packageManager = packageManager;
_reportsCoordinator = reportsCoordinator;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }
@ -113,7 +117,7 @@ namespace Orchard.Modules.Controllers {
} }
[HttpPost] [HttpPost]
public ActionResult Update(string id, bool? force) { public ActionResult Update(string id) {
if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features"))) if (!Services.Authorizer.Authorize(Permissions.ManageFeatures, T("Not allowed to manage features")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
@ -121,6 +125,7 @@ namespace Orchard.Modules.Controllers {
return new NotFoundResult(); return new NotFoundResult();
try { try {
_reportsCoordinator.Register("Data Migration", "Upgrade " + id, "Orchard installation");
_dataMigrationManager.Update(id); _dataMigrationManager.Update(id);
Services.Notifier.Information(T("The feature {0} was updated succesfuly", id)); Services.Notifier.Information(T("The feature {0} was updated succesfuly", id));
} }

View File

@ -69,7 +69,6 @@
if(Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name)){ if(Model.FeaturesThatNeedUpdate.Contains(feature.Descriptor.Name)){
using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Update", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %> using (Html.BeginFormAntiForgeryPost(string.Format("{0}", Url.Action("Update", new { area = "Orchard.Modules" })), FormMethod.Post, new {@class = "inline link"})) { %>
<%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%> <%: Html.Hidden("id", feature.Descriptor.Name, new { id = "" })%>
<%: Html.Hidden("force", true)%>
<button type="submit" class="update"><%: T("Update") %></button><% <button type="submit" class="update"><%: T("Update") %></button><%
} }
}%> }%>

View File

@ -0,0 +1,20 @@
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Orchard.Pages.DataMigrations {
public class PageDataMigration : DataMigrationImpl {
public int Create() {
ContentDefinitionManager.AlterTypeDefinition("Page",
cfg => cfg
.WithPart("Page")
.WithPart("CommonAspect")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
);
return 1;
}
}
}

View File

@ -1,29 +0,0 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Routable.Models;
using Orchard.Localization;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Pages.Drivers;
using Orchard.Pages.Models;
using Orchard.Pages.Services;
namespace Orchard.Pages.Handlers {
[UsedImplicitly]
public class PageHandler : ContentHandler {
private readonly IPageService _pageService;
public PageHandler(IPageService pageService) {
_pageService = pageService;
T = NullLocalizer.Instance;
Filters.Add(new ActivatingFilter<Page>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(PageDriver.ContentType.Name));
}
Localizer T { get; set; }
}
}

View File

@ -72,9 +72,9 @@
<Compile Include="AdminMenu.cs" /> <Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\AdminController.cs" /> <Compile Include="Controllers\AdminController.cs" />
<Compile Include="Controllers\PageController.cs" /> <Compile Include="Controllers\PageController.cs" />
<Compile Include="DataMigrations\PageDataMigration.cs" />
<Compile Include="Drivers\PageDriver.cs" /> <Compile Include="Drivers\PageDriver.cs" />
<Compile Include="Models\Page.cs" /> <Compile Include="Models\Page.cs" />
<Compile Include="Handlers\PageHandler.cs" />
<Compile Include="Permissions.cs" /> <Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routes.cs" /> <Compile Include="Routes.cs" />
@ -122,6 +122,9 @@
<Name>Orchard.Core</Name> <Name>Orchard.Core</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Handlers\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -1,4 +1,5 @@
using Orchard.Data.Migration; using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Orchard.Sandbox.DataMigrations { namespace Orchard.Sandbox.DataMigrations {
public class SandboxDataMigration : DataMigrationImpl { public class SandboxDataMigration : DataMigrationImpl {
@ -16,5 +17,18 @@ namespace Orchard.Sandbox.DataMigrations {
return 1; return 1;
} }
public int UpdateFrom1() {
ContentDefinitionManager.AlterTypeDefinition("SandboxPage",
cfg => cfg
.WithPart("SandboxPage")
.WithPart("CommonAspect")
.WithPart("IsRoutable")
.WithPart("BodyAspect")
);
return 2;
}
} }
} }

View File

@ -1,10 +1,7 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Core.Routable.Models;
using Orchard.Data; using Orchard.Data;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.Sandbox.Drivers;
using Orchard.Sandbox.Models; using Orchard.Sandbox.Models;
namespace Orchard.Sandbox.Handlers { namespace Orchard.Sandbox.Handlers {
@ -12,10 +9,6 @@ namespace Orchard.Sandbox.Handlers {
public class SandboxContentHandler : ContentHandler { public class SandboxContentHandler : ContentHandler {
public SandboxContentHandler(IRepository<SandboxPageRecord> pageRepository, IRepository<SandboxSettingsRecord> settingsRepository) { public SandboxContentHandler(IRepository<SandboxPageRecord> pageRepository, IRepository<SandboxSettingsRecord> settingsRepository) {
// define the "SandboxPage" content type // define the "SandboxPage" content type
Filters.Add(new ActivatingFilter<SandboxPage>(SandboxPageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(SandboxPageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<IsRoutable>(SandboxPageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPageDriver.ContentType.Name));
Filters.Add(StorageFilter.For(pageRepository) ); Filters.Add(StorageFilter.For(pageRepository) );
// add settings to site, and simple record-template gui // add settings to site, and simple record-template gui

View File

@ -130,6 +130,7 @@ namespace Orchard.Setup.Services {
.Column<int>("Version")); .Column<int>("Version"));
var dataMigrationManager = environment.Resolve<IDataMigrationManager>(); var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
dataMigrationManager.Update("Settings");
foreach ( var feature in context.EnabledFeatures ) { foreach ( var feature in context.EnabledFeatures ) {
dataMigrationManager.Update(feature); dataMigrationManager.Update(feature);