pull/531/head
tidusjar 8 years ago
parent 8df742abe3
commit 0ac114d987

@ -27,7 +27,7 @@ namespace PlexRequests.Store
public string Status { get; set; }
public bool Approved { get; set; }
[Obsolete("Use RequestedUsers")]
[Obsolete("Use RequestedUsers")] //TODO remove this obsolete property
public string RequestedBy { get; set; }
public DateTime RequestedDate { get; set; }
@ -44,6 +44,8 @@ namespace PlexRequests.Store
public string ArtistId { get; set; }
public int IssueId { get; set; }
public List<EpisodesModel> Episodes { get; set; }
public bool Denied { get; set; }
public string DeniedReason { get; set; }
[JsonIgnore]
public List<string> AllUsers

@ -373,6 +373,17 @@ $('#noteModal').on('show.bs.modal', function (event) {
requestField.val(id); // Add ID to the hidden field
});
// Update deny reason modal
$('#denyReasonModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget); // Button that triggered the modal
var id = button.data('identifier'); // Extract info from data-* attributes
var modal = $(this);
modal.find('.denySaveReason').val(id); // Add ID to the button
var requestField = modal.find('input');
requestField.val(id); // Add ID to the hidden field
});
// Delete
$(document).on("click", ".delete", function (e) {
e.preventDefault();
@ -403,28 +414,80 @@ $(document).on("click", ".delete", function (e) {
// Approve single request
$(document).on("click", ".approve", function (e) {
e.preventDefault();
var $this = $(this);
var $form = $this.parents('form').first();
var $self = $(this);
var $form = $self.parents('form').first();
if ($this.text() === " Loading...") {
if ($self.text() === " Loading...") {
return;
}
loadingButton($this.attr('id'), "success");
loadingButton($self.attr('id'), "success");
approveRequest($form, null, function () {
$("#" + $this.attr('id') + "notapproved").prop("class", "fa fa-check");
$("#" + $self.attr('id') + "notapproved").prop("class", "fa fa-check");
var $group = $this.parent('.btn-split');
var $group = $self.parent('.btn-split');
if ($group.length > 0) {
$group.remove();
}
else {
$this.remove();
$self.remove();
}
});
});
// Deny single request
$(document).on("click", ".deny", function (e) {
e.preventDefault();
var $self = $(this);
var $form = $self.parents('form').first();
if ($self.text() === " Loading...") {
return;
}
loadingButton($self.attr('id')+"deny", "success");
denyRequest($form, function () {
//$("#" + $self.attr('id') + "notapproved").prop("class", "fa fa-check");
var $group = $self.parent('.btn-split');
if ($group.length > 0) {
$group.remove();
}
else {
$self.remove();
}
});
});
// Deny single request with reason (modal)
$(document).on("click", ".denySaveReason", function (e) {
var comment = $("#denyReason").val();
e.preventDefault();
var $form = $("#denyReasonForm");
var data = $form.serialize();
data = data + "&reason=" + comment;
$.ajax({
type: $form.prop("method"),
url: $form.prop("action"),
data: data,
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
generateNotify(response.message, "success");
$("#denyReasonModal").modal("hide");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
$(document).on("click", ".approve-with-quality", function (e) {
e.preventDefault();
var $this = $(this);
@ -524,6 +587,35 @@ function approveRequest($form, qualityId, successCallback) {
});
}
function denyRequest($form, successCallback) {
var formData = $form.serialize();
$.ajax({
type: $form.prop('method'),
url: $form.prop('action'),
data: formData,
dataType: "json",
success: function (response) {
if (checkJsonResponse(response)) {
if (response.message) {
generateNotify(response.message, "success");
} else {
generateNotify("Success! Request Approved.", "success");
}
if (successCallback) {
successCallback();
}
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
}
function mixItUpConfig(activeState) {
var conf = mixItUpDefault;
@ -556,6 +648,11 @@ function movieLoad() {
var html = searchTemplate(context);
$ml.append(html);
});
$('.customTooltip').tooltipster({
contentCloning: true
});
}
else {
$ml.html(noResultsHtml.format("movie"));
@ -658,6 +755,8 @@ function buildRequestContext(result, type) {
hasQualities: result.qualities && result.qualities.length > 0,
artist: result.artistName,
musicBrainzId: result.musicBrainzId,
denied: result.denied,
deniedReason: result.deniedReason,
};
return context;

@ -55,5 +55,7 @@ namespace PlexRequests.UI.Models
public QualityModel[] Qualities { get; set; }
public string ArtistName { get; set; }
public Store.EpisodesModel[] Episodes { get; set; }
public bool Denied { get; set; }
public string DeniedReason { get; set; }
}
}

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

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

@ -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");

@ -1,4 +1,5 @@
@using Nancy.Security
@using Nancy.Security
@using PlexRequests.UI.Helpers
@using PlexRequests.UI.Resources
@{
@ -136,13 +137,13 @@
{{#if episodes}}
<div id="{{requestId}}toolTipContent">
{{#each episodes}}
Season: {{this.seasonNumber}}
<br />
Episodes Requested:
{{#each this.episodes}}
{{this}}
{{/each}}
<hr />
Season: {{this.seasonNumber}}
<br />
Episodes Requested:
{{#each this.episodes}}
{{this}}
{{/each}}
<hr />
{{/each}}
</div>
{{/if}}
@ -170,12 +171,21 @@
<span class="label label-success">{{status}}</span>
</div>
<br />
{{#if denied}}
<div>
Denied: <i style="color:red;" class="fa fa-check"></i>
{{#if deniedReason}}
<span class="customTooltip" title="{{deniedReason}}"><i class="fa fa-info-circle"></i></span>
{{/if}}
</div>
{{/if}}
{{#if_eq releaseDate "01/01/0001 00:00:00"}} <!--TheTVDB didn't provide any premier info-->
<div>@UI.Requests_ReleaseDate: {{releaseDate}}</div>
{{else}}
<div>@UI.Requests_ReleaseDate: {{releaseDate}}</div>
{{/if_eq}}
{{#unless denied}}
<div>
@UI.Common_Approved:
{{#if_eq approved false}}
@ -185,6 +195,7 @@
<i class="fa fa-check"></i>
{{/if_eq}}
</div>
{{/unless}}
<div>
@UI.Requests_Available
{{#if_eq available false}}
@ -216,6 +227,7 @@
</div>
<div class="col-sm-3 col-sm-push-3">
{{#if_eq admin true}}
{{#unless denied}}
{{#if_eq approved false}}
<form method="POST" action="@formAction/approval/approve" id="approve{{requestId}}">
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
@ -236,7 +248,22 @@
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
{{/if_eq}}
</form>
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
<input name="reason" type="text" hidden="hidden" />
<div class="btn-group btn-split">
<button type="button" class="btn btn-sm btn-danger-outline deny" id="{{requestId}}deny" custom-button="{{requestId}}"><i class="fa fa-times"></i> Deny</button>
<button type="button" class="btn btn-danger-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">@UI.Requests_ToggleDropdown</span>
</button>
<ul class="dropdown-menu">
<li><a class="deny-with-reason" id="denyReason{{requestId}}" href="#" data-toggle="modal" data-identifier="{{requestId}}" data-target="#denyReasonModal">Deny with a reason</a></li>
</ul>
</div>
</form>
{{/if_eq}}
{{/unless}}
<form method="POST" action="@formAction/requests/delete" id="delete{{requestId}}">
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
<button id="{{requestId}}" style="text-align: right" class="btn btn-sm btn-danger-outline delete" type="submit"><i class="fa fa-minus"></i> @UI.Common_Remove</button>
@ -324,6 +351,12 @@
<div>@UI.Requests_RequestedBy: {{requestedUsers}}</div>
{{/if}}
<div>@UI.Requests_RequestedDate: {{requestedDate}}</div>
{{#if denied}}
<div>Denied: <i class="fa fa-times"></i></div>
{{#if deniedReason}}
<div>Reason: {{deniedReason}}</div>
{{/if}}
{{/if}}
</div>
<div class="col-sm-2 col-sm-push-3">
{{#if_eq admin true}}
@ -332,6 +365,20 @@
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
<button id="{{requestId}}" custom-button="{{requestId}}" style="text-align: right" class="btn btn-sm btn-success-outline approve" type="submit"><i class="fa fa-plus"></i> @UI.Common_Approve</button>
</form>
<form method="POST" action="@formAction/approval/deny" id="deny{{requestId}}">
<input name="requestId" type="text" value="{{requestId}}" hidden="hidden" />
<input name="reason" type="text" hidden="hidden" />
<div class="btn-group btn-split">
<button type="button" class="btn btn-sm btn-danger-outline deny" id="{{requestId}}deny" custom-button="{{requestId}}"><i class="fa fa-times"></i> Deny</button>
<button type="button" class="btn btn-danger-outline dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">@UI.Requests_ToggleDropdown</span>
</button>
<ul class="dropdown-menu">
<li><a class="deny-with-reason" id="denyReason{{requestId}}" href="#" data-toggle="modal" data-identifier="{{requestId}}" data-target="#denyReasonModal">Deny with a reason</a></li>
</ul>
</div>
</form>
{{/if_eq}}
<form method="POST" action="@formAction/requests/delete" id="delete{{requestId}}">
<input name="Id" type="text" value="{{requestId}}" hidden="hidden" />
@ -393,6 +440,27 @@
</div>
</div>
<div class="modal fade" id="denyReasonModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times"></i></button>
<h4 class="modal-title">Deny with a reason</h4>
</div>
<form method="POST" action="@formAction/approval/deny" id="denyReasonForm">
<div class="modal-body">
<input name="requestId" class="requestId" type="text" hidden="hidden" value="" />
<textarea class="form-control form-control-custom" rows="3" id="denyReason" name="denyReason"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger-outline" data-dismiss="modal">@UI.Common_Close</button>
<button type="button" class="btn btn-primary-outline denySaveReason" data-dismiss="modal">@UI.Common_Save</button>
</div>
</form>
</div>
</div>
</div>
@Html.LoadRequestAssets()

Loading…
Cancel
Save