Feature #69 #72: Noticeboard themes and filtering

This commit is contained in:
Gary Sharp
2014-08-26 16:27:37 +10:00
parent 0de162fce3
commit 4b6604df5b
30 changed files with 2491 additions and 383 deletions
@@ -1,5 +1,8 @@
using Disco.Services.Jobs.Noticeboards;
using Disco.Models.Repository;
using Disco.Services.Jobs.Noticeboards;
using Disco.Services.Web;
using Disco.Web.Areas.Public.Models.UserHeldDevices;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
@@ -7,9 +10,26 @@ namespace Disco.Web.Areas.Public.Controllers
{
public partial class HeldDevicesController : DatabaseController
{
public virtual ActionResult Index()
public virtual ActionResult Index(List<int?> DeviceProfileInclude, List<int?> DeviceProfileExclude, List<string> DeviceAddressInclude, List<string> DeviceAddressExclude)
{
var m = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(Database);
IQueryable<Job> query = Database.Jobs;
if (DeviceProfileInclude != null)
query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId));
if (DeviceProfileExclude != null)
query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId));
if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0)
{
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList();
query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
}
if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0)
{
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList();
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
}
var m = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(query);
return View(m);
}
@@ -38,7 +58,12 @@ namespace Disco.Web.Areas.Public.Controllers
public virtual ActionResult Noticeboard()
{
return View();
var model = new NoticeboardModel()
{
DefaultTheme = Database.DiscoConfiguration.JobPreferences.DefaultNoticeboardTheme
};
return View(model);
}
public virtual ActionResult HeldDevice(string id)
@@ -1,5 +1,8 @@
using Disco.Services.Jobs.Noticeboards;
using Disco.Models.Repository;
using Disco.Services.Jobs.Noticeboards;
using Disco.Services.Web;
using Disco.Web.Areas.Public.Models.UserHeldDevices;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
@@ -7,9 +10,26 @@ namespace Disco.Web.Areas.Public.Controllers
{
public partial class UserHeldDevicesController : DatabaseController
{
public virtual ActionResult Index()
public virtual ActionResult Index(List<int?> DeviceProfileInclude, List<int?> DeviceProfileExclude, List<string> DeviceAddressInclude, List<string> DeviceAddressExclude)
{
var m = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(Database);
IQueryable<Job> query = Database.Jobs;
if (DeviceProfileInclude != null)
query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId));
if (DeviceProfileExclude != null)
query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId));
if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0)
{
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList();
query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
}
if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0)
{
var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList();
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
}
var m = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(query);
return View(m);
}
@@ -38,7 +58,12 @@ namespace Disco.Web.Areas.Public.Controllers
public virtual ActionResult Noticeboard()
{
return View();
var model = new NoticeboardModel()
{
DefaultTheme = Database.DiscoConfiguration.JobPreferences.DefaultNoticeboardTheme
};
return View(model);
}
public virtual ActionResult UserHeldDevice(string id)