Updated upgrade process for 1.6

--HG--
branch : 1.x
rename : src/Orchard.Web/Modules/UpgradeTo15/AdminMenu.cs => src/Orchard.Web/Modules/UpgradeTo16/AdminMenu.cs
rename : src/Orchard.Web/Modules/UpgradeTo15/Controllers/FieldController.cs => src/Orchard.Web/Modules/UpgradeTo16/Controllers/FieldController.cs
rename : src/Orchard.Web/Modules/UpgradeTo15/Controllers/RouteController.cs => src/Orchard.Web/Modules/UpgradeTo16/Controllers/RouteController.cs
rename : src/Orchard.Web/Modules/UpgradeTo15/Module.txt => src/Orchard.Web/Modules/UpgradeTo16/Module.txt
rename : src/Orchard.Web/Modules/UpgradeTo15/Properties/AssemblyInfo.cs => src/Orchard.Web/Modules/UpgradeTo16/Properties/AssemblyInfo.cs
rename : src/Orchard.Web/Modules/UpgradeTo15/Scripts/Web.config => src/Orchard.Web/Modules/UpgradeTo16/Scripts/Web.config
rename : src/Orchard.Web/Modules/UpgradeTo15/Styles/Web.config => src/Orchard.Web/Modules/UpgradeTo16/Styles/Web.config
rename : src/Orchard.Web/Modules/UpgradeTo15/ViewModels/MigrateViewModel.cs => src/Orchard.Web/Modules/UpgradeTo16/ViewModels/MigrateViewModel.cs
rename : src/Orchard.Web/Modules/UpgradeTo15/Views/Field/Index.cshtml => src/Orchard.Web/Modules/UpgradeTo16/Views/Field/Index.cshtml
rename : src/Orchard.Web/Modules/UpgradeTo15/Views/Route/Index.cshtml => src/Orchard.Web/Modules/UpgradeTo16/Views/Route/Index.cshtml
rename : src/Orchard.Web/Modules/UpgradeTo15/Views/Web.config => src/Orchard.Web/Modules/UpgradeTo16/Views/Web.config
rename : src/Orchard.Web/Modules/UpgradeTo15/Web.config => src/Orchard.Web/Modules/UpgradeTo16/Web.config
This commit is contained in:
Sebastien Ros 2012-10-10 11:56:52 -07:00
parent 9543e4ed7b
commit 2fb0dc6fb3
18 changed files with 142 additions and 47 deletions

View File

@ -1,15 +1,9 @@
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Contents.Extensions;
using Orchard.Core.Navigation.Services;
using Orchard.Data.Migration;
namespace Orchard.Core.Navigation {
public class Migrations : DataMigrationImpl {
private readonly IMenuService _menuService;
public Migrations(IMenuService menuService ) {
_menuService = menuService;
}
public int Create() {
ContentDefinitionManager.AlterPartDefinition("MenuPart", builder => builder.Attachable());
@ -181,20 +175,6 @@ namespace Orchard.Core.Navigation {
.WithSetting("Stereotype", "MenuItem")
);
// create a Main Menu
var mainMenu = _menuService.Create("Main Menu");
// assign the Main Menu to all current menu items
foreach (var menuItem in _menuService.Get()) {
// if they don't have a position or a text, then they are not displayed
if(string.IsNullOrWhiteSpace(menuItem.MenuPosition) || string.IsNullOrEmpty(menuItem.MenuText)) {
continue;
}
menuItem.Menu = mainMenu.ContentItem;
}
// at this point a widget should still be created to display the navigation
return 3;
}
}

View File

@ -1,11 +0,0 @@
Name: UpgradeTo15
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.5
OrchardVersion: 1.5
Description: Description for the module
Features:
UpgradeTo15:
Description: Description for feature UpgradeTo15.
Dependencies: Orchard.Autoroute, Title

View File

@ -2,7 +2,7 @@
using Orchard.Security;
using Orchard.UI.Navigation;
namespace UpgradeTo15 {
namespace UpgradeTo16 {
public class AdminMenu : INavigationProvider {
public Localizer T { get; set; }
@ -12,9 +12,10 @@ namespace UpgradeTo15 {
public void GetNavigation(NavigationBuilder builder) {
builder
.Add(T("Migrate to 1.5"), "0", menu => menu.Action("Index", "Route", new { area = "UpgradeTo15" })
.Add(T("Migrate Routes"), "0", item => item.Action("Index", "Route", new { area = "UpgradeTo15" }).LocalNav().Permission(StandardPermissions.SiteOwner))
.Add(T("Migrate Fields"), "0", item => item.Action("Index", "Field", new { area = "UpgradeTo15" }).LocalNav().Permission(StandardPermissions.SiteOwner))
.Add(T("Upgrade to 1.6"), "0", menu => menu.Action("Index", "Route", new { area = "UpgradeTo16" })
.Add(T("Migrate Routes"), "0", item => item.Action("Index", "Route", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
.Add(T("Migrate Fields"), "0", item => item.Action("Index", "Field", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
.Add(T("Migrate Menu"), "0", item => item.Action("Index", "Menu", new { area = "UpgradeTo16" }).LocalNav().Permission(StandardPermissions.SiteOwner))
);
}
}

View File

@ -9,9 +9,9 @@ using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using UpgradeTo15.ViewModels;
using UpgradeTo16.ViewModels;
namespace UpgradeTo15.Controllers {
namespace UpgradeTo16.Controllers {
[Admin]
public class FieldController : Controller {
private readonly IContentDefinitionManager _contentDefinitionManager;

View File

@ -0,0 +1,92 @@
using System.Linq;
using System.Web.Mvc;
using Orchard;
using Orchard.ContentManagement;
using Orchard.Core.Navigation.Models;
using Orchard.Core.Navigation.Services;
using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using Orchard.Widgets.Models;
using Orchard.Widgets.Services;
namespace UpgradeTo16.Controllers {
[Admin]
public class MenuController : Controller {
private readonly IMenuService _menuService;
private readonly IOrchardServices _orchardServices;
private readonly IWidgetsService _widgetsService;
public MenuController(
IMenuService menuService,
IOrchardServices orchardServices,
IWidgetsService widgetsService ) {
_menuService = menuService;
_orchardServices = orchardServices;
_widgetsService = widgetsService;
}
public Localizer T { get; set; }
public ActionResult Index() {
var menus = _menuService.GetMenus();
if(menus.Any()) {
_orchardServices.Notifier.Warning(T("This step is unnecessary as some menus already exist."));
}
return View();
}
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST() {
if (!_orchardServices.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not allowed to migrate the navigation.")))
return new HttpUnauthorizedResult();
var menus = _menuService.GetMenus();
if (menus.Any()) {
_orchardServices.Notifier.Error(T("This step is unnecessary as some menus already exist."));
return View();
}
// create a Main Menu
var mainMenu = _menuService.Create("Main Menu");
_orchardServices.Notifier.Information(T("Main menu created"));
// assign the Main Menu to all current menu items
foreach (var menuItem in _menuService.Get()) {
// if they don't have a position or a text, then they are not displayed
if (string.IsNullOrWhiteSpace(menuItem.MenuPosition) || string.IsNullOrEmpty(menuItem.MenuText)) {
continue;
}
menuItem.Menu = mainMenu.ContentItem;
}
_orchardServices.Notifier.Information(T("Menu items moved to Main menu"));
// a widget should is created to display the navigation
var layer = _widgetsService.GetLayers().FirstOrDefault(x => x.Name == "Default");
if(layer == null) {
_orchardServices.Notifier.Warning(T("Widget could not be created. Please create it manually."));
}
var widget = _widgetsService.CreateWidget(layer.Id, "MenuWidget", "Main Menu", "1.0", "Navigation");
widget.RenderTitle = false;
var menuWidget = widget.As<MenuWidgetPart>();
menuWidget.Menu = mainMenu.ContentItem.Record;
menuWidget.StartLevel = 1;
menuWidget.Levels = 1;
menuWidget.Breadcrumb = false;
menuWidget.AddHomePage = false;
menuWidget.AddCurrentPage = false;
_orchardServices.ContentManager.Publish(menuWidget.ContentItem);
return View("Index");
}
}
}

View File

@ -18,9 +18,9 @@ using Orchard.Reports.Services;
using Orchard.Security;
using Orchard.UI.Admin;
using Orchard.UI.Notify;
using UpgradeTo15.ViewModels;
using UpgradeTo16.ViewModels;
namespace UpgradeTo15.Controllers {
namespace UpgradeTo16.Controllers {
[Admin]
public class RouteController : Controller {
private readonly IContentDefinitionManager _contentDefinitionManager;
@ -73,7 +73,7 @@ namespace UpgradeTo15.Controllers {
if(TryUpdateModel(viewModel)) {
// creating report
_reportsCoordinator.Register("Migration", "UpgradeTo15", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
_reportsCoordinator.Register("Migration", "UpgradeTo16", "Migrating " + string.Join(" ,", viewModel.ContentTypes.Where(x => x.IsChecked).Select(x => x.ContentTypeName).ToArray()));
var contentTypesToMigrate = viewModel.ContentTypes.Where(c => c.IsChecked).Select(c => c.ContentTypeName);

View File

@ -0,0 +1,11 @@
Name: UpgradeTo16
AntiForgery: enabled
Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.6
OrchardVersion: 1.5
Description: Description for the module
Features:
UpgradeTo16:
Description: Description for feature UpgradeTo16.
Dependencies: Orchard.Autoroute, Title, Navigation

View File

@ -6,7 +6,7 @@ using System.Security;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UpgradeTo15")]
[assembly: AssemblyTitle("UpgradeTo16")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Orchard")]

View File

@ -10,8 +10,8 @@
<ProjectTypeGuids>{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UpgradeTo15</RootNamespace>
<AssemblyName>UpgradeTo15</AssemblyName>
<RootNamespace>UpgradeTo16</RootNamespace>
<AssemblyName>UpgradeTo16</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<FileUpgradeFlags>
@ -88,9 +88,14 @@
<Project>{66FCCD76-2761-47E3-8D11-B45D0001DDAA}</Project>
<Name>Orchard.Autoroute</Name>
</ProjectReference>
<ProjectReference Include="..\Orchard.Widgets\Orchard.Widgets.csproj">
<Project>{194D3CCC-1153-474D-8176-FDE8D7D0D0BD}</Project>
<Name>Orchard.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="AdminMenu.cs" />
<Compile Include="Controllers\MenuController.cs" />
<Compile Include="Controllers\FieldController.cs" />
<Compile Include="Controllers\RouteController.cs" />
<Compile Include="ViewModels\MigrateViewModel.cs" />
@ -102,6 +107,9 @@
<Content Include="Views\Field\Index.cshtml" />
<Content Include="Views\Route\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Menu\Index.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace UpgradeTo15.ViewModels {
namespace UpgradeTo16.ViewModels {
public class MigrateViewModel {
public IList<ContentTypeEntry> ContentTypes { get; set; }
}

View File

@ -1,5 +1,5 @@
@using Orchard.Utility.Extensions
@model UpgradeTo15.ViewModels.MigrateViewModel
@model UpgradeTo16.ViewModels.MigrateViewModel
@{ Layout.Title = T("Migrate Fields").ToString(); }

View File

@ -0,0 +1,14 @@
@using Orchard.Utility.Extensions
@{ Layout.Title = T("Migrate Menu").ToString(); }
@using (Html.BeginFormAntiForgeryPost()) {
Html.ValidationSummary();
<fieldset>
<legend>@T("Migrating Menu:")</legend>
<span class="hint">@T("This migration step will create a new Menu named \"Main Menu\" and add all your previous menu items to it. Finally it will create a new \"Menu Widget\" instance to render this menu on the website.")</span>
</fieldset>
<fieldset>
<button type="submit">@T("Migrate")</button>
</fieldset>
}

View File

@ -1,5 +1,5 @@
@using Orchard.Utility.Extensions
@model UpgradeTo15.ViewModels.MigrateViewModel
@model UpgradeTo16.ViewModels.MigrateViewModel
@{ Layout.Title = T("Migrate Routes").ToString(); }

View File

@ -142,7 +142,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.ContentPermissions"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SysCache", "Orchard.Web\Modules\SysCache\SysCache.csproj", "{3BD22132-D538-48C6-8854-F71333C798EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpgradeTo15", "Orchard.Web\Modules\UpgradeTo15\UpgradeTo15.csproj", "{8A9FDB57-342D-49C2-BAFC-D885AAE5CC7C}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpgradeTo16", "Orchard.Web\Modules\UpgradeTo16\UpgradeTo16.csproj", "{8A9FDB57-342D-49C2-BAFC-D885AAE5CC7C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution