From f5ecb630718981e3955c0db3202aa9a5a9d6faa7 Mon Sep 17 00:00:00 2001 From: Drewster727 Date: Sun, 27 Mar 2016 22:39:59 -0500 Subject: [PATCH] #84 provide an option in settings to resttrict users from viewing requests other than their own. --- .../SettingModels/PlexRequestSettings.cs | 1 + PlexRequests.UI/Modules/RequestsModule.cs | 12 ++++++++ PlexRequests.UI/Views/Admin/Settings.cshtml | 28 ++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs index 5dfe7cf76..aebb720af 100644 --- a/PlexRequests.Core/SettingModels/PlexRequestSettings.cs +++ b/PlexRequests.Core/SettingModels/PlexRequestSettings.cs @@ -38,6 +38,7 @@ namespace PlexRequests.Core.SettingModels public bool SearchForTvShows { get; set; } public bool RequireMovieApproval { get; set; } public bool RequireTvShowApproval { get; set; } + public bool UsersCanViewOnlyOwnRequests { get; set; } public int WeeklyRequestLimit { get; set; } public string NoApprovalUsers { get; set; } diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 47dcf3369..b49acd013 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -79,8 +79,14 @@ namespace PlexRequests.UI.Modules private Response GetMovies() { + var settings = PrSettings.GetSettings(); var isAdmin = Context.CurrentUser.IsAuthenticated(); var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie); + if (settings.UsersCanViewOnlyOwnRequests && !isAdmin) + { + dbMovies = dbMovies.Where(x => x.RequestedBy.Equals(Session[SessionKeys.UsernameKey].ToString(), StringComparison.OrdinalIgnoreCase)); + } + var viewModel = dbMovies.Select(movie => new RequestViewModel { ProviderId = movie.ProviderId, @@ -110,8 +116,14 @@ namespace PlexRequests.UI.Modules private Response GetTvShows() { + var settings = PrSettings.GetSettings(); var isAdmin = Context.CurrentUser.IsAuthenticated(); var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow); + if (settings.UsersCanViewOnlyOwnRequests && !isAdmin) + { + dbTv = dbTv.Where(x => x.RequestedBy.Equals(Session[SessionKeys.UsernameKey].ToString(), StringComparison.OrdinalIgnoreCase)); + } + var viewModel = dbTv.Select(tv => new RequestViewModel { ProviderId = tv.ProviderId, diff --git a/PlexRequests.UI/Views/Admin/Settings.cshtml b/PlexRequests.UI/Views/Admin/Settings.cshtml index 078171cda..1f3257c49 100644 --- a/PlexRequests.UI/Views/Admin/Settings.cshtml +++ b/PlexRequests.UI/Views/Admin/Settings.cshtml @@ -90,16 +90,31 @@ -
- @*
- -
+
+
+
-
//TODO: Need to implement this*@ +
+ + @*
+ +
+ +
+
//TODO: Need to implement this*@
@@ -111,4 +126,3 @@
-