From 3e5e188e2c791df99a4bb9b0bbdf6aff38ad5ee3 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sun, 9 Oct 2016 22:19:13 +0100 Subject: [PATCH 1/6] Moved the horizontal rules inside the table row --- PlexRequests.Services/Jobs/RecentlyAdded.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index 8e12f76c9..f6b47aab8 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -151,10 +151,10 @@ namespace PlexRequests.Services.Jobs sb.AppendFormat("

{0}

", info.Overview); sb.Append(""); sb.Append("
"); sb.Append("
"); sb.Append("
"); + sb.Append(""); } sb.Append("

"); From 41e6d72210bbcd9d76b28770474c1620d7cd0a77 Mon Sep 17 00:00:00 2001 From: Jim MacKenize Date: Mon, 10 Oct 2016 01:59:39 -0500 Subject: [PATCH 2/6] Added Paypalme options, no UI yet (#568) * Added Paypalme options * Added Custom Donation UI * Updated error checking * Review fixes to donation work --- .../SettingModels/PlexRequestSettings.cs | 3 ++ PlexRequests.UI/Modules/DonationLinkModule.cs | 52 +++++++++++++++++++ PlexRequests.UI/PlexRequests.UI.csproj | 1 + PlexRequests.UI/Resources/UI.resx | 3 ++ PlexRequests.UI/Resources/UI1.Designer.cs | 9 ++++ PlexRequests.UI/Views/Admin/Settings.cshtml | 30 ++++++++++- .../Views/Shared/Partial/_Navbar.cshtml | 27 +++++++++- 7 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 PlexRequests.UI/Modules/DonationLinkModule.cs diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 078798b3e..65afd1559 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -60,6 +60,9 @@ namespace PlexRequests.Core.SettingModels public bool DisableTvRequestsBySeason { get; set; } public bool SendRecentlyAddedEmail { get; set; } + public string CustomDonationUrl { get; set; } + public bool EnableCustomDonationUrl { get; set; } + public string CustomDonationMessage { get; set; } /// /// The CSS name of the theme we want /// diff --git a/PlexRequests.UI/Modules/DonationLinkModule.cs b/PlexRequests.UI/Modules/DonationLinkModule.cs new file mode 100644 index 000000000..9ede62e41 --- /dev/null +++ b/PlexRequests.UI/Modules/DonationLinkModule.cs @@ -0,0 +1,52 @@ +using System; +using System.Threading.Tasks; + +using Nancy; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NLog; + +using PlexRequests.Core; +using PlexRequests.Core.SettingModels; +using PlexRequests.Helpers; +using PlexRequests.UI.Models; + +namespace PlexRequests.UI.Modules +{ + public class DonationLinkModule : BaseAuthModule + { + public DonationLinkModule(ICacheProvider provider, ISettingsService pr) : base("customDonation", pr) + { + Cache = provider; + + Get["/", true] = async (x, ct) => await GetCustomDonationUrl(pr); + } + + private ICacheProvider Cache { get; } + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private async Task GetCustomDonationUrl(ISettingsService pr) + { + PlexRequestSettings settings = await pr.GetSettingsAsync(); + try + { + if (settings.EnableCustomDonationUrl) + { + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + else + { + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + } + catch (Exception e) + { + Log.Warn("Exception Thrown when attempting to check the custom donation url"); + Log.Warn(e); + return Response.AsJson(new { url = settings.CustomDonationUrl, message = settings.CustomDonationMessage }); + } + } + } + +} diff --git a/PlexRequests.UI/PlexRequests.UI.csproj b/PlexRequests.UI/PlexRequests.UI.csproj index 1df11b208..bd88121f2 100644 --- a/PlexRequests.UI/PlexRequests.UI.csproj +++ b/PlexRequests.UI/PlexRequests.UI.csproj @@ -248,6 +248,7 @@ + diff --git a/PlexRequests.UI/Resources/UI.resx b/PlexRequests.UI/Resources/UI.resx index 4f23fce97..883e20be1 100644 --- a/PlexRequests.UI/Resources/UI.resx +++ b/PlexRequests.UI/Resources/UI.resx @@ -443,4 +443,7 @@ View In Plex + + Donate to Library Maintainer + \ No newline at end of file diff --git a/PlexRequests.UI/Resources/UI1.Designer.cs b/PlexRequests.UI/Resources/UI1.Designer.cs index 6cd282c32..acb53c9bb 100644 --- a/PlexRequests.UI/Resources/UI1.Designer.cs +++ b/PlexRequests.UI/Resources/UI1.Designer.cs @@ -114,6 +114,15 @@ namespace PlexRequests.UI.Resources { } } + /// + /// Looks up a localized string similar to Donate to Library Maintainer. + /// + public static string Custom_Donation_Default { + get { + return ResourceManager.GetString("Custom_Donation_Default", resourceCulture); + } + } + /// /// Looks up a localized string similar to Issue. /// diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index 386b209c8..8ed022ee8 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -273,10 +273,38 @@ } +
+
+ + @if (Model.EnableCustomDonationUrl) + { + + + } + else + { + + } +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ -

A comma separated list of users whose requests do not require approval (These users also do not have a request limit).

+ +

A comma separated list of users whose requests do not require approval (These users also do not have a request limit).

diff --git a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml index 6692f6f74..8a1826a07 100644 --- a/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml +++ b/PlexRequests.UI/Views/Shared/Partial/_Navbar.cshtml @@ -1,6 +1,7 @@ @using Nancy.Security @using Nancy.Session @using Nancy; +@using PlexRequests.Core.SettingModels @using PlexRequests.UI.Helpers @using PlexRequests.UI.Models @using PlexRequests.UI.Resources @@ -38,10 +39,11 @@ {
  • } +
    + \ No newline at end of file From 0b241e0be363ede3ddf9b8b666e5c47fa3c91dd2 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Mon, 10 Oct 2016 10:15:26 +0100 Subject: [PATCH 3/6] Moved the HR inside the table for TV Shows --- PlexRequests.Services/Jobs/RecentlyAdded.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index f6b47aab8..83818d627 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -192,10 +192,10 @@ namespace PlexRequests.Services.Jobs string.IsNullOrEmpty(parentMetaData.Directory.Summary) ? info.summary : parentMetaData.Directory.Summary); // Episode Summary sb.Append(""); sb.Append("
    "); sb.Append("
    "); sb.Append("
    "); + sb.Append(""); } sb.Append("

    "); } From c0e6030ba35c71799509983cffd005a0f5f7fe4c Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 10 Oct 2016 21:36:29 +0100 Subject: [PATCH 4/6] FIXED!!!!! YES BITCH! #550 --- PlexRequests.Services/Jobs/RecentlyAdded.cs | 7 ++++++- PlexRequests.UI/Modules/BaseAuthModule.cs | 9 ++++++--- PlexRequests.UI/Modules/UserLoginModule.cs | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index f6b47aab8..3a744bb6b 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -147,7 +147,12 @@ namespace PlexRequests.Services.Jobs sb.AppendFormat("

    {1} {2}

    ", info.ImdbId, info.Title, info.ReleaseDate?.ToString("yyyy") ?? string.Empty); - sb.AppendFormat("

    Genre: {0}

    ", string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())); + if (info.Genres.Any()) + { + sb.AppendFormat( + "

    Genre: {0}

    ", + string.Join(", ", info.Genres.Select(x => x.Name.ToString()).ToArray())); + } sb.AppendFormat("

    {0}

    ", info.Overview); sb.Append(" Date: Mon, 10 Oct 2016 21:40:42 +0100 Subject: [PATCH 5/6] Make sure it's enabled before sending the recently added --- PlexRequests.Services/Jobs/RecentlyAdded.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/PlexRequests.Services/Jobs/RecentlyAdded.cs b/PlexRequests.Services/Jobs/RecentlyAdded.cs index e5b0cb702..c138b942b 100644 --- a/PlexRequests.Services/Jobs/RecentlyAdded.cs +++ b/PlexRequests.Services/Jobs/RecentlyAdded.cs @@ -48,13 +48,14 @@ namespace PlexRequests.Services.Jobs public class RecentlyAdded : IJob, IRecentlyAdded { public RecentlyAdded(IPlexApi api, ISettingsService plexSettings, ISettingsService email, - ISettingsService scheduledService, IJobRecord rec) + ISettingsService scheduledService, IJobRecord rec, ISettingsService plexRequest) { JobRecord = rec; Api = api; PlexSettings = plexSettings; EmailSettings = email; ScheduledJobsSettings = scheduledService; + PlexRequestSettings = plexRequest; } private IPlexApi Api { get; } @@ -62,6 +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 ScheduledJobsSettings { get; } private IJobRecord JobRecord { get; } @@ -71,14 +73,19 @@ namespace PlexRequests.Services.Jobs { try { + var settings = PlexRequestSettings.GetSettings(); + if (!settings.SendRecentlyAddedEmail) + { + return; + } var jobs = JobRecord.GetJobs(); var thisJob = jobs.FirstOrDefault( x => x.Name.Equals(JobNames.RecentlyAddedEmail, StringComparison.CurrentCultureIgnoreCase)); - var settings = ScheduledJobsSettings.GetSettings(); + var jobSettings = ScheduledJobsSettings.GetSettings(); - if (thisJob?.LastRun > DateTime.Now.AddHours(-settings.RecentlyAdded)) + if (thisJob?.LastRun > DateTime.Now.AddHours(-jobSettings.RecentlyAdded)) { return; } From c1ea2ecc65bef15a7f5e05c0520063ba26cb46cf Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 10 Oct 2016 21:55:43 +0100 Subject: [PATCH 6/6] Reverted --- PlexRequests.UI/Modules/UserLoginModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlexRequests.UI/Modules/UserLoginModule.cs b/PlexRequests.UI/Modules/UserLoginModule.cs index 7e7d1dc42..d9a0c5327 100644 --- a/PlexRequests.UI/Modules/UserLoginModule.cs +++ b/PlexRequests.UI/Modules/UserLoginModule.cs @@ -65,7 +65,7 @@ namespace PlexRequests.UI.Modules { if (!string.IsNullOrEmpty(Username) || IsAdmin) { - var url = Linker.BuildAbsoluteUri(Context, "SearchIndex").ToString(); + var url = Linker.BuildRelativeUri(Context, "SearchIndex").ToString(); return Response.AsRedirect(url); } var settings = await AuthService.GetSettingsAsync();