Update: Auth Claims Refinement, Job Creation

Auth Claims for Job Creation types, user details.
This commit is contained in:
Gary Sharp
2014-02-04 17:41:00 +11:00
parent eea71e6eb0
commit 7748f15d76
39 changed files with 1296 additions and 899 deletions
+10 -8
View File
@@ -1,10 +1,12 @@
using System;
using Disco.BI.Extensions;
using Disco.Data.Repository;
using Disco.Models.UI.Job;
using Disco.Services.Authorization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Disco.Data.Repository;
using Disco.Models.UI.Job;
namespace Disco.Web.Models.Job
{
@@ -25,7 +27,7 @@ namespace Disco.Web.Models.Job
[Required(ErrorMessage = "Please specify whether the device is held or not")]
public bool? DeviceHeld { get; set; }
public string QuickLogDestinationUrl { get; set; }
public string SourceUrl { get; set; }
[Display(Description = "Automatically close this job")]
public bool? QuickLog { get; set; }
@@ -38,10 +40,10 @@ namespace Disco.Web.Models.Job
public Disco.Models.Repository.User User { get; set; }
public List<Disco.Models.Repository.JobType> JobTypes { get; set; }
public void UpdateModel(DiscoDataContext Database)
public void UpdateModel(DiscoDataContext Database, AuthorizationToken Authorization)
{
if (this.JobTypes == null)
JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").ToList();
this.JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").FilterCreatableTypePermissions(Authorization).ToList();
if (!string.IsNullOrEmpty(DeviceSerialNumber))
{
@@ -55,7 +57,7 @@ namespace Disco.Web.Models.Job
this.UserId = this.Device.AssignedUserId;
}
if (string.IsNullOrEmpty(this.Type))
this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar).Id;
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar) ? Disco.Models.Repository.JobType.JobTypeIds.HWar : this.JobTypes.First().Id;
if (string.IsNullOrEmpty(this.UserId))
{
@@ -93,7 +95,7 @@ namespace Disco.Web.Models.Job
// Set Default Job Type for Users
if (string.IsNullOrEmpty(this.Type))
this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp).Id;
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp) ? Disco.Models.Repository.JobType.JobTypeIds.SApp : this.JobTypes.First().Id;
}
if (!string.IsNullOrEmpty(UserId))
{