This commit is contained in:
tidusjar 2016-08-30 14:31:18 +01:00
commit 0ac114d987
7 changed files with 214 additions and 17 deletions

View file

@ -65,6 +65,7 @@ namespace PlexRequests.UI.Modules
HeadphoneApi = hpApi;
Post["/approve", true] = async (x, ct) => await Approve((int)Request.Form.requestid, (string)Request.Form.qualityId);
Post["/deny", true] = async (x, ct) => await DenyRequest((int)Request.Form.requestid, (string)Request.Form.reason);
Post["/approveall", true] = async (x, ct) => await ApproveAll();
Post["/approveallmovies", true] = async (x, ct) => await ApproveAllMovies();
Post["/approvealltvshows", true] = async (x, ct) => await ApproveAllTVShows();
@ -262,7 +263,7 @@ namespace PlexRequests.UI.Modules
{
var requests = await Service.GetAllAsync();
requests = requests.Where(x => x.CanApprove && x.Type == RequestType.Movie);
requests = requests.Where(x => x.CanApprove && x.Type == RequestType.Movie);
var requestedModels = requests as RequestedModel[] ?? requests.ToArray();
if (!requestedModels.Any())
{
@ -491,6 +492,24 @@ namespace PlexRequests.UI.Modules
}
}
private async Task<Response> DenyRequest(int requestId, string reason)
{
// Get the request from the DB
var request = await Service.GetAsync(requestId);
// Deny it
request.Denied = true;
request.DeniedReason = reason;
// Update the new value
var result = await Service.UpdateRequestAsync(request);
return result
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Request has been denied" })
: Response.AsJson(new JsonResponseModel { Result = false, Message = "An error happened, could not update the DB" });
}
private bool SendMovie(CouchPotatoSettings settings, RequestedModel r, ICouchPotatoApi cp)
{
Log.Info("Adding movie to CP : {0}", r.Title);

View file

@ -178,6 +178,8 @@ namespace PlexRequests.UI.Modules
Available = movie.Available,
Admin = IsAdmin,
IssueId = movie.IssueId,
Denied = movie.Denied,
DeniedReason = movie.DeniedReason,
Qualities = qualities.ToArray()
}).ToList();
@ -249,6 +251,8 @@ namespace PlexRequests.UI.Modules
Available = tv.Available,
Admin = IsAdmin,
IssueId = tv.IssueId,
Denied = tv.Denied,
DeniedReason = tv.DeniedReason,
TvSeriesRequestType = tv.SeasonsRequested,
Qualities = qualities.ToArray(),
Episodes = tv.Episodes.ToArray(),
@ -290,6 +294,8 @@ namespace PlexRequests.UI.Modules
Available = album.Available,
Admin = IsAdmin,
IssueId = album.IssueId,
Denied = album.Denied,
DeniedReason = album.DeniedReason,
TvSeriesRequestType = album.SeasonsRequested,
MusicBrainzId = album.MusicBrainzId,
ArtistName = album.ArtistName

View file

@ -64,6 +64,7 @@ namespace PlexRequests.UI.Modules
a.TrackEventAsync(Category.Wizard, Action.Start, "Started the wizard", Username, CookieHelper.GetAnalyticClientId(Cookies));
var settings = await PlexRequestSettings.GetSettingsAsync();
if (settings.Wizard)
{
return Context.GetRedirect("~/search");