docs: #319 displaying list of user section corrections
This commit is contained in:
parent
e4ac771e25
commit
ede6a1d2ee
@ -53,11 +53,11 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
{
|
||||
{
|
||||
int pageNumber = 1;
|
||||
string url = $"{APIRoot.Url}/api/ganjoor/corrections/mine?PageNumber={pageNumber}&PageSize=20";
|
||||
if (!string.IsNullOrEmpty(Request.Query["page"]))
|
||||
{
|
||||
pageNumber = int.Parse(Request.Query["page"]);
|
||||
}
|
||||
string url = $"{APIRoot.Url}/api/ganjoor/corrections/mine?PageNumber={pageNumber}&PageSize=20";
|
||||
if (CanEdit)
|
||||
{
|
||||
AllUsersEdits = Request.Query["AllUsers"] == "1";
|
||||
|
||||
189
GanjooRazor/Areas/User/Pages/SectionEdits.cshtml
Normal file
189
GanjooRazor/Areas/User/Pages/SectionEdits.cshtml
Normal file
@ -0,0 +1,189 @@
|
||||
@page
|
||||
@model GanjooRazor.Areas.User.Pages.SectionEditsModel
|
||||
@using RMuseum.Models.Ganjoor
|
||||
@using RMuseum.Services.Implementation
|
||||
@{
|
||||
Layout = "_UserPanelLayout";
|
||||
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
|
||||
{
|
||||
|
||||
if (@Model.CanEdit)
|
||||
{
|
||||
<div class="clear-both">
|
||||
<p>
|
||||
<a role="button" href="/User/SectionEdits?AllUsers=1" class="pagebutton">ویرایشهای قطعات همه</a>
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (Model.Corrections.Count == 0)
|
||||
{
|
||||
<p>
|
||||
شما هنوز هیچ ویرایشی در گنجور انجام ندادهاید. برای آشنایی با نحوهٔ ویرایش اشعار <a href="https://blog.ganjoor.net/1400/05/23/notes-for-suggesting-corrections/" target="_blank">اینجا</a> را ببینید.
|
||||
</p>
|
||||
}
|
||||
|
||||
|
||||
<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="/User/Section?poemId=@correction.PoemId&index=@correction.SectionIndex" target="_blank">مشاهدهٔ متن شعر یا بخش</a></td>
|
||||
</tr>
|
||||
|
||||
@if (Model.AllUsersEdits)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="3"><a href="/hashieha/?userid=@correction.UserId" target="_blank">@correction.UserNickname</a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
<tr>
|
||||
<td>متن اولیه</td>
|
||||
<td>تغییرات من</td>
|
||||
<td>نتیجهٔ بررسی</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 (!string.IsNullOrEmpty(correction.ReviewNote))
|
||||
{
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<p>@correction.ReviewNote</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
}
|
||||
|
||||
@if (
|
||||
correction.BreakFromVerse1VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse2VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse3VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse4VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse5VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse6VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse7VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse8VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse9VOrderResult == CorrectionReviewResult.Approved
|
||||
||
|
||||
correction.BreakFromVerse10VOrderResult == CorrectionReviewResult.Approved
|
||||
)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<p>پیشنهاد شما برای شکستن قطعه تأیید شده است.</p>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if (!string.IsNullOrEmpty(correction.Note))
|
||||
{
|
||||
<tr>
|
||||
<td>یادداشت:</td>
|
||||
<td colspan="2">
|
||||
@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/Section?poemId=@correction.PoemId&index=@correction.SectionIndex">ویرایش مجدد</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a role="button" style="cursor:pointer;width:100%;color:white;background-color:blue;display:block" href="/User/Section?poemId=@correction.PoemId&index=@correction.SectionIndex">مشاهده</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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
158
GanjooRazor/Areas/User/Pages/SectionEdits.cshtml.cs
Normal file
158
GanjooRazor/Areas/User/Pages/SectionEdits.cshtml.cs
Normal file
@ -0,0 +1,158 @@
|
||||
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 SectionEditsModel : PageModel
|
||||
{ /// <summary>
|
||||
/// Last Error
|
||||
/// </summary>
|
||||
public string LastError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// pagination links
|
||||
/// </summary>
|
||||
public List<NameIdUrlImage> PaginationLinks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// can edit
|
||||
/// </summary>
|
||||
public bool CanEdit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// all users edits
|
||||
/// </summary>
|
||||
public bool AllUsersEdits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Corrections
|
||||
/// </summary>
|
||||
public List<GanjoorPoemSectionCorrectionViewModel> Corrections { get; set; }
|
||||
public async Task<IActionResult> OnGetAsync()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Request.Cookies["Token"]))
|
||||
return Redirect("/");
|
||||
CanEdit = Request.Cookies["CanEdit"] == "True";
|
||||
AllUsersEdits = false;
|
||||
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"]);
|
||||
}
|
||||
string url = $"{APIRoot.Url}/api/ganjoor/section/corrections/mine?PageNumber={pageNumber}&PageSize=20";
|
||||
|
||||
if (CanEdit)
|
||||
{
|
||||
AllUsersEdits = Request.Query["AllUsers"] == "1";
|
||||
if (AllUsersEdits)
|
||||
{
|
||||
url = $"{APIRoot.Url}/api/ganjoor/section/corrections/all?PageNumber={pageNumber}&PageSize=20";
|
||||
}
|
||||
}
|
||||
var response = await secureClient.GetAsync(url);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LastError = JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync());
|
||||
return Page();
|
||||
}
|
||||
|
||||
Corrections = JArray.Parse(await response.Content.ReadAsStringAsync()).ToObject<List<GanjoorPoemSectionCorrectionViewModel>>();
|
||||
|
||||
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 = AllUsersEdits ? "/User/SectionEdits/?page=1&AllUsers=1" : "/User/SectionEdits/?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 = AllUsersEdits ? $"/User/SectionEdits/?page={i}&AllUsers=1" : $"/User/SectionEdits/?page={i}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (paginationMetadata.totalPages > (paginationMetadata.currentPage + 2))
|
||||
{
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "... ",
|
||||
}
|
||||
);
|
||||
|
||||
PaginationLinks.Add
|
||||
(
|
||||
new NameIdUrlImage()
|
||||
{
|
||||
Name = "صفحهٔ آخر",
|
||||
Url = AllUsersEdits ? $"/User/SectionEdits/?page={paginationMetadata.totalPages}&AllUsers=1" : $"/User/SectionEdits/?page={paginationMetadata.totalPages}"
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LastError = "لطفا از گنجور خارج و مجددا به آن وارد شوید.";
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,4 +22,16 @@
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<UpToDateCheckInput Remove="Areas\User\Pages\SectionEdits.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Areas\User\Pages\SectionEdits.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="Areas\User\Pages\SectionEdits.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -17,17 +17,17 @@
|
||||
<script src="/lib/tinymce/tinymce.min.js"></script>
|
||||
<script>
|
||||
tinymce.init({
|
||||
selector: 'textarea.editor',
|
||||
language: 'fa_IR',
|
||||
menubar: false,
|
||||
plugins: 'link paste image',
|
||||
toolbar: 'undo redo | alignleft aligncenter alignright alignjustify | link',
|
||||
paste_auto_cleanup_on_paste: true,
|
||||
paste_remove_styles: true,
|
||||
paste_remove_styles_if_webkit: true,
|
||||
paste_strip_class_attributes: true,
|
||||
a11y_advanced_options: true
|
||||
});
|
||||
selector: 'textarea.editor',
|
||||
language: 'fa_IR',
|
||||
menubar: false,
|
||||
plugins: 'link paste image',
|
||||
toolbar: 'undo redo | alignleft aligncenter alignright alignjustify | link',
|
||||
paste_auto_cleanup_on_paste: true,
|
||||
paste_remove_styles: true,
|
||||
paste_remove_styles_if_webkit: true,
|
||||
paste_strip_class_attributes: true,
|
||||
a11y_advanced_options: true
|
||||
});
|
||||
</script>
|
||||
<script src="/lib/diff.js"></script>
|
||||
<script src="/js/bk.js?version=27"></script>
|
||||
@ -60,10 +60,6 @@
|
||||
<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>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/UpVotedRecitations">خوانشهای نشان شده</a>
|
||||
</li>
|
||||
@ -76,6 +72,14 @@
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/MySuggestedSongs">آهنگهای پیشنهادی من</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/Edits">ویرایشهای من</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="User" asp-page="/SectionEdits">ویرایشهای قطعات من</a>
|
||||
</li>
|
||||
|
||||
@if (ViewData.ContainsKey("ganjoor-songrevu"))
|
||||
{
|
||||
<li class="nav-item">
|
||||
|
||||
@ -184,5 +184,15 @@ namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
/// review note
|
||||
/// </summary>
|
||||
public string ReviewNote { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poem Id
|
||||
/// </summary>
|
||||
public int PoemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// poem Id
|
||||
/// </summary>
|
||||
public int SectionIndex { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -9338,6 +9338,16 @@
|
||||
review note
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemSectionCorrectionViewModel.PoemId">
|
||||
<summary>
|
||||
poem Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemSectionCorrectionViewModel.SectionIndex">
|
||||
<summary>
|
||||
poem Id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorPoemSummaryViewModel">
|
||||
<summary>
|
||||
poem summary
|
||||
|
||||
@ -268,7 +268,7 @@ namespace RMuseum.Services.Implementation
|
||||
await _notificationService.PushNotification(dbCorrection.UserId,
|
||||
"بررسی ویرایش پیشنهادی شما",
|
||||
$"با سپاس از زحمت و همت شما ویرایش پیشنهادیتان برای <a href=\"{dbPoem.FullUrl}\" target=\"_blank\">{dbPoem.FullTitle}</a> بررسی شد.{Environment.NewLine}" +
|
||||
$"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «ویرایشهای من» را مشاهده بفرمایید.{Environment.NewLine}"
|
||||
$"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «ویرایشهای قطعات من» را مشاهده بفرمایید.{Environment.NewLine}"
|
||||
);
|
||||
|
||||
foreach (var section in sections)
|
||||
@ -564,6 +564,7 @@ namespace RMuseum.Services.Implementation
|
||||
List<GanjoorPoemSectionCorrectionViewModel> list = new List<GanjoorPoemSectionCorrectionViewModel>();
|
||||
foreach (var dbCorrection in dbPaginatedResult.Items)
|
||||
{
|
||||
var section = await _context.GanjoorPoemSections.AsNoTracking().Where(s => s.Id == dbCorrection.SectionId).SingleOrDefaultAsync();
|
||||
list.Add
|
||||
(
|
||||
new GanjoorPoemSectionCorrectionViewModel()
|
||||
@ -602,7 +603,9 @@ namespace RMuseum.Services.Implementation
|
||||
Reviewed = dbCorrection.Reviewed,
|
||||
ReviewNote = dbCorrection.ReviewNote,
|
||||
ReviewDate = dbCorrection.ReviewDate,
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName,
|
||||
PoemId = section == null ? 0 : section.PoemId,
|
||||
SectionIndex = section == null ? 0 : section.Index,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user