docs: #373 display verse language changes in poem edits history
This commit is contained in:
parent
dcf3f08508
commit
d408f114a5
@ -117,7 +117,7 @@ else
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
else if(verse.NewVerse)
|
||||
else if (verse.NewVerse)
|
||||
{
|
||||
if (verse.NewVerseResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
@ -147,8 +147,13 @@ else
|
||||
</tr>
|
||||
}
|
||||
|
||||
if(verse.SummaryReviewResult == CorrectionReviewResult.Approved)
|
||||
if (verse.SummaryReviewResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@verse.OriginalText
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
معنی: <p style="color:red">@verse.OriginalCoupletSummary</p>
|
||||
@ -160,23 +165,58 @@ else
|
||||
</tr>
|
||||
}
|
||||
|
||||
if (verse.VersePosition != null)
|
||||
if (verse.VersePosition != null && verse.VersePositionResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
if (verse.VersePositionResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<p>@verse.OriginalText</p>
|
||||
<p style="color:red">تبدیل نوع مصرع از @RMuseum.Models.Ganjoor.VersePositionHelper.GetVersePositionString((VersePosition)verse.OriginalVersePosition)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>@verse.Text</p>
|
||||
<p style="color:green">تبدیل نوع مصرع به @RMuseum.Models.Ganjoor.VersePositionHelper.GetVersePositionString((VersePosition)verse.VersePosition)</p>
|
||||
</td>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@verse.OriginalText
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
<p style="color:red">تبدیل نوع مصرع از @RMuseum.Models.Ganjoor.VersePositionHelper.GetVersePositionString((VersePosition)verse.OriginalVersePosition)</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>@verse.Text</p>
|
||||
<p style="color:green">تبدیل نوع مصرع به @RMuseum.Models.Ganjoor.VersePositionHelper.GetVersePositionString((VersePosition)verse.VersePosition)</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if (verse.LanguageId != null && verse.LanguageReviewResult == CorrectionReviewResult.Approved)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@verse.OriginalText
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@if (verse.OriginalLanguageId != null)
|
||||
{
|
||||
<p>تغییر زبان از @Model.Languages.Where(l => l.Id == verse.OriginalLanguageId).Single().Name </p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>تغییر زبان از فارسی</p>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
@if (verse.LanguageId != null)
|
||||
{
|
||||
<p>به @Model.Languages.Where(l => l.Id == verse.LanguageId).Single().Name </p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>به فارسی</p>
|
||||
}
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
}
|
||||
|
||||
<tr><td colspan="2" style="background-color:black"> </td></tr>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using RMuseum.Models.Ganjoor.ViewModels;
|
||||
using RSecurityBackend.Models.Generic;
|
||||
|
||||
@ -30,6 +31,19 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
/// Corrections
|
||||
/// </summary>
|
||||
public List<GanjoorPoemCorrectionViewModel> Corrections { get; set; }
|
||||
|
||||
public GanjoorLanguage[] Languages { get; set; }
|
||||
private async Task ReadLanguagesAsync(HttpClient secureClient)
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/translations/languages");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return;
|
||||
}
|
||||
|
||||
Languages = JsonConvert.DeserializeObject<GanjoorLanguage[]>(await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
|
||||
@ -39,97 +53,99 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
int pageNumber = 1;
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
int poemId = 0;
|
||||
if(!string.IsNullOrEmpty(Request.Query["id"]))
|
||||
{
|
||||
poemId = int.Parse(Request.Query["id"]);
|
||||
}
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/corrections/effective?PageNumber={pageNumber}&PageSize=20");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
int poemId = 0;
|
||||
if (!string.IsNullOrEmpty(Request.Query["id"]))
|
||||
{
|
||||
poemId = int.Parse(Request.Query["id"]);
|
||||
}
|
||||
var response = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/poem/{poemId}/corrections/effective?PageNumber={pageNumber}&PageSize=20");
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
Corrections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoemCorrectionViewModel>>();
|
||||
Corrections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoemCorrectionViewModel>>();
|
||||
|
||||
string paginnationMetadata = response.Headers.GetValues("paging-headers").FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(paginnationMetadata))
|
||||
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)
|
||||
{
|
||||
PaginationMetadata paginationMetadata = JsonConvert.DeserializeObject<PaginationMetadata>(paginnationMetadata);
|
||||
PaginationLinks = new List<NameIdUrlImage>();
|
||||
if (paginationMetadata.totalPages > 1)
|
||||
if (paginationMetadata.currentPage > 3)
|
||||
{
|
||||
if (paginationMetadata.currentPage > 3)
|
||||
{
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ اول",
|
||||
Url = "/User/PoemCorrectionsHistory?page=1"
|
||||
}
|
||||
);
|
||||
}
|
||||
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
|
||||
{
|
||||
if (i >= 1 && i <= paginationMetadata.totalPages)
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ اول",
|
||||
Url = "/User/PoemCorrectionsHistory?page=1"
|
||||
}
|
||||
);
|
||||
}
|
||||
for (int i = (paginationMetadata.currentPage - 2); i <= (paginationMetadata.currentPage + 2); i++)
|
||||
{
|
||||
if (i >= 1 && i <= paginationMetadata.totalPages)
|
||||
{
|
||||
if (i == paginationMetadata.currentPage)
|
||||
{
|
||||
if (i == paginationMetadata.currentPage)
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
}
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
Url = $"/User/PoemCorrectionsHistory?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = i.ToPersianNumbers(),
|
||||
Url = $"/User/PoemCorrectionsHistory?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = $"/User/PoemCorrectionsHistory?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = $"/User/PoemCorrectionsHistory?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
await ReadLanguagesAsync(secureClient);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -2052,6 +2052,8 @@ namespace RMuseum.Services.Implementation
|
||||
v.NewVerseResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
v.SummaryReviewResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
v.LanguageReviewResult == CorrectionReviewResult.Approved
|
||||
)
|
||||
)
|
||||
orderby dbCorrection.Id descending
|
||||
|
||||
Loading…
Reference in New Issue
Block a user