#186 showing user suggested corrections and result in their panel
This commit is contained in:
parent
5975f5dcc6
commit
42c515b125
176
GanjooRazor/Areas/User/Pages/Edits.cshtml
Normal file
176
GanjooRazor/Areas/User/Pages/Edits.cshtml
Normal file
@ -0,0 +1,176 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.EditsModel
|
||||
@using RMuseum.Models.Ganjoor
|
||||
@using RMuseum.Services.Implementation
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
ViewData["Title"] = "ویرایشهای من";
|
||||
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
|
||||
string color = "gray";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@if (Model.LastError != "")
|
||||
{
|
||||
<h2>@Model.LastError</h2>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p style="text-align:center">
|
||||
@foreach (var paginationLink in Model.PaginationLinks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(paginationLink.Url))
|
||||
{
|
||||
<a href="@paginationLink.Url">@paginationLink.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@paginationLink.Name
|
||||
}
|
||||
}
|
||||
</p>
|
||||
|
||||
@foreach (var correction in Model.Corrections)
|
||||
{
|
||||
if (color == "gray")
|
||||
color = "white";
|
||||
else
|
||||
color = "gray";
|
||||
|
||||
<div style="background-color:@color" id="correction-@correction.Id">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3"><a href="/?p=@correction.PoemId" target="_blank">مشاهدهٔ متن شعر یا بخش</a></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>متن اولیه</td>
|
||||
<td>تغییرات من</td>
|
||||
<td>نتیجهٔ بررسی</td>
|
||||
</tr>
|
||||
|
||||
@if (correction.Title != null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@correction.OriginalTitle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@correction.Title</p>
|
||||
</td>
|
||||
<td>
|
||||
@if (correction.Result == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:blue">@CorrectionReviewResultConvertor.GetString(correction.Result)</p>
|
||||
}
|
||||
else
|
||||
@if (correction.Result == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:green">@CorrectionReviewResultConvertor.GetString(correction.Result)</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p style="color:red">@CorrectionReviewResultConvertor.GetString(correction.Result)</p>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (correction.Rhythm != null)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@correction.OriginalRhythm</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@correction.Rhythm</p>
|
||||
</td>
|
||||
<td>
|
||||
@if (correction.RhythmResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:blue">@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)</p>
|
||||
}
|
||||
else
|
||||
@if (correction.RhythmResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:green">@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p style="color:red">@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)</p>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (correction.VerseOrderText != null)
|
||||
@foreach (var verse in correction.VerseOrderText)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<p style="color:red">@verse.OriginalText</p>
|
||||
</td>
|
||||
<td>
|
||||
<p style="color:green">@verse.Text</p>
|
||||
</td>
|
||||
<td>
|
||||
@if (verse.Result == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:blue">@CorrectionReviewResultConvertor.GetString(verse.Result)</p>
|
||||
}
|
||||
else
|
||||
@if (verse.Result == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<p style="color:green">@CorrectionReviewResultConvertor.GetString(verse.Result)</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p style="color:red">@CorrectionReviewResultConvertor.GetString(verse.Result)</p>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(correction.Note))
|
||||
{
|
||||
<tr>
|
||||
<td>یادداشت:</td>
|
||||
<td>
|
||||
@correction.Note
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
@if (correction.Reviewed)
|
||||
{
|
||||
<a role="button" style="cursor:pointer;width:100%;color:white;background-color:red;display:block" href="/User/Editor?id=@correction.PoemId">ویرایش مجدد</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a role="button" style="cursor:pointer;width:100%;color:white;background-color:blue;display:block" href="/User/Editor?id=@correction.PoemId">مشاهده</a>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<hr />
|
||||
}
|
||||
|
||||
<p style="text-align:center">
|
||||
@foreach (var paginationLink in Model.PaginationLinks)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(paginationLink.Url))
|
||||
{
|
||||
<a href="@paginationLink.Url">@paginationLink.Name</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
@paginationLink.Name
|
||||
}
|
||||
}
|
||||
</p>
|
||||
|
||||
|
||||
}
|
||||
135
GanjooRazor/Areas/User/Pages/Edits.cshtml.cs
Normal file
135
GanjooRazor/Areas/User/Pages/Edits.cshtml.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using DNTPersianUtils.Core;
|
||||
using GanjooRazor.Utils;
|
||||
using GSpotifyProxy.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
[IgnoreAntiforgeryToken(Order = 1001)]
|
||||
public class EditsModel : PageModel
|
||||
{
|
||||
// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pagination links
|
||||
/// </summary>
|
||||
public List<NameIdUrlImage> PaginationLinks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Corrections
|
||||
/// </summary>
|
||||
public List<GanjoorPoemCorrectionViewModel> Corrections { get; set; }
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
LastError = "";
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
{
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/corrections/mine?PageNumber={pageNumber}&PageSize=20");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = await response.Content.ReadAsStringAsync();
|
||||
return Page();
|
||||
}
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
Corrections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoemCorrectionViewModel>>();
|
||||
|
||||
string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
{
|
||||
PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata);
|
||||
PaginationLinks = new List<NameIdUrlImage>();
|
||||
if (paginationMetadata.totalPages > 1)
|
||||
{
|
||||
if (paginationMetadata.currentPage > 3)
|
||||
{
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ اول",
|
||||
Url = "/User/Edits/?page=1"
|
||||
}
|
||||
);
|
||||
}
|
||||
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
|
||||
{
|
||||
if (i >= 1 && i <= paginationMetadata.totalPages)
|
||||
{
|
||||
if (i == paginationMetadata.currentPage)
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
Url = $"/User/Edits/?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = $"/User/Edits/?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,6 +306,10 @@
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/Notifications">اعلانهای من</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/Edits">ویرایشهای من</a>
|
||||
</li>
|
||||
|
||||
@if (ViewData.ContainsKey("ganjoor-songrevu"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
|
||||
@ -8794,6 +8794,18 @@
|
||||
<param name="format"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.Implementation.CorrectionReviewResultConvertor">
|
||||
<summary>
|
||||
تبدیلگر CorrectionReviewResult
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult)">
|
||||
<summary>
|
||||
تبدیل به رشته
|
||||
</summary>
|
||||
<param name="reviewResult"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.Implementation.DonationService">
|
||||
<summary>
|
||||
donation service
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
using RMuseum.Models.Ganjoor;
|
||||
|
||||
namespace RMuseum.Services.Implementation
|
||||
{
|
||||
/// <summary>
|
||||
/// تبدیلگر CorrectionReviewResult
|
||||
/// </summary>
|
||||
public static class CorrectionReviewResultConvertor
|
||||
{
|
||||
/// <summary>
|
||||
/// تبدیل به رشته
|
||||
/// </summary>
|
||||
/// <param name="reviewResult"></param>
|
||||
/// <returns></returns>
|
||||
public static string GetString(CorrectionReviewResult reviewResult)
|
||||
{
|
||||
switch(reviewResult)
|
||||
{
|
||||
case CorrectionReviewResult.Approved:
|
||||
return "تأیید میشود";
|
||||
case CorrectionReviewResult.NotChanged:
|
||||
return "تغییری نکرده";
|
||||
case CorrectionReviewResult.RejectedBecauseWrong:
|
||||
return "درست نیست";
|
||||
case CorrectionReviewResult.RejectedBecauseVariant:
|
||||
return "مربوط به نسخهٔ دیگری است";
|
||||
case CorrectionReviewResult.RejectedBecauseUnnecessaryChange:
|
||||
return "تغییر سلیقهای یا بی دلیل است";
|
||||
case CorrectionReviewResult.Rejected:
|
||||
return "به دلیل دیگری رد میشود";
|
||||
}
|
||||
return "بررسی نشده";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1420,28 +1420,38 @@ namespace RMuseum.Services.Implementation
|
||||
where dbCorrection.UserId == userId
|
||||
orderby dbCorrection.Id descending
|
||||
select
|
||||
new GanjoorPoemCorrectionViewModel()
|
||||
{
|
||||
Id = dbCorrection.Id,
|
||||
PoemId = dbCorrection.PoemId,
|
||||
UserId = dbCorrection.UserId,
|
||||
VerseOrderText = dbCorrection.VerseOrderText == null ? null : dbCorrection.VerseOrderText.ToArray(),
|
||||
Title = dbCorrection.Title,
|
||||
OriginalTitle = dbCorrection.OriginalTitle,
|
||||
Rhythm = dbCorrection.Rhythm,
|
||||
OriginalRhythm = dbCorrection.OriginalRhythm,
|
||||
Note = dbCorrection.Note,
|
||||
Date = dbCorrection.Date,
|
||||
Reviewed = dbCorrection.Reviewed,
|
||||
Result = dbCorrection.Result,
|
||||
RhythmResult = dbCorrection.RhythmResult,
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
|
||||
};
|
||||
dbCorrection;
|
||||
|
||||
(PaginationMetadata, GanjoorPoemCorrectionViewModel[]) paginatedResult =
|
||||
await QueryablePaginator<GanjoorPoemCorrectionViewModel>.Paginate(source, paging);
|
||||
(PaginationMetadata PagingMeta, GanjoorPoemCorrection[] Items) dbPaginatedResult =
|
||||
await QueryablePaginator<GanjoorPoemCorrection>.Paginate(source, paging);
|
||||
|
||||
return new RServiceResult<(PaginationMetadata, GanjoorPoemCorrectionViewModel[])>(paginatedResult);
|
||||
List<GanjoorPoemCorrectionViewModel> list = new List<GanjoorPoemCorrectionViewModel>();
|
||||
foreach (var dbCorrection in dbPaginatedResult.Items)
|
||||
{
|
||||
list.Add
|
||||
(
|
||||
new GanjoorPoemCorrectionViewModel()
|
||||
{
|
||||
Id = dbCorrection.Id,
|
||||
PoemId = dbCorrection.PoemId,
|
||||
UserId = dbCorrection.UserId,
|
||||
VerseOrderText = dbCorrection.VerseOrderText == null ? null : dbCorrection.VerseOrderText.ToArray(),
|
||||
Title = dbCorrection.Title,
|
||||
OriginalTitle = dbCorrection.OriginalTitle,
|
||||
Rhythm = dbCorrection.Rhythm,
|
||||
OriginalRhythm = dbCorrection.OriginalRhythm,
|
||||
Note = dbCorrection.Note,
|
||||
Date = dbCorrection.Date,
|
||||
Reviewed = dbCorrection.Reviewed,
|
||||
Result = dbCorrection.Result,
|
||||
RhythmResult = dbCorrection.RhythmResult,
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return new RServiceResult<(PaginationMetadata, GanjoorPoemCorrectionViewModel[])>
|
||||
((dbPaginatedResult.PagingMeta, list.ToArray()));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user