mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
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:
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
@@ -39,6 +44,10 @@ namespace Orchard.Core.Contents.Controllers {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 }));
|
||||
}
|
||||
|
||||
@@ -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[] { }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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}",
|
||||
var result = String.Format("{0}://{1}",
|
||||
urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
|
||||
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
|
||||
? tenantShellSettings.RequestUrlHost + port : host);
|
||||
!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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user