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

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

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

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

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

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

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

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

@ -178,17 +178,13 @@
<div>Requested By: {{requestedUsers}}</div>
{{/if}}
<div>Requested Date: {{requestedDate}}</div>
<div id="issueArea{{requestId}}">
{{#if otherMessage}}
<div>Message: {{otherMessage}}</div>
<div>
Issue:
{{#if_eq issueId 0}}
<i class="fa fa-times"></i>
{{else}}
<div>Issue: {{issues}}</div>
{{/if}}
</div>
<div id="adminNotesArea{{requestId}}">
{{#if adminNote}}
<div>Note from Admin: {{adminNote}}</div>
{{/if}}
<a href="/issues/{{issueId}}"><i class="fa fa-check"></i></a>
{{/if_eq}}
</div>
</div>
<div class="col-sm-3 col-sm-push-3">

@ -39,7 +39,7 @@
<ul class="nav navbar-nav">
@Html.GetNavbarUrl(Context, "/search", "Search", "search")
@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 class="nav navbar-nav navbar-right">
@ -133,7 +133,9 @@
dataType: "json",
success: function (response) {
if (response) {
$('#issueCount').html(response);
if(response > 0)
$('#issueCount').addClass("badge");
$('#issueCount').html(+response);
}
},
error: function (e) {

Loading…
Cancel
Save