--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 {
public class NavigationDataMigration : DataMigrationImpl {
@ -20,5 +21,14 @@ namespace Orchard.Core.Navigation.DataMigrations {
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]
public class MenuPartHandler : ContentHandler {
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));
OnInitializing<MenuPart>((ctx, x) => {

View File

@ -13,13 +13,6 @@ namespace Futures.Widgets.Controllers {
IRepository<HasWidgetsRecord> hasWidgetRepository,
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
Filters.Add(StorageFilter.For(hasWidgetRepository));
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 {
public class WidgetsDataMigration : DataMigrationImpl {
@ -19,5 +20,20 @@ namespace Futures.Widgets.DataMigrations {
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() {
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
.WithLocation(new Dictionary<string, ContentLocation> {
{"Editor", new ContentLocation { Zone = "primary", Position = "1" }}
}));
return 2;
return 3;
}
}
}

View File

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

View File

@ -1,18 +1,12 @@
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Models;
using Orchard.Core.Routable.Models;
using Orchard.Data;
namespace Orchard.Blogs.Handlers {
[UsedImplicitly]
public class BlogHandler : ContentHandler {
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));
}
}

View File

@ -2,14 +2,10 @@ using System;
using System.Linq;
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.Blogs.Drivers;
using Orchard.Blogs.Models;
using Orchard.Blogs.Services;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.PublishLater.Models;
using Orchard.Core.Routable.Models;
using Orchard.Localization;
namespace Orchard.Blogs.Handlers {
@ -23,13 +19,6 @@ namespace Orchard.Blogs.Handlers {
_orchardServices = orchardServices;
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 =
(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;
namespace Orchard.Blogs.Models {

View File

@ -1,4 +1,5 @@
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Orchard.Comments.DataMigrations {
@ -43,5 +44,20 @@ namespace Orchard.Comments.DataMigrations {
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]
public class CommentHandler : ContentHandler {
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));
}
}

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="Models\CommentStatus.cs" />
<Compile Include="Models\HasCommentsContainer.cs" />
<Compile Include="Handlers\HasCommentsContainerHandler.cs" />
<Compile Include="Feeds\CommentedOnContainerFeedQuery.cs" />
<Compile Include="Feeds\CommentedOnFeedQuery.cs" />
<Compile Include="Feeds\CommentFeedItemBuilder.cs" />

View File

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

View File

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

View File

@ -6,6 +6,7 @@ using Orchard.Localization;
using Orchard.Modules.ViewModels;
using Orchard.Mvc.Results;
using Orchard.Packaging;
using Orchard.Reports.Services;
using Orchard.UI.Notify;
namespace Orchard.Modules.Controllers {
@ -13,16 +14,19 @@ namespace Orchard.Modules.Controllers {
private readonly IModuleService _moduleService;
private readonly IDataMigrationManager _dataMigrationManager;
private readonly IPackageManager _packageManager;
private readonly IReportsCoordinator _reportsCoordinator;
public AdminController(IOrchardServices services,
IModuleService moduleService,
IDataMigrationManager dataMigrationManager,
IPackageManager packageManager) {
IPackageManager packageManager,
IReportsCoordinator reportsCoordinator) {
Services = services;
_moduleService = moduleService;
_dataMigrationManager = dataMigrationManager;
_packageManager = packageManager;
_reportsCoordinator = reportsCoordinator;
T = NullLocalizer.Instance;
}
@ -113,7 +117,7 @@ namespace Orchard.Modules.Controllers {
}
[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")))
return new HttpUnauthorizedResult();
@ -121,6 +125,7 @@ namespace Orchard.Modules.Controllers {
return new NotFoundResult();
try {
_reportsCoordinator.Register("Data Migration", "Upgrade " + id, "Orchard installation");
_dataMigrationManager.Update(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)){
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("force", true)%>
<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="Controllers\AdminController.cs" />
<Compile Include="Controllers\PageController.cs" />
<Compile Include="DataMigrations\PageDataMigration.cs" />
<Compile Include="Drivers\PageDriver.cs" />
<Compile Include="Models\Page.cs" />
<Compile Include="Handlers\PageHandler.cs" />
<Compile Include="Permissions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Routes.cs" />
@ -122,6 +122,9 @@
<Name>Orchard.Core</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Handlers\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.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.

View File

@ -1,4 +1,5 @@
using Orchard.Data.Migration;
using Orchard.ContentManagement.MetaData;
using Orchard.Data.Migration;
namespace Orchard.Sandbox.DataMigrations {
public class SandboxDataMigration : DataMigrationImpl {
@ -16,5 +17,18 @@ namespace Orchard.Sandbox.DataMigrations {
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 Orchard.Core.Common.Models;
using Orchard.Core.Routable.Models;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Sandbox.Drivers;
using Orchard.Sandbox.Models;
namespace Orchard.Sandbox.Handlers {
@ -12,10 +9,6 @@ namespace Orchard.Sandbox.Handlers {
public class SandboxContentHandler : ContentHandler {
public SandboxContentHandler(IRepository<SandboxPageRecord> pageRepository, IRepository<SandboxSettingsRecord> settingsRepository) {
// 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) );
// add settings to site, and simple record-template gui

View File

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