Job Expressions
Expressions can be triggered when jobs are created and closed
This commit is contained in:
@@ -1684,7 +1684,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
if (j.CanCloseForced())
|
||||
{
|
||||
j.OnCloseForced(Database, CurrentUser, Reason);
|
||||
j.OnCloseForced(Database, Database.Users.Find(CurrentUser.UserId), Reason);
|
||||
|
||||
Database.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
@@ -1709,7 +1709,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
if (j.CanCloseNormally())
|
||||
{
|
||||
j.OnCloseNormally(CurrentUser);
|
||||
j.OnCloseNormally(Database, Database.Users.Find(CurrentUser.UserId));
|
||||
|
||||
Database.SaveChanges();
|
||||
if (redirect)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Disco.Models.Services.Job;
|
||||
using Disco.Services.Authorization;
|
||||
using Disco.Services.Jobs;
|
||||
using Disco.Services.Web;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -117,5 +118,53 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.JobPreferences.Configure)]
|
||||
public virtual ActionResult UpdateOnCreateExpression(string OnCreateExpression, bool redirect = false)
|
||||
{
|
||||
string expression = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(OnCreateExpression))
|
||||
{
|
||||
expression = OnCreateExpression.Trim();
|
||||
}
|
||||
|
||||
if (Database.DiscoConfiguration.JobPreferences.OnCreateExpression != expression)
|
||||
{
|
||||
Database.DiscoConfiguration.JobPreferences.OnCreateExpression = expression;
|
||||
Database.SaveChanges();
|
||||
|
||||
Jobs.OnCreateExpressionInvalidateCache();
|
||||
}
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.JobPreferences.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
[DiscoAuthorize(Claims.Config.JobPreferences.Configure)]
|
||||
public virtual ActionResult UpdateOnCloseExpression(string OnCloseExpression, bool redirect = false)
|
||||
{
|
||||
string expression = null;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(OnCloseExpression))
|
||||
{
|
||||
expression = OnCloseExpression.Trim();
|
||||
}
|
||||
|
||||
if (Database.DiscoConfiguration.JobPreferences.OnCloseExpression != expression)
|
||||
{
|
||||
Database.DiscoConfiguration.JobPreferences.OnCloseExpression = expression;
|
||||
Database.SaveChanges();
|
||||
|
||||
Jobs.OnCloseExpressionInvalidateCache();
|
||||
}
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.JobPreferences.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -219,7 +219,7 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
|
||||
if (CloseJob.HasValue && CloseJob.Value && job.CanCloseNormally())
|
||||
{
|
||||
job.OnCloseNormally(CurrentUser);
|
||||
job.OnCloseNormally(Database, Database.Users.Find(CurrentUser.UserId));
|
||||
Database.SaveChanges();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user