pull/332/head
tidusjar 9 years ago
parent 6067a4743e
commit 9ffe184dd3

@ -25,19 +25,15 @@
// ************************************************************************/ // ************************************************************************/
#endregion #endregion
using System; using System;
using System.Collections.Generic;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
using PlexRequests.Api.Interfaces; using PlexRequests.Api.Interfaces;
using PlexRequests.Api.Models.Plex;
using PlexRequests.Core; using PlexRequests.Core;
using PlexRequests.Core.SettingModels; using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers.Exceptions;
using PlexRequests.Services.Interfaces; using PlexRequests.Services.Interfaces;
using PlexRequests.Store;
using PlexRequests.Helpers; using PlexRequests.Helpers;
using PlexRequests.Services.Jobs; using PlexRequests.Services.Jobs;
using PlexRequests.Store.Models; using PlexRequests.Store.Models;

@ -152,7 +152,6 @@ namespace PlexRequests.Services.Jobs
if (names.Length > 1) if (names.Length > 1)
{ {
DateTime parsed; DateTime parsed;
//DateTime.TryParseExcat(names[1], "yyyy-MM-dd hh.mm.ss",CultureInfo.CurrentUICulture, DateTimeStyles.None, out parsed);
DateTime.TryParse(names[2], out parsed); DateTime.TryParse(names[2], out parsed);
return parsed; return parsed;

@ -654,10 +654,8 @@ function buildRequestContext(result, type) {
released: result.released, released: result.released,
available: result.available, available: result.available,
admin: result.admin, admin: result.admin,
issues: result.issues, issueId: result.issueId,
otherMessage: result.otherMessage,
requestId: result.id, requestId: result.id,
adminNote: result.adminNotes,
imdb: result.imdbId, imdb: result.imdbId,
seriesRequested: result.tvSeriesRequestType, seriesRequested: result.tvSeriesRequestType,
coverArtUrl: result.coverArtUrl, coverArtUrl: result.coverArtUrl,

@ -49,9 +49,7 @@ namespace PlexRequests.UI.Models
public string ReleaseYear { get; set; } public string ReleaseYear { get; set; }
public bool Available { get; set; } public bool Available { get; set; }
public bool Admin { get; set; } public bool Admin { get; set; }
public string Issues { get; set; } public int IssueId { get; set; }
public string OtherMessage { get; set; }
public string AdminNotes { get; set; }
public string TvSeriesRequestType { get; set; } public string TvSeriesRequestType { get; set; }
public string MusicBrainzId { get; set; } public string MusicBrainzId { get; set; }
public QualityModel[] Qualities { get; set; } public QualityModel[] Qualities { get; set; }

@ -87,21 +87,21 @@ namespace PlexRequests.UI.Modules
protected BaseAuthModule(ISettingsService<PlexRequestSettings> pr) : base(pr) protected BaseAuthModule(ISettingsService<PlexRequestSettings> pr) : base(pr)
{ {
Service = pr; PlexRequestSettings = pr;
Before += (ctx) => CheckAuth(); Before += (ctx) => CheckAuth();
} }
protected BaseAuthModule(string modulePath, ISettingsService<PlexRequestSettings> pr) : base(modulePath, pr) protected BaseAuthModule(string modulePath, ISettingsService<PlexRequestSettings> pr) : base(modulePath, pr)
{ {
Service = pr; PlexRequestSettings = pr;
Before += (ctx) => CheckAuth(); Before += (ctx) => CheckAuth();
} }
private ISettingsService<PlexRequestSettings> Service { get; } protected ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
private Response CheckAuth() private Response CheckAuth()
{ {
var settings = Service.GetSettings(); var settings = PlexRequestSettings.GetSettings();
var baseUrl = settings.BaseUrl; var baseUrl = settings.BaseUrl;
var redirectPath = string.IsNullOrEmpty(baseUrl) ? "~/userlogin" : $"~/{baseUrl}/userlogin"; 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 System.Threading.Tasks;
using Nancy; using Nancy;
@ -23,7 +25,7 @@ namespace PlexRequests.UI.Modules
Get["/issuecount", true] = async (x, ct) => await IssueCount(); 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["/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); 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() public async Task<Response> IssueCount()
{ {
var issues = await IssuesService.GetAllAsync(); 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); return Response.AsJson(count);
} }
public async Task<Negotiator> Details(int id) public async Task<Negotiator> Details(int id)
{ {
var issue = await IssuesService.GetAsync(id); var issue = await IssuesService.GetAsync(id);
return issue == null return issue == null

@ -76,7 +76,7 @@ namespace PlexRequests.UI.Modules
Get["/"] = _ => LoadRequests(); Get["/"] = _ => LoadRequests();
Get["/movies", true] = async (x, ct) => await GetMovies(); Get["/movies", true] = async (x, ct) => await GetMovies();
Get["/tvshows", true] = async (c, ct) => await GetTvShows(); 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["/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["/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); 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(), ReleaseYear = movie.ReleaseDate.Year.ToString(),
Available = movie.Available, Available = movie.Available,
Admin = IsAdmin, Admin = IsAdmin,
Issues = movie.Issues.ToString().CamelCaseToWords(), IssueId = movie.IssueId,
OtherMessage = movie.OtherMessage,
AdminNotes = movie.AdminNote,
Qualities = qualities.ToArray() Qualities = qualities.ToArray()
}).ToList(); }).ToList();
@ -223,9 +221,7 @@ namespace PlexRequests.UI.Modules
ReleaseYear = tv.ReleaseDate.Year.ToString(), ReleaseYear = tv.ReleaseDate.Year.ToString(),
Available = tv.Available, Available = tv.Available,
Admin = IsAdmin, Admin = IsAdmin,
Issues = tv.Issues.ToString().CamelCaseToWords(), IssueId = tv.IssueId,
OtherMessage = tv.OtherMessage,
AdminNotes = tv.AdminNote,
TvSeriesRequestType = tv.SeasonsRequested, TvSeriesRequestType = tv.SeasonsRequested,
Qualities = qualities.ToArray() Qualities = qualities.ToArray()
}; };
@ -266,9 +262,7 @@ namespace PlexRequests.UI.Modules
ReleaseYear = album.ReleaseDate.Year.ToString(), ReleaseYear = album.ReleaseDate.Year.ToString(),
Available = album.Available, Available = album.Available,
Admin = IsAdmin, Admin = IsAdmin,
Issues = album.Issues.ToString().CamelCaseToWords(), IssueId = album.IssueId,
OtherMessage = album.OtherMessage,
AdminNotes = album.AdminNote,
TvSeriesRequestType = album.SeasonsRequested, TvSeriesRequestType = album.SeasonsRequested,
MusicBrainzId = album.MusicBrainzId, MusicBrainzId = album.MusicBrainzId,
ArtistName = album.ArtistName ArtistName = album.ArtistName

@ -510,6 +510,9 @@
<Content Include="Views\Admin\SlackNotifications.cshtml"> <Content Include="Views\Admin\SlackNotifications.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Views\Issues\Index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Web.Debug.config"> <None Include="Web.Debug.config">
<DependentUpon>web.config</DependentUpon> <DependentUpon>web.config</DependentUpon>
</None> </None>

@ -178,17 +178,13 @@
<div>Requested By: {{requestedUsers}}</div> <div>Requested By: {{requestedUsers}}</div>
{{/if}} {{/if}}
<div>Requested Date: {{requestedDate}}</div> <div>Requested Date: {{requestedDate}}</div>
<div id="issueArea{{requestId}}"> <div>
{{#if otherMessage}} Issue:
<div>Message: {{otherMessage}}</div> {{#if_eq issueId 0}}
<i class="fa fa-times"></i>
{{else}} {{else}}
<div>Issue: {{issues}}</div> <a href="/issues/{{issueId}}"><i class="fa fa-check"></i></a>
{{/if}} {{/if_eq}}
</div>
<div id="adminNotesArea{{requestId}}">
{{#if adminNote}}
<div>Note from Admin: {{adminNote}}</div>
{{/if}}
</div> </div>
</div> </div>
<div class="col-sm-3 col-sm-push-3"> <div class="col-sm-3 col-sm-push-3">
@ -405,7 +401,7 @@
</div> </div>
<form method="POST" action="@formAction/requests/addnote" id="noteForm"> <form method="POST" action="@formAction/requests/addnote" id="noteForm">
<div class="modal-body"> <div class="modal-body">
<input name="requestId" class="noteId" type="text" hidden="hidden" value=""/> <input name="requestId" class="noteId" type="text" hidden="hidden" value="" />
<textarea class="form-control form-control-custom" rows="3" id="noteArea" name="noteArea"></textarea> <textarea class="form-control form-control-custom" rows="3" id="noteArea" name="noteArea"></textarea>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

@ -39,7 +39,7 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
@Html.GetNavbarUrl(Context, "/search", "Search", "search") @Html.GetNavbarUrl(Context, "/search", "Search", "search")
@Html.GetNavbarUrl(Context, "/requests", "Requests", "plus-circle") @Html.GetNavbarUrl(Context, "/requests", "Requests", "plus-circle")
@Html.GetNavbarUrl(Context, "/issues", "Issues", "exclamation", "<span id=\"issueCount\" class=\"badge\">0</span>") @Html.GetNavbarUrl(Context, "/issues", "Issues", "exclamation", "<span id=\"issueCount\"></span>")
</ul> </ul>
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
@ -133,7 +133,9 @@
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response) { if (response) {
$('#issueCount').html(response); if(response > 0)
$('#issueCount').addClass("badge");
$('#issueCount').html(+response);
} }
}, },
error: function (e) { error: function (e) {

Loading…
Cancel
Save