From 25a8563ee8891a342687f40dd61cf54930e63dc6 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Thu, 24 Mar 2016 19:45:02 +0000 Subject: [PATCH] Fixed #69 Removed some redundant code --- PlexRequests.Api/SonarrApi.cs | 41 ++++++--------------- PlexRequests.Store/RequestedModel.cs | 1 + PlexRequests.UI/Content/requests.js | 3 +- PlexRequests.UI/Models/RequestViewModel.cs | 1 + PlexRequests.UI/Modules/LoginModule.cs | 7 ++++ PlexRequests.UI/Modules/RequestsModule.cs | 3 +- PlexRequests.UI/Modules/SearchModule.cs | 26 +++---------- PlexRequests.UI/Program.cs | 5 --- PlexRequests.UI/Views/Requests/Index.cshtml | 3 ++ 9 files changed, 33 insertions(+), 57 deletions(-) diff --git a/PlexRequests.Api/SonarrApi.cs b/PlexRequests.Api/SonarrApi.cs index 166b41497..1d1a57f34 100644 --- a/PlexRequests.Api/SonarrApi.cs +++ b/PlexRequests.Api/SonarrApi.cs @@ -63,36 +63,17 @@ namespace PlexRequests.Api Method = Method.POST }; - var options = new SonarrAddSeries(); - - - //I'm fairly certain we won't need this logic anymore since we're manually adding the seasons - //if (seasons.Length == 0) - //{ - // options.addOptions = new AddOptions - // { - // ignoreEpisodesWithFiles = true, - // ignoreEpisodesWithoutFiles = true, - // searchForMissingEpisodes = false - // }; - //} - //else - //{ - // options.addOptions = new AddOptions - // { - // ignoreEpisodesWithFiles = false, - // ignoreEpisodesWithoutFiles = false, - // searchForMissingEpisodes = true - // }; - //} - - options.seasonFolder = seasonFolders; - options.title = title; - options.qualityProfileId = qualityId; - options.tvdbId = tvdbId; - options.titleSlug = title; - options.seasons = new List(); - options.rootFolderPath = rootPath; + var options = new SonarrAddSeries + { + seasonFolder = seasonFolders, + title = title, + qualityProfileId = qualityId, + tvdbId = tvdbId, + titleSlug = title, + seasons = new List(), + rootFolderPath = rootPath + }; + for (var i = 1; i <= seasonCount; i++) { diff --git a/PlexRequests.Store/RequestedModel.cs b/PlexRequests.Store/RequestedModel.cs index 5f746b841..18ef216af 100644 --- a/PlexRequests.Store/RequestedModel.cs +++ b/PlexRequests.Store/RequestedModel.cs @@ -26,6 +26,7 @@ namespace PlexRequests.Store public string AdminNote { get; set; } public int[] SeasonList { get; set; } public int SeasonCount { get; set; } + public string SeasonsRequested { get; set; } } public enum RequestType diff --git a/PlexRequests.UI/Content/requests.js b/PlexRequests.UI/Content/requests.js index 961b30a9a..e05cd294d 100644 --- a/PlexRequests.UI/Content/requests.js +++ b/PlexRequests.UI/Content/requests.js @@ -362,7 +362,8 @@ function buildRequestContext(result, type) { otherMessage: result.otherMessage, requestId: result.id, adminNote: result.adminNotes, - imdb: result.imdbId + imdb: result.imdbId, + seriesRequested: result.tvSeriesRequestType }; return context; diff --git a/PlexRequests.UI/Models/RequestViewModel.cs b/PlexRequests.UI/Models/RequestViewModel.cs index 6018b50b1..011b9977d 100644 --- a/PlexRequests.UI/Models/RequestViewModel.cs +++ b/PlexRequests.UI/Models/RequestViewModel.cs @@ -48,5 +48,6 @@ namespace PlexRequests.UI.Models public string Issues { get; set; } public string OtherMessage { get; set; } public string AdminNotes { get; set; } + public string TvSeriesRequestType { get; set; } } } diff --git a/PlexRequests.UI/Modules/LoginModule.cs b/PlexRequests.UI/Modules/LoginModule.cs index 5436be973..578b9cf7f 100644 --- a/PlexRequests.UI/Modules/LoginModule.cs +++ b/PlexRequests.UI/Modules/LoginModule.cs @@ -115,6 +115,13 @@ namespace PlexRequests.UI.Modules var oldPass = Request.Form.OldPassword; var newPassword = Request.Form.NewPassword; var newPasswordAgain = Request.Form.NewPasswordAgain; + + if (string.IsNullOrEmpty(oldPass) || string.IsNullOrEmpty(newPassword) || + string.IsNullOrEmpty(newPasswordAgain)) + { + return Response.AsJson(new JsonResponseModel { Message = "Please fill in all fields", Result = false }); + } + if (!newPassword.Equals(newPasswordAgain)) { return Response.AsJson(new JsonResponseModel { Message = "The passwords do not match", Result = false }); diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 2f9eb364d..a951e0db8 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -129,7 +129,8 @@ namespace PlexRequests.UI.Modules Admin = isAdmin, Issues = tv.Issues.Humanize(LetterCasing.Title), OtherMessage = tv.OtherMessage, - AdminNotes = tv.AdminNote + AdminNotes = tv.AdminNote, + TvSeriesRequestType = tv.SeasonsRequested }).ToList(); return Response.AsJson(viewModel); diff --git a/PlexRequests.UI/Modules/SearchModule.cs b/PlexRequests.UI/Modules/SearchModule.cs index 67fe62c22..0ea295d40 100644 --- a/PlexRequests.UI/Modules/SearchModule.cs +++ b/PlexRequests.UI/Modules/SearchModule.cs @@ -261,7 +261,7 @@ namespace PlexRequests.UI.Modules /// Requests the tv show. /// /// The show identifier. - /// if set to true [latest]. + /// The seasons. /// private Response RequestTvShow(int showId, string seasons) { @@ -310,9 +310,14 @@ namespace PlexRequests.UI.Modules { case "first": seasonsList.Add(1); + model.SeasonsRequested = "First"; break; case "latest": seasonsList.Add(model.SeasonCount); + model.SeasonsRequested = "Latest"; + break; + default: + model.SeasonsRequested = "All"; break; } @@ -370,24 +375,5 @@ namespace PlexRequests.UI.Modules var result = Checker.IsAvailable(title, year); return result; } - - //private Response SendToSickRage(SickRageSettings sickRageSettings, RequestedModel model) - //{ - // var result = SickrageApi.AddSeries(model.ProviderId, model.SeasonCount, model.SeasonList, sickRageSettings.QualityProfile, - // sickRageSettings.ApiKey, sickRageSettings.FullUri); - - // Log.Trace("SickRage Result: "); - // Log.Trace(result.DumpJson()); - - // if (result?.result == "success") - // { - // model.Approved = true; - // Log.Debug("Adding tv to database requests (No approval required & SickRage)"); - // RequestService.AddRequest(model); - - // return Response.AsJson(new JsonResponseModel { Result = true }); - // } - // return Response.AsJson(new JsonResponseModel { Result = false, Message = "Something went wrong adding the movie to SickRage! Please check your settings." }); - //} } } \ No newline at end of file diff --git a/PlexRequests.UI/Program.cs b/PlexRequests.UI/Program.cs index f84972699..7ca3fa77c 100644 --- a/PlexRequests.UI/Program.cs +++ b/PlexRequests.UI/Program.cs @@ -25,8 +25,6 @@ // ************************************************************************/ #endregion using System; -using System.Data; - using Microsoft.Owin.Hosting; using Mono.Data.Sqlite; @@ -34,9 +32,6 @@ using Mono.Unix; using Mono.Unix.Native; using NLog; -using NLog.Config; -using NLog.Targets; - using PlexRequests.Core; using PlexRequests.Core.SettingModels; using PlexRequests.Helpers; diff --git a/PlexRequests.UI/Views/Requests/Index.cshtml b/PlexRequests.UI/Views/Requests/Index.cshtml index 2b6653f0a..cd73d64d9 100644 --- a/PlexRequests.UI/Views/Requests/Index.cshtml +++ b/PlexRequests.UI/Views/Requests/Index.cshtml @@ -119,6 +119,9 @@ {{/if_eq}} + {{#if_eq type "tv"}} +
Series Requested: {{seriesRequested}}
+ {{/if_eq}}
Requested By: {{requestedBy}}
Requested Date: {{requestedDate}}