From 5288685f976f7f44c72753f9858bd230adc198ab Mon Sep 17 00:00:00 2001 From: Jamie Date: Mon, 10 Oct 2016 22:01:11 +0100 Subject: [PATCH 1/5] Update appveyor.yml --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 7282f9b16..a860b2de2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,9 +3,9 @@ configuration: Release assembly_info: patch: true file: '**\AssemblyInfo.*' - assembly_version: '1.9.3' + assembly_version: '1.9.4' assembly_file_version: '{version}' - assembly_informational_version: '1.9.3' + assembly_informational_version: '1.9.4' before_build: - cmd: appveyor-retry nuget restore build: From 626decacb1c71244faabd4f46caa888c0e2f8591 Mon Sep 17 00:00:00 2001 From: Jim MacKenzie Date: Wed, 12 Oct 2016 21:26:03 -0500 Subject: [PATCH 2/5] Moved Newsletter Settings to its own page --- PlexRequests.Core/PlexRequests.Core.csproj | 1 + .../SettingModels/NewsletterSettings.cs | 38 ++++++++++ .../SettingModels/PlexRequestSettings.cs | 1 - PlexRequests.Services/Jobs/RecentlyAdded.cs | 4 +- PlexRequests.UI/Modules/AdminModule.cs | 33 ++++++++ PlexRequests.UI/PlexRequests.UI.csproj | 1 + .../Views/Admin/NewsletterSettings.cshtml | 76 +++++++++++++++++++ PlexRequests.UI/Views/Admin/Settings.cshtml | 19 ----- PlexRequests.UI/Views/Admin/_Sidebar.cshtml | 1 + 9 files changed, 152 insertions(+), 22 deletions(-) create mode 100644 PlexRequests.Core/SettingModels/NewsletterSettings.cs create mode 100644 PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml diff --git a/PlexRequests.Core/PlexRequests.Core.csproj b/PlexRequests.Core/PlexRequests.Core.csproj index d3cd82a7b..57f0e7dfc 100644 --- a/PlexRequests.Core/PlexRequests.Core.csproj +++ b/PlexRequests.Core/PlexRequests.Core.csproj @@ -89,6 +89,7 @@ + diff --git a/PlexRequests.Core/SettingModels/NewsletterSettings.cs b/PlexRequests.Core/SettingModels/NewsletterSettings.cs new file mode 100644 index 000000000..775c06571 --- /dev/null +++ b/PlexRequests.Core/SettingModels/NewsletterSettings.cs @@ -0,0 +1,38 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: NewsletterSettings.cs +// Created By: Jim MacKenzie +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using System.Collections.Generic; +using PlexRequests.Core.Models; +using PlexRequests.Core.Notification; + +namespace PlexRequests.Core.SettingModels +{ + public class NewletterSettings : Settings + { + public bool SendRecentlyAddedEmail { get; set; } + } +} \ No newline at end of file diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 65afd1559..0802bb204 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -58,7 +58,6 @@ namespace PlexRequests.Core.SettingModels public bool Wizard { get; set; } public bool DisableTvRequestsByEpisode { get; set; } public bool DisableTvRequestsBySeason { get; set; } - public bool SendRecentlyAddedEmail { get; set; } public string CustomDonationUrl { get; set; } public bool EnableCustomDonationUrl { get; set; } diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index c138b942b..1ffee4ebb 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -48,7 +48,7 @@ namespace PlexRequests.Services.Jobs public class RecentlyAdded : IJob, IRecentlyAdded { public RecentlyAdded(IPlexApi api, ISettingsService plexSettings, ISettingsService email, - ISettingsService scheduledService, IJobRecord rec, ISettingsService plexRequest) + ISettingsService scheduledService, IJobRecord rec, ISettingsService plexRequest) { JobRecord = rec; Api = api; @@ -63,7 +63,7 @@ namespace PlexRequests.Services.Jobs private readonly TheMovieDbApi _movieApi = new TheMovieDbApi(); private ISettingsService PlexSettings { get; } private ISettingsService EmailSettings { get; } - private ISettingsService PlexRequestSettings { get; } + private ISettingsService PlexRequestSettings { get; } private ISettingsService ScheduledJobsSettings { get; } private IJobRecord JobRecord { get; } diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index fba7e8a95..d583168df 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -80,6 +80,7 @@ namespace PlexRequests.UI.Modules private ISettingsService PushbulletService { get; } private ISettingsService PushoverService { get; } private ISettingsService HeadphonesService { get; } + private ISettingsService NewsLetterService { get; } private ISettingsService LogService { get; } private IPlexApi PlexApi { get; } private ISonarrApi SonarrApi { get; } @@ -112,6 +113,7 @@ namespace PlexRequests.UI.Modules PushbulletApi pbApi, ICouchPotatoApi cpApi, ISettingsService pushoverSettings, + ISettingsService newsletter, IPushoverApi pushoverApi, IRepository logsRepo, INotificationService notify, @@ -139,6 +141,7 @@ namespace PlexRequests.UI.Modules PushoverApi = pushoverApi; NotificationService = notify; HeadphonesService = headphones; + NewsLetterService = newsletter; LogService = logs; Cache = cache; SlackSettings = slackSettings; @@ -200,6 +203,9 @@ namespace PlexRequests.UI.Modules Get["/headphones"] = _ => Headphones(); Post["/headphones"] = _ => SaveHeadphones(); + Get["/newsletter"] = _ => Newsletter(); + Post["/newsletter"] = _ => SaveNewsletter(); + Post["/createapikey"] = x => CreateApiKey(); Post["/autoupdate"] = x => AutoUpdate(); @@ -814,6 +820,33 @@ namespace PlexRequests.UI.Modules : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." }); } + private Negotiator Newsletter() + { + var settings = NewsLetterService.GetSettings(); + return View["NewsletterSettings", settings]; + } + + private Response SaveNewsletter() + { + var settings = this.Bind(); + + var valid = this.Validate(settings); + if (!valid.IsValid) + { + var error = valid.SendJsonError(); + Log.Info("Error validating Headphones settings, message: {0}", error.Message); + return Response.AsJson(error); + } + settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail; + var result = NewsLetterService.SaveSettings(settings); + + Log.Info("Saved headphones settings, result: {0}", result); + return Response.AsJson(result + ? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Newsletter!" } + : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." }); + } + + private Response CreateApiKey() { this.RequiresClaims(UserClaims.Admin); diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index bd88121f2..535042274 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -711,6 +711,7 @@ Always + web.config diff --git a/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml b/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml new file mode 100644 index 000000000..f45060aa8 --- /dev/null +++ b/PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml @@ -0,0 +1,76 @@ +@using System.Linq +@using PlexRequests.Core.Models +@using PlexRequests.UI.Helpers +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase +@Html.Partial("_Sidebar") + +
+
+
+ Newsletter Settings + + +
+
+ + Note: This will require you to setup your email notifications + @if (Model.SendRecentlyAddedEmail) + { + + } + else + { + + } + +
+ +
+ +
+
+
+
+ +
+
+ + +
+
+
+ + + \ No newline at end of file diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index 8ed022ee8..0a2a55c3a 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -75,26 +75,7 @@
-
-
-
- - Note: This will require you to setup your email notifications - @if (Model.SendRecentlyAddedEmail) - { - - } - else - { - - } - -
-
-
-
-
diff --git a/PlexRequests.UI/Views/Admin/_Sidebar.cshtml b/PlexRequests.UI/Views/Admin/_Sidebar.cshtml index 37d6fb9e5..30739102d 100644 --- a/PlexRequests.UI/Views/Admin/_Sidebar.cshtml +++ b/PlexRequests.UI/Views/Admin/_Sidebar.cshtml @@ -9,6 +9,7 @@ @Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr") @Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage") @Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (Beta)") + @Html.GetSidebarUrl(Context, "/admin/newsletter", "Newsletter Settings") @Html.GetSidebarUrl(Context, "/admin/emailnotification", "Email Notifications") @Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications") @Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications") From b06c55c2bf2d7768d4e9112d73b3d48cbbe3658b Mon Sep 17 00:00:00 2001 From: Jim MacKenzie Date: Wed, 12 Oct 2016 21:27:28 -0500 Subject: [PATCH 3/5] removed extra line breaks --- PlexRequests.UI/Views/Admin/Settings.cshtml | 2 -- 1 file changed, 2 deletions(-) diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index 0a2a55c3a..fdb847b13 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -74,8 +74,6 @@
-
-
From bfea6815224470b104ce215bfca326fb0a5816a6 Mon Sep 17 00:00:00 2001 From: Jim MacKenzie Date: Fri, 14 Oct 2016 22:14:27 -0500 Subject: [PATCH 4/5] Migration setup --- .../SettingModels/PlexRequestSettings.cs | 3 +- PlexRequests.Core/Setup.cs | 30 +++++++++++++++++++ PlexRequests.Services/Jobs/RecentlyAdded.cs | 8 ++--- 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 0802bb204..682e584f5 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -58,7 +58,8 @@ namespace PlexRequests.Core.SettingModels public bool Wizard { get; set; } public bool DisableTvRequestsByEpisode { get; set; } public bool DisableTvRequestsBySeason { get; set; } - + //To Remove at some point? + public bool SendRecentlyAddedEmail { get; set; } public string CustomDonationUrl { get; set; } public bool EnableCustomDonationUrl { get; set; } public string CustomDonationMessage { get; set; } diff --git a/PlexRequests.Core/Setup.cs b/PlexRequests.Core/Setup.cs index dac15a731..e16613161 100644 --- a/PlexRequests.Core/Setup.cs +++ b/PlexRequests.Core/Setup.cs @@ -72,6 +72,10 @@ namespace PlexRequests.Core { MigrateToVersion1910(); } + if (version > 1943 && version <= 1945) + { + MigrateToVersion1945(); + } } return Db.DbConnection().ConnectionString; @@ -275,5 +279,31 @@ namespace PlexRequests.Core Log.Error(e); } } + + + /// + /// Migrates to version1945 + /// + public void MigrateToVersion1945() + { + try + { + var settings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); + var plex = settings.GetSettings(); + var newsLetterSettings = new SettingsServiceV2(new SettingsJsonRepository(Db, new MemoryCacheProvider())); + var newsLetter = newsLetterSettings.GetSettings(); + if (plex.SendRecentlyAddedEmail) + { + newsLetter.SendRecentlyAddedEmail = plex.SendRecentlyAddedEmail; + plex.SendRecentlyAddedEmail = false; + settings.SaveSettings(plex); + newsLetterSettings.SaveSettings(newsLetter); + } + } + catch (Exception e) + { + Log.Error(e); + } + } } } diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index 1ffee4ebb..6f0e76f3a 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -48,14 +48,14 @@ namespace PlexRequests.Services.Jobs public class RecentlyAdded : IJob, IRecentlyAdded { public RecentlyAdded(IPlexApi api, ISettingsService plexSettings, ISettingsService email, - ISettingsService scheduledService, IJobRecord rec, ISettingsService plexRequest) + ISettingsService scheduledService, IJobRecord rec, ISettingsService newsletter) { JobRecord = rec; Api = api; PlexSettings = plexSettings; EmailSettings = email; ScheduledJobsSettings = scheduledService; - PlexRequestSettings = plexRequest; + NewsletterSettings = newsletter; } private IPlexApi Api { get; } @@ -63,7 +63,7 @@ namespace PlexRequests.Services.Jobs private readonly TheMovieDbApi _movieApi = new TheMovieDbApi(); private ISettingsService PlexSettings { get; } private ISettingsService EmailSettings { get; } - private ISettingsService PlexRequestSettings { get; } + private ISettingsService NewsletterSettings { get; } private ISettingsService ScheduledJobsSettings { get; } private IJobRecord JobRecord { get; } @@ -73,7 +73,7 @@ namespace PlexRequests.Services.Jobs { try { - var settings = PlexRequestSettings.GetSettings(); + var settings = NewsletterSettings.GetSettings(); if (!settings.SendRecentlyAddedEmail) { return; From b8c488ce3d2caf56bff6b0374b807fef4a7b5ddb Mon Sep 17 00:00:00 2001 From: Jim MacKenzie Date: Mon, 17 Oct 2016 20:00:03 -0500 Subject: [PATCH 5/5] Marked as obsolete --- PlexRequests.Core/SettingModels/PlexRequestSettings.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 682e584f5..5c7e6ddf5 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -58,7 +58,7 @@ namespace PlexRequests.Core.SettingModels public bool Wizard { get; set; } public bool DisableTvRequestsByEpisode { get; set; } public bool DisableTvRequestsBySeason { get; set; } - //To Remove at some point? + [Obsolete("Moved to NewsLetterSettings")] public bool SendRecentlyAddedEmail { get; set; } public string CustomDonationUrl { get; set; } public bool EnableCustomDonationUrl { get; set; }