docs: #275 suggestion review UI
This commit is contained in:
parent
e9642dbd95
commit
c404fbd8d1
99
GanjooRazor/Areas/User/Pages/SuggestedPoetSpecLines.cshtml
Normal file
99
GanjooRazor/Areas/User/Pages/SuggestedPoetSpecLines.cshtml
Normal file
@ -0,0 +1,99 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.SuggestedPoetSpecLinesModel
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
ViewData["Title"] = "نکات پیشنهادی برای تصاویر شاعران";
|
||||
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
|
||||
}
|
||||
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@if (Model.LastError != "")
|
||||
{
|
||||
<h2>@Model.LastError</h2>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post">
|
||||
<table style="width:100%" class="noborder">
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">شاعر: </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="@Html.Raw(Model.Poet.FullUrl)" target="_blank">@Model.Poet.Nickname</a>
|
||||
<input type="hidden" asp-for="Suggestion.Id" />
|
||||
<input type="hidden" asp-for="Suggestion.PoetId" />
|
||||
<input type="hidden" asp-for="Suggestion.LineOrder" />
|
||||
<input type="hidden" asp-for="Suggestion.SuggestedById" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">پیشنهاد دهنده: </span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/hashieha/?userid=@Model.Suggestion.SuggestedById" target="_blank">@Model.Suggestion.SuggestedById</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<span class="inputlabel">نکته: </span>
|
||||
</td>
|
||||
<td>
|
||||
<textarea asp-for="Suggestion.Contents" class="editor"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="approve" id="approve" style="width:100%;color:white;background-color:green">تأیید</button>
|
||||
</td>
|
||||
<td>
|
||||
<table style="width:100%" class="noborder">
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="reject1" id="reject1" style="width:100%;color:white;background-color:darkred">در آهنگ این شعر خوانده نشده</button>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="reject1" id="reject1" style="width:100%;color:white;background-color:darkred">لینک یا اطلاعات آهنگ ایراد دارد</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="reject1" id="reject1" style="width:100%;color:white;background-color:darkred">رد به دلیل دیگر:</button>
|
||||
</td>
|
||||
<td>
|
||||
<input style="width:100%" asp-for="PoemMusicTrackViewModel.RejectionCause" /><br />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<button type="submit" name="next" id="next" style="width:100%;color:white;background-color:orange">بعدی</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
تعداد کل:
|
||||
</td>
|
||||
<td>
|
||||
@Model.TotalCount
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,90 @@
|
||||
using GanjooRazor.Utils;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
public class SuggestedPoetSpecLinesModel : PageModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// api model
|
||||
/// </summary>
|
||||
[BindProperty]
|
||||
public GanjoorPoetSuggestedSpecLineViewModel Suggestion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poet
|
||||
/// </summary>
|
||||
public GanjoorPoetViewModel Poet { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// skip
|
||||
/// </summary>
|
||||
public int Skip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// total count
|
||||
/// </summary>
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public async Task OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
TotalCount = 0;
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var suggestionResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/poetspecs/unpublished/next?skip={Skip}");
|
||||
if (!suggestionResponse.IsSuccessStatusCode)
|
||||
{
|
||||
if(suggestionResponse.StatusCode == System.Net.HttpStatusCode.NotFound )
|
||||
{
|
||||
LastError = "مورد دیگری وجود ندارد.";
|
||||
}
|
||||
LastError = JsonConvert.DeserializeObject<string>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
string paginnationMetadata = suggestionResponse.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
TotalCount = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata).totalCount;
|
||||
}
|
||||
|
||||
|
||||
Suggestion = JsonConvert.DeserializeObject<GanjoorPoetSuggestedSpecLineViewModel>(await suggestionResponse.Content.ReadAsStringAsync());
|
||||
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poet/{Suggestion.PoetId}");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return;
|
||||
}
|
||||
|
||||
var poet = JsonConvert.DeserializeObject<GanjoorPoetCompleteViewModel>(await response.Content.ReadAsStringAsync());
|
||||
Poet = poet.Poet;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -311,6 +311,14 @@
|
||||
</li>
|
||||
}
|
||||
|
||||
|
||||
@if (ViewData.ContainsKey($"{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.GanjoorEntityShortName}-{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.ModeratePoetPhotos}"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/SuggestedPoetSpecLines">نکات پیشنهادی</a>
|
||||
</li>
|
||||
}
|
||||
|
||||
@if (ViewData.ContainsKey($"{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.GanjoorEntityShortName}-{RMuseum.Models.Auth.Memory.RMuseumSecurableItem.ModifyOperationShortName}"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using RMuseum.Models.Auth.Memory;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RMuseum.Services;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
@ -49,6 +51,26 @@ namespace RMuseum.Controllers
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
|
||||
var resCount = await _ganjoorService.GetNextUnmoderatedPoetSuggestedSpecLinesCountAsync();
|
||||
if (!string.IsNullOrEmpty(resCount.ExceptionString))
|
||||
return BadRequest(resCount.ExceptionString);
|
||||
|
||||
// Paging Header
|
||||
HttpContext.Response.Headers.Add("paging-headers",
|
||||
JsonConvert.SerializeObject(
|
||||
new PaginationMetadata()
|
||||
{
|
||||
totalCount = resCount.Result,
|
||||
pageSize = -1,
|
||||
currentPage = -1,
|
||||
hasNextPage = false,
|
||||
hasPreviousPage = false,
|
||||
totalPages = -1
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
|
||||
@ -10510,6 +10510,12 @@
|
||||
<param name="skip"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetNextUnmoderatedPoetSuggestedSpecLinesCountAsync">
|
||||
<summary>
|
||||
npublished suggested lines count for poets
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.AddPoetSuggestedSpecLinesAsync(RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetSuggestedSpecLineViewModel)">
|
||||
<summary>
|
||||
add a suggestion for poets spec lines
|
||||
@ -11939,6 +11945,12 @@
|
||||
<param name="skip"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetNextUnmoderatedPoetSuggestedSpecLinesCountAsync">
|
||||
<summary>
|
||||
npublished suggested lines count for poets
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.AddPoetSuggestedSpecLinesAsync(RMuseum.Models.Ganjoor.ViewModels.GanjoorPoetSuggestedSpecLineViewModel)">
|
||||
<summary>
|
||||
add a suggestion for poets spec lines
|
||||
|
||||
@ -756,6 +756,12 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoetSuggestedSpecLineViewModel>> GetNextUnmoderatedPoetSuggestedSpecLineAsync(int skip);
|
||||
|
||||
/// <summary>
|
||||
/// npublished suggested lines count for poets
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<int>> GetNextUnmoderatedPoetSuggestedSpecLinesCountAsync();
|
||||
|
||||
/// <summary>
|
||||
/// add a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
|
||||
@ -114,7 +114,7 @@ namespace RMuseum.Services.Implementation
|
||||
Published = r.Published,
|
||||
SuggestedById = r.SuggestedById
|
||||
}
|
||||
).SingleOrDefaultAsync()
|
||||
).FirstOrDefaultAsync()
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
@ -123,6 +123,30 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// npublished suggested lines count for poets
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<int>> GetNextUnmoderatedPoetSuggestedSpecLinesCountAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return new RServiceResult<int>
|
||||
(
|
||||
await _context.GanjoorPoetSuggestedSpecLines
|
||||
.Where
|
||||
(
|
||||
r => r.Published == false
|
||||
)
|
||||
.CountAsync()
|
||||
);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<int>(0, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// add a suggestion for poets spec lines
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user