mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -63,7 +63,7 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod2() {
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethod() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
@@ -74,7 +74,7 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod4() {
|
||||
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
@@ -86,7 +86,17 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod5() {
|
||||
public void EventParametersAreCorrectlyPassedToBestMatchingMethodAndExtraParametersAreIgnored2() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["e"] = 1;
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(3000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
@@ -96,7 +106,7 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod6() {
|
||||
public void EventParametersAreCorrectlyPassedToExactlyMatchingMethodWhenThereIsOne2() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
@@ -105,17 +115,7 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod7() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["a"] = 1000;
|
||||
arguments["e"] = 1;
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(3000));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod8() {
|
||||
public void EventHandlerWontBeCalledWhenNoParameterMatchExists() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
arguments["e"] = 1;
|
||||
@@ -124,7 +124,7 @@ namespace Orchard.Tests.Events {
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EventParametersAreCorrectlyPassedToMatchingMethod9() {
|
||||
public void EventHandlerWontBeCalledWhenNoParameterMatchExists2() {
|
||||
Assert.That(_eventHandler.Result, Is.EqualTo(0));
|
||||
Dictionary<string, object> arguments = new Dictionary<string, object>();
|
||||
_eventBus.Notify("ITestEventHandler.Sum", arguments);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Localization;
|
||||
@@ -10,9 +11,11 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
[ValidateInput(false)]
|
||||
public class AdminController : Controller {
|
||||
private readonly ITenantService _tenantService;
|
||||
private readonly ShellSettings _thisShellSettings;
|
||||
|
||||
public AdminController(ITenantService tenantService, IOrchardServices orchardServices) {
|
||||
public AdminController(ITenantService tenantService, IOrchardServices orchardServices, ShellSettings shellSettings) {
|
||||
_tenantService = tenantService;
|
||||
_thisShellSettings = shellSettings;
|
||||
Services = orchardServices;
|
||||
T = NullLocalizer.Instance;
|
||||
}
|
||||
@@ -51,5 +54,35 @@ namespace Orchard.MultiTenancy.Controllers {
|
||||
return View(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Disable(ShellSettings shellSettings) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't disable tenant")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == shellSettings.Name);
|
||||
|
||||
if (tenant != null && tenant.Name != _thisShellSettings.Name) {
|
||||
tenant.State.CurrentState = TenantState.State.Disabled;
|
||||
_tenantService.UpdateTenant(tenant);
|
||||
}
|
||||
|
||||
return RedirectToAction("index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ActionResult Enable(ShellSettings shellSettings) {
|
||||
if (!Services.Authorizer.Authorize(Permissions.ManageTenants, T("Couldn't enable tenant")))
|
||||
return new HttpUnauthorizedResult();
|
||||
|
||||
var tenant = _tenantService.GetTenants().FirstOrDefault(ss => ss.Name == shellSettings.Name);
|
||||
|
||||
if (tenant != null && tenant.Name != _thisShellSettings.Name) {
|
||||
tenant.State.CurrentState = TenantState.State.Running;
|
||||
_tenantService.UpdateTenant(tenant);
|
||||
}
|
||||
|
||||
return RedirectToAction("index");
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,5 +5,6 @@ namespace Orchard.MultiTenancy.Services {
|
||||
public interface ITenantService : IDependency {
|
||||
IEnumerable<ShellSettings> GetTenants();
|
||||
void CreateTenant(ShellSettings settings);
|
||||
void UpdateTenant(ShellSettings settings);
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Orchard.Environment;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
@@ -19,5 +20,11 @@ namespace Orchard.MultiTenancy.Services {
|
||||
public void CreateTenant(ShellSettings settings) {
|
||||
_shellSettingsManager.SaveSettings(settings);
|
||||
}
|
||||
|
||||
public void UpdateTenant(ShellSettings settings) {
|
||||
var tenant = GetTenants().FirstOrDefault(ss => ss.Name == settings.Name);
|
||||
if (tenant != null)
|
||||
_shellSettingsManager.SaveSettings(settings);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,3 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShellSettings>" %>
|
||||
<%@ Import Namespace="Orchard.Environment.Configuration" %>
|
||||
<%=Html.ActionLink(T("Resume").ToString(), "_enable", new {tenantName = Model.Name, area = "Orchard.MultiTenancy"}) %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<% using(Html.BeginFormAntiForgeryPost(Url.Action("enable", new {tenantName = Model.Name, area = "Orchard.MultiTenancy"}), FormMethod.Post, new {@class = "inline link"})) { %>
|
||||
<%=Html.HiddenFor(ss => ss.Name) %>
|
||||
<button type="submit"><%=_Encoded("Resume")%></button><%
|
||||
} %>
|
@@ -1,3 +1,7 @@
|
||||
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<ShellSettings>" %>
|
||||
<%@ Import Namespace="Orchard.Environment.Configuration" %>
|
||||
<%=Html.ActionLink(T("Suspend").ToString(), "_disable", new {tenantName = Model.Name, area = "Orchard.MultiTenancy"}) %>
|
||||
<%@ Import Namespace="Orchard.Mvc.Html" %>
|
||||
<% using(Html.BeginFormAntiForgeryPost(Url.Action("disable", new {area = "Orchard.MultiTenancy"}), FormMethod.Post, new {@class = "inline link"})) { %>
|
||||
<%=Html.HiddenFor(ss => ss.Name) %>
|
||||
<button type="submit"><%=_Encoded("Suspend") %></button><%
|
||||
} %>
|
@@ -18,12 +18,12 @@
|
||||
<div class="related"><%
|
||||
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
||||
var t = tenant; %>
|
||||
<%=Html.DisplayFor(m => t, string.Format("ActionsFor{0}", tenant.State.CurrentState)) %><%=_Encoded(" | ")%><%
|
||||
<%=Html.DisplayFor(m => t, string.Format("ActionsFor{0}", tenant.State.CurrentState), "") %><%=_Encoded(" | ")%><%
|
||||
} %>
|
||||
<%=Html.ActionLink(T("Edit").ToString(), "edit", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
|
||||
<%=Html.ActionLink(T("Edit").ToString(), "edit", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}, new {@class = "button"}) %><%
|
||||
if (!string.Equals(tenant.Name, "default", StringComparison.OrdinalIgnoreCase)) { //todo: (heskew) base this off the view model so logic on what can be removed and have its state changed stays in the controller
|
||||
%><%=_Encoded(" | ")%>
|
||||
<%=Html.ActionLink(T("Remove").ToString(), "delete", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}) %><%
|
||||
<%=Html.ActionLink(T("Remove").ToString(), "delete", new {tenantName = tenant.Name, area = "Orchard.MultiTenancy"}, new {@class = "button"}) %><%
|
||||
} %>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -167,7 +167,6 @@ a:hover, a:active, a:focus {
|
||||
text-decoration:underline;
|
||||
}
|
||||
|
||||
|
||||
/* Header - Branding and Login
|
||||
----------------------------------------------------------*/
|
||||
#header {
|
||||
@@ -469,6 +468,9 @@ button, .button, .button:link, .button:visited {
|
||||
text-align:center;
|
||||
padding:0 .8em .1em .8em;
|
||||
}
|
||||
button {
|
||||
padding-top:.08em;
|
||||
}
|
||||
.primaryAction, .primaryAction:link, .primaryAction:visited {
|
||||
background:#4687ad;
|
||||
border:1px solid #8f8f8f;
|
||||
@@ -786,6 +788,11 @@ table.items, textarea, input.text, input.text-box,
|
||||
float:right;
|
||||
text-align:right;
|
||||
}
|
||||
/*todo: (heskew) cleanup */
|
||||
.related .button {
|
||||
font-size:1em;
|
||||
}
|
||||
/*end todo*/
|
||||
.commentcount {
|
||||
line-height:2em;
|
||||
}
|
||||
|
Reference in New Issue
Block a user