mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
More for #273
This commit is contained in:
parent
6067a4743e
commit
9ffe184dd3
11 changed files with 67 additions and 56 deletions
|
@ -87,21 +87,21 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
protected BaseAuthModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
|
||||
{
|
||||
Service = pr;
|
||||
PlexRequestSettings = pr;
|
||||
Before += (ctx) => CheckAuth();
|
||||
}
|
||||
|
||||
protected BaseAuthModule(string modulePath, ISettingsService<PlexRequestSettings> pr) : base(modulePath, pr)
|
||||
{
|
||||
Service = pr;
|
||||
PlexRequestSettings = pr;
|
||||
Before += (ctx) => CheckAuth();
|
||||
}
|
||||
|
||||
private ISettingsService<PlexRequestSettings> Service { get; }
|
||||
protected ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
|
||||
|
||||
private Response CheckAuth()
|
||||
{
|
||||
var settings = Service.GetSettings();
|
||||
var settings = PlexRequestSettings.GetSettings();
|
||||
var baseUrl = settings.BaseUrl;
|
||||
|
||||
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin";
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Nancy;
|
||||
|
@ -23,7 +25,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
Get["/issuecount", true] = async (x, ct) => await IssueCount();
|
||||
|
||||
Get["/details/{id}", true] = async (x, ct) => await Details(x.id);
|
||||
Get["/{id}", true] = async (x, ct) => await Details(x.id);
|
||||
|
||||
Post["/issue", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);
|
||||
Post["/issuecomment", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
|
||||
|
@ -40,13 +42,35 @@ namespace PlexRequests.UI.Modules
|
|||
public async Task<Response> IssueCount()
|
||||
{
|
||||
var issues = await IssuesService.GetAllAsync();
|
||||
var count = issues.Count(x => x.Deleted == false);
|
||||
var settings = PlexRequestSettings.GetSettings();
|
||||
|
||||
IEnumerable<IssueModel> myIssues;
|
||||
|
||||
if (IsAdmin)
|
||||
{
|
||||
myIssues = issues.Where(x => x.Deleted == false).SelectMany(i => i.Issues);
|
||||
}
|
||||
else if (settings.UsersCanViewOnlyOwnRequests)
|
||||
{
|
||||
myIssues = (from issuesModel in issues
|
||||
from i in issuesModel.Issues
|
||||
where i.UserReported.Equals(Username, StringComparison.CurrentCultureIgnoreCase)
|
||||
select i).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
myIssues = issues.Where(x => x.Deleted == false).SelectMany(i => i.Issues);
|
||||
}
|
||||
|
||||
|
||||
var count = myIssues.Count();
|
||||
|
||||
return Response.AsJson(count);
|
||||
}
|
||||
|
||||
public async Task<Negotiator> Details(int id)
|
||||
{
|
||||
|
||||
var issue = await IssuesService.GetAsync(id);
|
||||
|
||||
return issue == null
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace PlexRequests.UI.Modules
|
|||
Get["/"] = _ => LoadRequests();
|
||||
Get["/movies", true] = async (x, ct) => await GetMovies();
|
||||
Get["/tvshows", true] = async (c, ct) => await GetTvShows();
|
||||
Get["/albums", true] = async (x,ct) => await GetAlbumRequests();
|
||||
Get["/albums", true] = async (x, ct) => await GetAlbumRequests();
|
||||
Post["/delete", true] = async (x, ct) => await DeleteRequest((int)Request.Form.id);
|
||||
Post["/reportissue", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, (IssueState)(int)Request.Form.issue, null);
|
||||
Post["/reportissuecomment", true] = async (x, ct) => await ReportIssue((int)Request.Form.requestId, IssueState.Other, (string)Request.Form.commentArea);
|
||||
|
@ -156,9 +156,7 @@ namespace PlexRequests.UI.Modules
|
|||
ReleaseYear = movie.ReleaseDate.Year.ToString(),
|
||||
Available = movie.Available,
|
||||
Admin = IsAdmin,
|
||||
Issues = movie.Issues.ToString().CamelCaseToWords(),
|
||||
OtherMessage = movie.OtherMessage,
|
||||
AdminNotes = movie.AdminNote,
|
||||
IssueId = movie.IssueId,
|
||||
Qualities = qualities.ToArray()
|
||||
}).ToList();
|
||||
|
||||
|
@ -223,9 +221,7 @@ namespace PlexRequests.UI.Modules
|
|||
ReleaseYear = tv.ReleaseDate.Year.ToString(),
|
||||
Available = tv.Available,
|
||||
Admin = IsAdmin,
|
||||
Issues = tv.Issues.ToString().CamelCaseToWords(),
|
||||
OtherMessage = tv.OtherMessage,
|
||||
AdminNotes = tv.AdminNote,
|
||||
IssueId = tv.IssueId,
|
||||
TvSeriesRequestType = tv.SeasonsRequested,
|
||||
Qualities = qualities.ToArray()
|
||||
};
|
||||
|
@ -266,9 +262,7 @@ namespace PlexRequests.UI.Modules
|
|||
ReleaseYear = album.ReleaseDate.Year.ToString(),
|
||||
Available = album.Available,
|
||||
Admin = IsAdmin,
|
||||
Issues = album.Issues.ToString().CamelCaseToWords(),
|
||||
OtherMessage = album.OtherMessage,
|
||||
AdminNotes = album.AdminNote,
|
||||
IssueId = album.IssueId,
|
||||
TvSeriesRequestType = album.SeasonsRequested,
|
||||
MusicBrainzId = album.MusicBrainzId,
|
||||
ArtistName = album.ArtistName
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue