Create Organization complete
This commit is contained in:
@@ -221,7 +221,15 @@ namespace Swarmops.Basic.Enums
|
||||
/// <summary>
|
||||
/// A National ID number, if any. Like US SSN.
|
||||
/// </summary>
|
||||
NationalIdNumber
|
||||
NationalIdNumber,
|
||||
/// <summary>
|
||||
/// What are ordinary people called in this org?
|
||||
/// </summary>
|
||||
OrgRegularLabel,
|
||||
/// <summary>
|
||||
/// What are activists called in this org?
|
||||
/// </summary>
|
||||
OrgActivistLabel
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -905,5 +905,37 @@ namespace Swarmops.Logic.Structure
|
||||
}
|
||||
}
|
||||
|
||||
public string RegularLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionalData = OptionalData[ObjectOptionalDataType.OrgRegularLabel];
|
||||
if (string.IsNullOrEmpty(optionalData))
|
||||
{
|
||||
this.RegularLabel = "Member";
|
||||
return "Member"; // Legacy
|
||||
}
|
||||
|
||||
return optionalData;
|
||||
}
|
||||
set { OptionalData[ObjectOptionalDataType.OrgRegularLabel] = value; }
|
||||
}
|
||||
|
||||
public string ActivistLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
string optionalData = OptionalData[ObjectOptionalDataType.OrgActivistLabel];
|
||||
if (string.IsNullOrEmpty(optionalData))
|
||||
{
|
||||
this.ActivistLabel = "Activist";
|
||||
return "Activist";
|
||||
}
|
||||
|
||||
return optionalData;
|
||||
}
|
||||
set { OptionalData[ObjectOptionalDataType.OrgActivistLabel] = value; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -146,4 +146,8 @@
|
||||
<value>Regular people will be called</value>
|
||||
<comment>This can be "members", etc.</comment>
|
||||
</data>
|
||||
<data name="CreateOrganization_Success" xml:space="preserve">
|
||||
<value>The new organization has been created. You have been given an initial two-year {0} in the organization, so you can work with it and set it up properly. To switch to working with your new organization, use the control panel top right.</value>
|
||||
<comment>The {0} is membership, employment, citizenship, residence, etc.</comment>
|
||||
</data>
|
||||
</root>
|
||||
@@ -13,20 +13,7 @@
|
||||
$('#<%=this.DropCreateChild.ClientID %>').combobox({
|
||||
editable: false,
|
||||
height: 30,
|
||||
width: 300,
|
||||
textField: 'label',
|
||||
valueField: 'id',
|
||||
data: [{
|
||||
'label': "<%= Resources.Global.Global_SelectOne %>",
|
||||
'id': '0'
|
||||
}, {
|
||||
'label': "<%= Resources.Pages.Admin.CreateOrganization_AsRoot%>",
|
||||
'id': 'Root'
|
||||
}, {
|
||||
'label': "<%= String.Format(Resources.Pages.Admin.CreateOrganization_ChildOfX, this.CurrentOrganization.Name)%>",
|
||||
'id': 'Child'
|
||||
}]
|
||||
|
||||
width: 300
|
||||
});
|
||||
|
||||
$('#<%=this.DropCurrencies.ClientID%>').combobox({
|
||||
|
||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using Swarmops.Logic.Financial;
|
||||
using Swarmops.Logic.Structure;
|
||||
using Swarmops.Logic.Swarm;
|
||||
|
||||
namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
{
|
||||
@@ -48,6 +50,9 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
this.DropCreateChild.Items.Add(new ListItem(Resources.Global.Global_SelectOne, "0"));
|
||||
|
||||
|
||||
this.DropCreateChild.Items.Add(new ListItem(Resources.Pages.Admin.CreateOrganization_AsRoot, "Root"));
|
||||
this.DropCreateChild.Items.Add(new ListItem(String.Format(Resources.Pages.Admin.CreateOrganization_ChildOfX, CurrentOrganization.Name), "Child"));
|
||||
|
||||
List<string> localizedPersonLabels = new List<string>();
|
||||
|
||||
foreach (string personLabel in _personLabels)
|
||||
@@ -89,7 +94,40 @@ namespace Swarmops.Frontend.Pages.v5.Admin
|
||||
|
||||
protected void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
string successMessage = string.Empty;
|
||||
string activistLabel = this.DropActivistLabel.SelectedValue;
|
||||
string peopleLabel = this.DropPersonLabel.SelectedValue;
|
||||
string asRoot = this.DropCreateChild.SelectedValue;
|
||||
string currencyCode = this.DropCurrencies.SelectedValue;
|
||||
string newOrgName = this.TextOrganizationName.Text;
|
||||
|
||||
if (string.IsNullOrEmpty(newOrgName))
|
||||
{
|
||||
throw new ArgumentException("Organization name can't be empty");
|
||||
}
|
||||
|
||||
if (activistLabel == "0" || peopleLabel == "0" || asRoot == "0" || currencyCode == "0")
|
||||
{
|
||||
throw new ArgumentException("Necessary argument was not supplied (did client-side validation run?)");
|
||||
}
|
||||
|
||||
Currency newOrgCurrency = Currency.FromCode(currencyCode);
|
||||
Organization parent = CurrentOrganization;
|
||||
|
||||
if (asRoot == "Root")
|
||||
{
|
||||
parent = null;
|
||||
}
|
||||
|
||||
Organization newOrganization = Organization.Create(parent == null ? 0 : parent.Identity, newOrgName,
|
||||
newOrgName, newOrgName, string.Empty, newOrgName, 0, true, true, 0);
|
||||
newOrganization.EnableEconomy(newOrgCurrency);
|
||||
|
||||
newOrganization.RegularLabel = peopleLabel;
|
||||
newOrganization.ActivistLabel = activistLabel;
|
||||
|
||||
Membership.Create(CurrentUser, newOrganization, DateTime.UtcNow.AddYears(2));
|
||||
|
||||
string successMessage = String.Format(Resources.Pages.Admin.CreateOrganization_Success, Resources.Global.ResourceManager.GetString(peopleLabel));
|
||||
|
||||
// Create org here
|
||||
|
||||
|
||||
Reference in New Issue
Block a user