Permissions & Authorization for Users #24

Initial Release; Includes Database and MVC refactoring
This commit is contained in:
Gary Sharp
2013-10-10 19:13:16 +11:00
parent 172ce5524a
commit a099d68915
458 changed files with 40221 additions and 12130 deletions
@@ -0,0 +1,13 @@
using Disco.Models.UI.Config.AuthorizationRole;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Disco.Web.Areas.Config.Models.AuthorizationRole
{
public class CreateModel : ConfigAuthorizationRoleCreateModel
{
public Disco.Models.Repository.AuthorizationRole AuthorizationRole { get; set; }
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.Data.Repository;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Models.Authorization;
namespace Disco.Web.Areas.Config.Models.AuthorizationRole
{
public class IndexModel : ConfigAuthorizationRoleIndexModel
{
public List<IRoleToken> Tokens { get; set; }
}
}
@@ -0,0 +1,54 @@
using Disco.Models.Authorization;
using Disco.Models.Interop.ActiveDirectory;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Web.Models.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Disco.Web.Areas.Config.Models.AuthorizationRole
{
public class ShowModel : ConfigAuthorizationRoleShowModel
{
public IRoleToken Token { get; set; }
public List<SubjectDescriptor> Subjects { get; set; }
public IClaimNavigatorItem ClaimNavigator { get; set; }
public FancyTreeNode[] ClaimNavigatorFancyTreeNodes
{
get
{
var rootNode = FancyTreeNode.FromClaimNavigatorItem(this.ClaimNavigator, false);
rootNode.expanded = true;
return new FancyTreeNode[] {
rootNode
};
}
}
public class SubjectDescriptor
{
public bool IsGroup { get; set; }
public string Name { get; set; }
public string Id { get; set; }
public static SubjectDescriptor FromActiveDirectoryObject(IActiveDirectoryObject ADObject)
{
var item = new SubjectDescriptor()
{
Id = ADObject.SamAccountName,
Name = ADObject.Name
};
if (ADObject is ActiveDirectoryGroup)
item.IsGroup = true;
return item;
}
}
}
}
@@ -11,10 +11,10 @@ namespace Disco.Web.Areas.Config.Models.DeviceBatch
{
public List<ConfigDeviceBatchIndexModelItem> DeviceBatches { get; set; }
public static IndexModel Build(DiscoDataContext dbContext)
public static IndexModel Build(DiscoDataContext Database)
{
var m = new IndexModel();
m.DeviceBatches = dbContext.DeviceBatches.OrderBy(db => db.Name).Select(db => new _IndexModelItem()
m.DeviceBatches = Database.DeviceBatches.OrderBy(db => db.Name).Select(db => new _IndexModelItem()
{
Id = db.Id,
Name = db.Name,
@@ -28,6 +28,9 @@ namespace Disco.Web.Areas.Config.Models.DeviceBatch
InsuredUntil = db.InsuredUntil
}).ToArray().Cast<ConfigDeviceBatchIndexModelItem>().ToList();
foreach (var item in m.DeviceBatches.Where(db => db.DefaultDeviceModel == null))
item.DefaultDeviceModel = "<None Specified>";
return m;
}
@@ -10,6 +10,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceBatch
public class ShowModel : ConfigDeviceBatchShowModel
{
public Disco.Models.Repository.DeviceBatch DeviceBatch { get; set; }
public Disco.Models.Repository.DeviceModel DefaultDeviceModel { get; set; }
public List<Disco.Models.Repository.DeviceModel> DeviceModels { get; set; }
public List<ConfigDeviceBatchShowModelMembership> DeviceModelMembers { get; set; }
public int DeviceCount { get; set; }
@@ -11,10 +11,10 @@ namespace Disco.Web.Areas.Config.Models.DeviceModel
{
public List<ConfigDeviceModelIndexModelItem> DeviceModels { get; set; }
public static IndexModel Build(DiscoDataContext dbContext)
public static IndexModel Build(DiscoDataContext Database)
{
var m = new IndexModel();
m.DeviceModels = dbContext.DeviceModels.OrderBy(dm => dm.Description).Select(dm => new _IndexModelItem()
m.DeviceModels = Database.DeviceModels.OrderBy(dm => dm.Description).Select(dm => new _IndexModelItem()
{
Id = dm.Id,
Name = dm.Description,
@@ -12,10 +12,10 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile
{
public List<ConfigDeviceProfileIndexModelItem> DeviceProfiles { get; set; }
public static IndexModel Build(DiscoDataContext dbContext)
public static IndexModel Build(DiscoDataContext Database)
{
var m = new IndexModel();
m.DeviceProfiles = dbContext.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new _IndexModelItem()
m.DeviceProfiles = Database.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new _IndexModelItem()
{
Id = dp.Id,
Name = dp.Name,
@@ -31,7 +31,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile
{
foreach (var dp in m.DeviceProfiles)
if (dp.Address.HasValue)
dp.AddressName = dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(dp.Address.Value).Name;
dp.AddressName = Database.DiscoConfiguration.OrganisationAddresses.GetAddress(dp.Address.Value).Name;
}
return m;
@@ -12,6 +12,7 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile
{
public Disco.Models.Repository.DeviceProfile DeviceProfile { get; set; }
public List<SelectListItem> DeviceProfileDistributionTypes { get; set; }
public Disco.Models.BI.Config.OrganisationAddress DefaultOrganisationAddress { get; set; }
public List<Disco.Models.BI.Config.OrganisationAddress> OrganisationAddresses { get; set; }
public List<PluginFeatureManifest> CertificateProviders { get; set; }
@@ -55,12 +55,12 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
}
}
public void UpdateModel(DiscoDataContext dbContext)
public void UpdateModel(DiscoDataContext Database)
{
if (this.JobTypes == null)
JobTypes = dbContext.JobTypes.ToList();
JobTypes = Database.JobTypes.ToList();
if (this.JobSubTypes == null)
JobSubTypes = dbContext.JobSubTypes.ToList();
JobSubTypes = Database.JobSubTypes.ToList();
}
}
@@ -36,26 +36,26 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
}
}
public void UpdateModel(DiscoDataContext dbContext)
public void UpdateModel(DiscoDataContext Database)
{
switch (this.DocumentTemplate.Scope)
{
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Device:
this.StoredInstanceCount = dbContext.DeviceAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
this.StoredInstanceCount = Database.DeviceAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
break;
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job:
this.StoredInstanceCount = dbContext.JobAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
this.StoredInstanceCount = Database.JobAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
break;
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.User:
this.StoredInstanceCount = dbContext.UserAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
this.StoredInstanceCount = Database.UserAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
break;
}
if (this.JobTypes == null)
JobTypes = dbContext.JobTypes.ToList();
JobTypes = Database.JobTypes.ToList();
if (this.JobSubTypes == null)
JobSubTypes = dbContext.JobSubTypes.ToList();
JobSubTypes = Database.JobSubTypes.ToList();
if (DocumentTemplate != null)
{
@@ -102,9 +102,9 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
};
}
public void ToConfiguration(DiscoDataContext db)
public void ToConfiguration(DiscoDataContext Database)
{
SystemConfiguration config = db.DiscoConfiguration;
SystemConfiguration config = Database.DiscoConfiguration;
//config.DataStoreLocation = DataStoreLocation;
config.ProxyAddress = ProxyAddress;
config.ProxyPort = ProxyPort;
@@ -112,11 +112,11 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
config.ProxyPassword = ProxyPassword;
DiscoApplication.SetGlobalProxy(ProxyAddress, ProxyPort, ProxyUsername, ProxyPassword);
db.SaveChanges();
Database.SaveChanges();
// Try and check for updates if needed - After Proxy Changed
if (db.DiscoConfiguration.UpdateLastCheck == null
|| db.DiscoConfiguration.UpdateLastCheck.ResponseTimestamp < DateTime.Now.AddDays(-1))
if (Database.DiscoConfiguration.UpdateLastCheck == null
|| Database.DiscoConfiguration.UpdateLastCheck.ResponseTimestamp < DateTime.Now.AddDays(-1))
{
Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow();
}