#84 provide an option in settings to resttrict users from viewing requests other than their own.

pull/110/head
Drewster727 9 years ago
parent fff267db37
commit f5ecb63071

@ -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; }

@ -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,

@ -90,16 +90,31 @@
<input type="text" class="form-control-custom form-control " id="NoApprovalUsers" name="NoApprovalUsers" placeholder="e.g. John, Bobby" value="@Model.NoApprovalUsers">
</div>
</div>
<br />
@*<div class="form-group">
<label for="WeeklyRequestLimit" class="control-label">Weekly Request Limit</label>
<div>
<div class="form-group">
<div class="checkbox">
<label>
<input type="number" id="WeeklyRequestLimit" name="WeeklyRequestLimit" class="form-control form-control-custom " value="@Model.WeeklyRequestLimit">
@if (Model.UsersCanViewOnlyOwnRequests)
{
<input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests" checked="checked"><text>Users can view their own requests only</text>
}
else
{
<input type="checkbox" id="UsersCanViewOnlyOwnRequests" name="UsersCanViewOnlyOwnRequests"><text>Users can view their own requests only</text>
}
</label>
</div>
</div> //TODO: Need to implement this*@
</div>
@*<div class="form-group">
<label for="WeeklyRequestLimit" class="control-label">Weekly Request Limit</label>
<div>
<label>
<input type="number" id="WeeklyRequestLimit" name="WeeklyRequestLimit" class="form-control form-control-custom " value="@Model.WeeklyRequestLimit">
</label>
</div>
</div> //TODO: Need to implement this*@
<div>
</div>
@ -111,4 +126,3 @@
</fieldset>
</form>
</div>

Loading…
Cancel
Save