From 72e73b75138ee2631fd7b6e20547a3aec0a91348 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 28 May 2011 21:07:11 -0700 Subject: [PATCH] All profiles (including the default ones) are now editable. --- .../Controllers/SettingsController.cs | 22 ++++++++++--------- NzbDrone.Web/Models/QualityModel.cs | 1 - NzbDrone.Web/NzbDrone.Web.csproj | 5 +---- NzbDrone.Web/Views/Settings/Quality.cshtml | 20 ++++++++++++----- ...ction.cshtml => QualityProfileItem.cshtml} | 6 ++--- 5 files changed, 30 insertions(+), 24 deletions(-) rename NzbDrone.Web/Views/Settings/{UserProfileSection.cshtml => QualityProfileItem.cshtml} (95%) diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 50257c750..3dc0cbf32 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -29,11 +29,12 @@ public class SettingsController : Controller private readonly AutoConfigureProvider _autoConfigureProvider; private readonly NotificationProvider _notificationProvider; private readonly DiskProvider _diskProvider; + private readonly SeriesProvider _seriesProvider; public SettingsController(ConfigProvider configProvider, IndexerProvider indexerProvider, QualityProvider qualityProvider, RootDirProvider rootDirProvider, AutoConfigureProvider autoConfigureProvider, NotificationProvider notificationProvider, - DiskProvider diskProvider) + DiskProvider diskProvider, SeriesProvider seriesProvider) { _configProvider = configProvider; _indexerProvider = indexerProvider; @@ -42,6 +43,7 @@ public SettingsController(ConfigProvider configProvider, IndexerProvider indexer _autoConfigureProvider = autoConfigureProvider; _notificationProvider = notificationProvider; _diskProvider = diskProvider; + _seriesProvider = seriesProvider; } public ActionResult Test() @@ -131,7 +133,6 @@ public ActionResult Quality() ViewData["Qualities"] = qualityTypes; - var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList(); var defaultQualityQualityProfileId = Convert.ToInt32(_configProvider.DefaultQualityProfile); @@ -142,7 +143,6 @@ public ActionResult Quality() var model = new QualityModel { Profiles = profiles, - UserProfiles = userProfiles, DefaultQualityProfileId = defaultQualityQualityProfileId, DownloadPropers = downloadPropers, SelectList = selectList @@ -199,7 +199,7 @@ public ActionResult EpisodeSorting() return View("Index", model); } - public ViewResult AddUserProfile() + public ViewResult AddProfile() { var qualityTypes = new List(); @@ -213,7 +213,6 @@ public ViewResult AddUserProfile() var qualityProfile = new QualityProfile { Name = "New Profile", - UserProfile = true, Allowed = new List { QualityTypes.Unknown }, Cutoff = QualityTypes.Unknown, }; @@ -224,7 +223,7 @@ public ViewResult AddUserProfile() ViewData["ProfileId"] = id; - return View("UserProfileSection", qualityProfile); + return View("QualityProfileItem", qualityProfile); } public ActionResult GetQualityProfileView(QualityProfile profile) @@ -238,7 +237,7 @@ public ActionResult GetQualityProfileView(QualityProfile profile) ViewData["Qualities"] = qualityTypes; ViewData["ProfileId"] = profile.QualityProfileId; - return PartialView("UserProfileSection", profile); + return PartialView("QualityProfileItem", profile); } public ViewResult AddRootDir() @@ -294,6 +293,9 @@ public JsonResult DeleteQualityProfile(int profileId) { try { + if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0) + return new JsonResult { Data = "Unable to delete Profile, it is still in use." }; + _qualityProvider.Delete(profileId); } @@ -460,12 +462,12 @@ public ActionResult SaveQuality(QualityModel data) _configProvider.DownloadPropers = data.DownloadPropers; //Saves only the Default Quality, skips User Profiles since none exist - if (data.UserProfiles == null) + if (data.Profiles == null) return Content(SETTINGS_SAVED); - foreach (var profile in data.UserProfiles) + foreach (var profile in data.Profiles) { - Logger.Debug(String.Format("Updating User Profile: {0}", profile)); + Logger.Debug(String.Format("Updating Profile: {0}", profile)); profile.Allowed = new List(); foreach (var quality in profile.AllowedString.Split(',')) diff --git a/NzbDrone.Web/Models/QualityModel.cs b/NzbDrone.Web/Models/QualityModel.cs index ef5716f3d..47e173b8e 100644 --- a/NzbDrone.Web/Models/QualityModel.cs +++ b/NzbDrone.Web/Models/QualityModel.cs @@ -8,7 +8,6 @@ namespace NzbDrone.Web.Models public class QualityModel { public List Profiles { get; set; } - public List UserProfiles { get; set; } [DisplayName("Default Quality Profile")] [Description("The default quality to use when adding series to NzbDrone")] diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index b5034d831..89e3be2c8 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -712,7 +712,7 @@ - + @@ -871,9 +871,6 @@ - - -