From b92391533268232b783131f15bb8e467e997ae79 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Tue, 7 Feb 2012 16:04:57 -0800 Subject: [PATCH] Fixing List specflow tests --HG-- branch : autoroute --- .hgsubstate | 4 +- .../Bindings/OrchardSiteFactory.cs | 12 +- .../Modules/Orchard.Lists/Migrations.cs | 11 +- .../Modules/Orchard.Lists/Module.txt | 2 +- .../Modules/UpgradeTo14/Migrations.cs | 131 ------------------ .../Modules/UpgradeTo14/UpgradeTo14.csproj | 1 - 6 files changed, 24 insertions(+), 137 deletions(-) delete mode 100644 src/Orchard.Web/Modules/UpgradeTo14/Migrations.cs diff --git a/.hgsubstate b/.hgsubstate index e78583811..cba5bd3ad 100644 --- a/.hgsubstate +++ b/.hgsubstate @@ -1,8 +1,8 @@ -6766f8961c16fce20dd9f1cff2abbabc1d8913f3 src/Orchard.Web/Modules/Orchard.Autoroute +5e57314d12cb06337920ca140f80477a6e3f6d92 src/Orchard.Web/Modules/Orchard.Autoroute c54cb640d6bc14c51b9fb9bd78231bb0facec067 src/Orchard.Web/Modules/Orchard.Forms 204bdef384f41bb5e463bed6b98a056945a7d839 src/Orchard.Web/Modules/Orchard.Rules ce578373f907c0a55fd91229a344f0755f290174 src/Orchard.Web/Modules/Orchard.TaskLease -29a8e4e60bed53a91e109f85879ffd0a6df6ec2c src/Orchard.Web/Modules/Orchard.Tokens +c6a4d1a5603381cbfc1d694e9525f42fd5ecdb79 src/Orchard.Web/Modules/Orchard.Tokens 8375c8c10297aa9b66f792354bed25268184cd08 src/orchard.web/modules/Orchard.Alias 114e75928872042f092b0cc7cafa1a58c208d8ae src/orchard.web/modules/Orchard.Fields 913ced6d47a208394f8149d1573c2f2d61240d24 src/orchard.web/modules/orchard.Projections diff --git a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs index 7a85c05a8..9f96fdbd6 100644 --- a/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs +++ b/src/Orchard.Specs/Bindings/OrchardSiteFactory.cs @@ -71,7 +71,17 @@ namespace Orchard.Specs.Bindings { var contentTypeDefinition = new ContentTypeDefinition(name, name); cdm.StoreTypeDefinition(contentTypeDefinition); - cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("AutoroutePart").WithPart("ContainablePart").Creatable().Draftable()); + cdm.AlterTypeDefinition(name, cfg => cfg.WithPart("CommonPart").WithPart("BodyPart").WithPart("TitlePart").WithPart("ContainablePart").Creatable().Draftable()); + + cdm.AlterTypeDefinition(name, + cfg => cfg.WithPart("AutoroutePart", + builder => builder + .WithSetting("AutorouteSettings.AllowCustomPattern", "true") + .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false") + .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]") + .WithSetting("AutorouteSettings.DefaultPatternIndex", "0") + )); + } }); } diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Migrations.cs b/src/Orchard.Web/Modules/Orchard.Lists/Migrations.cs index 7699b7454..f8839b73d 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Migrations.cs +++ b/src/Orchard.Web/Modules/Orchard.Lists/Migrations.cs @@ -9,12 +9,21 @@ namespace Orchard.Lists { cfg=>cfg .WithPart("CommonPart") .WithPart("TitlePart") - .WithPart("AutoroutePart") .WithPart("ContainerPart") .WithPart("MenuPart") .WithPart("AdminMenuPart", p => p.WithSetting("AdminMenuPartTypeSettings.DefaultPosition", "2")) .Creatable()); + ContentDefinitionManager.AlterTypeDefinition("List", + cfg => cfg.WithPart("AutoroutePart", + builder => builder + .WithSetting("AutorouteSettings.AllowCustomPattern", "true") + .WithSetting("AutorouteSettings.AutomaticAdjustmentOnEdit", "false") + .WithSetting("AutorouteSettings.PatternDefinitions", "[{Name:'Title', Pattern: '{Content.Slug}', Description: 'my-list'}]") + .WithSetting("AutorouteSettings.DefaultPatternIndex", "0") + )); + + return 4; } diff --git a/src/Orchard.Web/Modules/Orchard.Lists/Module.txt b/src/Orchard.Web/Modules/Orchard.Lists/Module.txt index fee1d9aef..1fee375d0 100644 --- a/src/Orchard.Web/Modules/Orchard.Lists/Module.txt +++ b/src/Orchard.Web/Modules/Orchard.Lists/Module.txt @@ -6,5 +6,5 @@ Version: 1.3.0 OrchardVersion: 1.3.0 Description: Introduces a preconfigured container-enabled content type. FeatureDescription: A basic container-enabled content type. -Dependencies: Contents, Containers, Navigation +Dependencies: Contents, Containers, Navigation, Orchard.Autoroute Category: Content diff --git a/src/Orchard.Web/Modules/UpgradeTo14/Migrations.cs b/src/Orchard.Web/Modules/UpgradeTo14/Migrations.cs deleted file mode 100644 index b0553721a..000000000 --- a/src/Orchard.Web/Modules/UpgradeTo14/Migrations.cs +++ /dev/null @@ -1,131 +0,0 @@ -using System.Transactions; -using Orchard.Autoroute.Models; -using Orchard.Autoroute.Services; -using Orchard.ContentManagement; -using Orchard.ContentManagement.MetaData; -using Orchard.Core.Title.Models; -using Orchard.Data; -using Orchard.Data.Migration; -using Orchard.Environment.Configuration; - -namespace UpgradeTo14 { - public class UpdateTo14DataMigration : DataMigrationImpl { - private readonly IContentManager _contentManager; - private readonly IAutorouteService _autorouteService; - private readonly ISessionFactoryHolder _sessionFactoryHolder; - private readonly ShellSettings _shellSettings; - - public UpdateTo14DataMigration( - IContentManager contentManager, - IAutorouteService autorouteService, - ISessionFactoryHolder sessionFactoryHolder, - ShellSettings shellSettings) { - _contentManager = contentManager; - _autorouteService = autorouteService; - _sessionFactoryHolder = sessionFactoryHolder; - _shellSettings = shellSettings; - } - - public int Create() { - return 1; - - var sessionFactory = _sessionFactoryHolder.GetSessionFactory(); - var session = sessionFactory.OpenSession(); - - // migrating pages - ContentDefinitionManager.AlterTypeDefinition("Page", - builder => builder - .WithPart("AutoroutePart") - .WithPart("TitlePart")); - - var pages = _contentManager.HqlQuery().ForType("Page").List(); - - foreach(dynamic page in pages) { - var autoroutePart = ((ContentItem)page).As(); - var titlePart = ((ContentItem)page).As(); - - using (new TransactionScope(TransactionScopeOption.Suppress)) { - var command = session.Connection.CreateCommand(); - command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id); - var reader = command.ExecuteReader(); - reader.Read(); - var title = reader.GetString(0); - var path = reader.GetString(1); - reader.Close(); - - autoroutePart.DisplayAlias = path; - titlePart.Title = title; - } - - _autorouteService.PublishAlias(autoroutePart); - } - - ContentDefinitionManager.AlterTypeDefinition("Page", builder => builder.RemovePart("RoutePart")); - - // migrating blogs - ContentDefinitionManager.AlterTypeDefinition("Blog", builder => builder.WithPart("AutoroutePart").WithPart("TitlePart")); - var blogs = _contentManager.HqlQuery().ForType("Blog").List(); - - foreach (dynamic blog in blogs) { - var autoroutePart = ((ContentItem)blog).As(); - var titlePart = ((ContentItem)blog).As(); - - using (new TransactionScope(TransactionScopeOption.Suppress)) { - var command = session.Connection.CreateCommand(); - command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id); - var reader = command.ExecuteReader(); - reader.Read(); - var title = reader.GetString(0); - var path = reader.GetString(1); - reader.Close(); - - autoroutePart.DisplayAlias = path; - titlePart.Title = title; - } - - _autorouteService.PublishAlias(autoroutePart); - } - - // migrating blog posts - ContentDefinitionManager.AlterTypeDefinition("BlogPost", builder => builder.WithPart("AutoroutePart").WithPart("TitlePart")); - var blogposts = _contentManager.HqlQuery().ForType("BlogPost").List(); - - foreach (dynamic blogpost in blogposts) { - var autoroutePart = ((ContentItem)blogpost).As(); - var titlePart = ((ContentItem)blogpost).As(); - - using (new TransactionScope(TransactionScopeOption.Suppress)) { - var command = session.Connection.CreateCommand(); - command.CommandText = string.Format("SELECT Title, Path FROM {0} WHERE ContentItemRecord_Id = {1}", GetPrefixedTableName("Routable_RoutePartRecord"), autoroutePart.ContentItem.Id); - var reader = command.ExecuteReader(); - reader.Read(); - var title = reader.GetString(0); - var path = reader.GetString(1); - reader.Close(); - - autoroutePart.DisplayAlias = path; - titlePart.Title = title; - } - - _autorouteService.PublishAlias(autoroutePart); - } - - // migrating containers/list - // todo - - _autorouteService.CreatePattern("Page", "Title", "{Content.Slug}", "about-us", true); - _autorouteService.CreatePattern("Blog", "Title", "{Content.Slug}", "my-blog", true); - _autorouteService.CreatePattern("BlogPost", "Blog and Title", "{Content.Container.Path}/{Content.Slug}", "my-blog/a-blog-post", true); - - return 1; - } - - private string GetPrefixedTableName(string tableName) { - if(string.IsNullOrWhiteSpace(_shellSettings.DataTablePrefix)) { - return tableName; - } - - return _shellSettings.DataTablePrefix + "_" + tableName; - } - } -} \ No newline at end of file diff --git a/src/Orchard.Web/Modules/UpgradeTo14/UpgradeTo14.csproj b/src/Orchard.Web/Modules/UpgradeTo14/UpgradeTo14.csproj index beddb8d55..526d22586 100644 --- a/src/Orchard.Web/Modules/UpgradeTo14/UpgradeTo14.csproj +++ b/src/Orchard.Web/Modules/UpgradeTo14/UpgradeTo14.csproj @@ -90,7 +90,6 @@ -