Merge branch 'dev' into feature/recipesteps

Conflicts:
	src/Orchard.Tests.Modules/Recipes/Services/RecipeManagerTests.cs
	src/Orchard.Web/Modules/Orchard.ImportExport/Controllers/AdminController.cs
This commit is contained in:
Sipke Schoorstra
2015-07-16 19:21:12 +01:00
9 changed files with 67 additions and 33 deletions

View File

@@ -19,7 +19,9 @@ using Orchard.Recipes.Services;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Recipes.Events;
using Orchard.Tests.ContentManagement;
using Orchard.Data;
using System;
using System.Linq.Expressions;
namespace Orchard.Tests.Modules.Recipes.Services {
[TestFixture]
@@ -100,9 +102,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
builder.RegisterType<RecipeParser>().As<IRecipeParser>();
builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>();
builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new StubRecipeStepResultRecordRepository()).As<IRepository<RecipeStepResultRecord>>();
_container = builder.Build();
_recipeManager = _container.Resolve<IRecipeManager>();
@@ -117,7 +117,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test]
public void HarvestRecipesFailsToFindRecipesWhenCalledWithNotExistingExtension() {
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("cantfindme");
var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("cantfindme");
Assert.That(recipes.Count, Is.EqualTo(0));
}
@@ -130,7 +130,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test]
public void ParseRecipeLoadsRecipeMetaDataIntoModel() {
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("Sample1");
var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("Sample1");
Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0];
@@ -149,7 +149,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0];
var recipeSteps = (List<RecipeStep>) sampleRecipe.RecipeSteps;
var recipeSteps = (List<RecipeStep>)sampleRecipe.RecipeSteps;
Assert.That(recipeSteps.Count, Is.EqualTo(9));
}
@@ -183,6 +183,22 @@ namespace Orchard.Tests.Modules.Recipes.Services {
}
}
public class StubRecipeStepResultRecordRepository : IRepository<RecipeStepResultRecord> {
private List<RecipeStepResultRecord> _records = new List<RecipeStepResultRecord>();
public IQueryable<RecipeStepResultRecord> Table { get { return _records.AsQueryable(); } }
public void Copy(RecipeStepResultRecord source, RecipeStepResultRecord target) { }
public int Count(Expression<Func<RecipeStepResultRecord, bool>> predicate) { return _records.Count; }
public void Create(RecipeStepResultRecord entity) { _records.Add(entity); }
public void Delete(RecipeStepResultRecord entity) { _records.Remove(entity); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order, int skip, int count) { throw new NotImplementedException(); }
public void Flush() { }
public RecipeStepResultRecord Get(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public RecipeStepResultRecord Get(int id) { throw new NotImplementedException(); }
public void Update(RecipeStepResultRecord entity) { }
}
public class StubRecipeScheduler : IRecipeScheduler {
private readonly IRecipeStepExecutor _recipeStepExecutor;
@@ -197,7 +213,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
public class CustomRecipeHandler : IRecipeHandler {
public static string AttributeValue;
public string[] _handles = {"Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings"};
public string[] _handles = { "Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings" };
public void ExecuteRecipeStep(RecipeContext recipeContext) {
if (_handles.Contains(recipeContext.RecipeStep.Name)) {

View File

@@ -9,9 +9,14 @@ namespace Orchard.Core.Contents.Controllers {
[Themed]
public class ItemController : Controller {
private readonly IContentManager _contentManager;
private readonly IHttpContextAccessor _hca;
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory, IOrchardServices services) {
public ItemController(IContentManager contentManager,
IShapeFactory shapeFactory,
IOrchardServices services,
IHttpContextAccessor hca) {
_contentManager = contentManager;
_hca = hca;
Shape = shapeFactory;
Services = services;
T = NullLocalizer.Instance;
@@ -37,8 +42,12 @@ namespace Orchard.Core.Contents.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ViewContent, contentItem, T("Cannot view content"))) {
return new HttpUnauthorizedResult();
}
var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this,model);
}
return View(model);
}
@@ -62,6 +71,10 @@ namespace Orchard.Core.Contents.Controllers {
}
var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this, model);
}
return View(model);
}
}

View File

@@ -52,9 +52,6 @@ namespace Orchard.ImportExport.Controllers {
if (!Services.Authorizer.Authorize(Permissions.Import, T("Not allowed to import.")))
return new HttpUnauthorizedResult();
// Sets the request timeout to 10 minutes to give enough time to execute custom recipes.
Services.WorkContext.HttpContext.Server.ScriptTimeout = 600;
var actions = _importActions.OrderByDescending(x => x.Priority).ToList();
var viewModel = new ImportViewModel {
Actions = actions.Select(x => new ImportActionViewModel {

View File

@@ -132,6 +132,9 @@ namespace Orchard.ImportExport.Providers.ImportActions {
if (RecipeDocument == null)
return;
// Sets the request timeout to 10 minutes to give enough time to execute custom recipes.
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = 600;
var executionId = ResetSite ? Setup() : ExecuteRecipe();
context.ActionResult = new RedirectToRouteResult(new RouteValueDictionary(new { action = "ImportResult", controller = "Admin", area = "Orchard.ImportExport", executionId = executionId }));
}

View File

@@ -112,8 +112,8 @@ namespace Orchard.MultiTenancy.Commands {
DataTablePrefix = DataTablePrefix,
RequestUrlHost = UrlHost,
RequestUrlPrefix = UrlPrefix,
Themes = Themes.Split(';'),
Modules = Modules.Split(';')
Themes = Themes != null ? Themes.Split(';') : new string[] { },
Modules = Modules != null ? Modules.Split(';') : new string[] { }
});
}

View File

@@ -1,26 +1,30 @@
using System.Web.Mvc;
using System;
using System.Linq;
using System.Web.Mvc;
using Orchard.Environment.Configuration;
namespace Orchard.MultiTenancy.Extensions {
public static class UrlHelperExtensions {
public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
var requestUrlHost = tenantShellSettings.RequestUrlHost.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).First();
//info: (heskew) might not keep the port/vdir insertion around beyond...
var port = string.Empty;
string host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
var host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
if (host.Contains(":"))
port = host.Substring(host.IndexOf(":"));
var result = string.Format("{0}://{1}",
urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
? tenantShellSettings.RequestUrlHost + port : host);
var result = String.Format("{0}://{1}",
urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
!String.IsNullOrEmpty(requestUrlHost) ? requestUrlHost + port : host);
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
if (!string.IsNullOrEmpty(applicationPath) && !string.Equals(applicationPath, "/"))
if (!String.IsNullOrEmpty(applicationPath) && applicationPath != "/")
result += applicationPath;
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
if (!String.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
result += "/" + tenantShellSettings.RequestUrlPrefix;
return result;

View File

@@ -24,14 +24,15 @@ namespace Orchard.MultiTenancy.Services {
/// <summary>
/// Resets a tenant to its uninitialized state.
/// </summary>
/// <param name="tenantName">A ShellSettings object for the tenant to reset.</param>
/// <param name="settings">A ShellSettings object to identify the tenant to reset.</param>
/// <param name="dropDatabaseTables">A boolean indicated whether tenant database tables should be dropped also.</param>
void ResetTenant(ShellSettings settings, bool dropDatabaseTables);
/// <summary>
/// Returns a list of all known database tables in a tenant.
/// </summary>
/// <returns>A ShellSettings object for the tenant.</returns>
/// <param name="settings">A ShellSettings object to identify the tenant.</param>
/// <returns>A list of known database table names for the tenant.</returns>
IEnumerable<string> GetTenantDatabaseTableNames(ShellSettings settings);
/// <summary>

View File

@@ -5,7 +5,7 @@
Layout.Title = T("Edit Tenant").ToString();
Script.Require("jQuery").AtFoot();
Script.Include(Url.Content("~/Themes/TheAdmin/Scripts/admin.js")).AtFoot();
Script.Include(Url.Content("~/Themes/TheAdmin/Scripts/admin.js")).AtFoot();
Script.Include("multi-tenancy.admin.js").AtFoot();
}
@@ -16,9 +16,9 @@
<h2>@Model.Name</h2>
</div>
<div>
<label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("Host")</label>
<label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("URL host")</label>
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "text medium" })
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\". Multiple hosts can be separated by a comma.")</span>
</div>
<div>
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>
@@ -56,8 +56,8 @@
</div>
</fieldset>
<fieldset class="available-extensions">
<label for="@Html.FieldIdFor(m => m.Themes)">@T("Available Themes")</label>
<fieldset class="available-extensions">
<label for="@Html.FieldIdFor(m => m.Themes)">@T("Available Themes")</label>
<div>
<span class="hint">@T("Select the Themes which should be available for this tenant. If none is selected, they will all be available.")</span>
@@ -83,8 +83,8 @@
</div>
</fieldset>
<fieldset class="available-extensions">
<label for="@Html.FieldIdFor(m => m.Modules)">@T("Available Modules")</label>
<fieldset class="available-extensions">
<label for="@Html.FieldIdFor(m => m.Modules)">@T("Available Modules")</label>
<div>
<span class="hint">@T("Select the Modules which should be available for this tenant. If none is selected, they will all be available.")</span>

View File

@@ -71,7 +71,7 @@ namespace Orchard.Setup.Controllers {
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model) {
// sets the setup request timeout to 10 minutes to give enough time to execute custom recipes.
// sets the setup request timeout to 10 minutes to give enough time to execute custom recipes.
HttpContext.Server.ScriptTimeout = 600;
var recipes = OrderRecipes(_setupService.Recipes());