docs: #319 moderating section corrections
This commit is contained in:
parent
bc01d15e3b
commit
7bba7277fb
@ -19,6 +19,51 @@ else if (@Model.Correction == null)
|
||||
}
|
||||
else
|
||||
{
|
||||
<script>
|
||||
function moderateSectionCorrections(correctionId) {
|
||||
|
||||
$('#moderatecorrections').hide();
|
||||
$('#saving').text('در حال بررسی ...');
|
||||
|
||||
|
||||
|
||||
|
||||
var rhythmReviewResult = 'DontCare';
|
||||
if ($('#rhythm_review_result_Approved').length > 0) {
|
||||
rhythmReviewResult = $('input[name=rhythm_review_result]:checked').val()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var url = '?handler=SendCorrectionsModeration';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {
|
||||
correctionId: correctionId,
|
||||
rhythmReviewResult: rhythmReviewResult,
|
||||
titleReviewNote: $('#title_review_note') == null? null : $('#title_review_note').val(),
|
||||
},
|
||||
success: function () {
|
||||
location.reload(true);
|
||||
},
|
||||
error: function (e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
$('#moderatecorrections').show();
|
||||
$('#saving').text('');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<p><a role="button" target="_blank" href="@Model.PageInformation.FullUrl" class="actionlink">@Model.PageInformation.FullTitle</a></p>
|
||||
|
||||
<table>
|
||||
@ -32,7 +77,7 @@ else
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a role="button" id="moderatecorrections" style="cursor:pointer;width:100%;color:white;background-color:green;display:block" onclick="moderatePoemCorrections(@Model.PageInformation.Poem.Verses.Length, @Model.Correction.Id)">بررسی</a>
|
||||
<a role="button" id="moderatecorrections" style="cursor:pointer;width:100%;color:white;background-color:green;display:block" onclick="moderateSectionCorrections(@Model.PageInformation.Poem.Verses.Length, @Model.Correction.Id)">بررسی</a>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post">
|
||||
|
||||
@ -121,5 +121,64 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public IActionResult OnPost()
|
||||
{
|
||||
Skip = string.IsNullOrEmpty(Request.Query["skip"]) ? 0 : int.Parse(Request.Query["skip"]);
|
||||
if (Request.Form["next"].Count == 1)
|
||||
{
|
||||
return Redirect($"/Admin/ReviewPartEdits/?skip={Skip + 1}");
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSendCorrectionsModerationAsync(int correctionId,
|
||||
string rhythmReviewResult,
|
||||
string titleReviewNote)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var correctionResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/section/correction/{correctionId}");
|
||||
if (!correctionResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await correctionResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
|
||||
Correction = JsonConvert.DeserializeObject<GanjoorPoemSectionCorrectionViewModel>(await correctionResponse.Content.ReadAsStringAsync());
|
||||
|
||||
|
||||
if (Correction.Rhythm != null)
|
||||
{
|
||||
if (rhythmReviewResult == null)
|
||||
{
|
||||
return new BadRequestObjectResult("لطفا تغییر وزن را بازبینی کنید.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Correction.RhythmResult = (CorrectionReviewResult)Enum.Parse(typeof(CorrectionReviewResult), rhythmReviewResult);
|
||||
Correction.ReviewNote = titleReviewNote;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var moderationResponse = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/section/moderate",
|
||||
new StringContent(JsonConvert.SerializeObject(Correction), Encoding.UTF8, "application/json"
|
||||
));
|
||||
|
||||
if (!moderationResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await moderationResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
|
||||
return new OkObjectResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2939,6 +2939,31 @@ namespace RMuseum.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get section correction by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("section/correction/{id}")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemSectionCorrectionViewModel))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
public async Task<IActionResult> GetSectionCorrectionById(int id)
|
||||
{
|
||||
Guid userId =
|
||||
new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value);
|
||||
|
||||
RServiceResult<GanjoorPoemSectionCorrectionViewModel> res =
|
||||
await _ganjoorService.GetSectionCorrectionById(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
if (res.Result == null)
|
||||
return NotFound();
|
||||
return Ok(res.Result);//might be null
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get next unreviewed correction for poem sections
|
||||
/// </summary>
|
||||
|
||||
@ -1748,6 +1748,13 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetSectionCorrectionById(System.Int32)">
|
||||
<summary>
|
||||
get section correction by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetNextUnreviewedPoemSectionCorrection(System.Int32)">
|
||||
<summary>
|
||||
get next unreviewed correction for poem sections
|
||||
@ -12425,6 +12432,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetSectionCorrectionById(System.Int32)">
|
||||
<summary>
|
||||
get section correction by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:RMuseum.Services.IGanjoorTranslationService">
|
||||
<summary>
|
||||
translation service implementation
|
||||
@ -14019,6 +14033,13 @@
|
||||
<param name="skip"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetSectionCorrectionById(System.Int32)">
|
||||
<summary>
|
||||
get section correction by id
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetUnreviewedPoemSectionCorrectionCount">
|
||||
<summary>
|
||||
unreview poem section correction count
|
||||
|
||||
@ -993,5 +993,12 @@ namespace RMuseum.Services
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<int>> GetUnreviewedPoemSectionCorrectionCount();
|
||||
|
||||
/// <summary>
|
||||
/// get section correction by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemSectionCorrectionViewModel>> GetSectionCorrectionById(int id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -318,6 +318,51 @@ namespace RMuseum.Services.Implementation
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get section correction by id
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<GanjoorPoemSectionCorrectionViewModel>> GetSectionCorrectionById(int id)
|
||||
{
|
||||
var dbCorrection = await _context.GanjoorPoemSectionCorrections.AsNoTracking().Include(c => c.User)
|
||||
.Where(c => c.Id == id)
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
if (dbCorrection == null)
|
||||
return new RServiceResult<GanjoorPoemSectionCorrectionViewModel>(null);
|
||||
|
||||
return new RServiceResult<GanjoorPoemSectionCorrectionViewModel>
|
||||
(
|
||||
new GanjoorPoemSectionCorrectionViewModel()
|
||||
{
|
||||
Id = dbCorrection.Id,
|
||||
SectionId = dbCorrection.SectionId,
|
||||
UserId = dbCorrection.UserId,
|
||||
Rhythm = dbCorrection.Rhythm,
|
||||
OriginalRhythm = dbCorrection.OriginalRhythm,
|
||||
RhythmResult = dbCorrection.RhythmResult,
|
||||
Rhythm2 = dbCorrection.Rhythm2,
|
||||
OriginalRhythm2 = dbCorrection.OriginalRhythm2,
|
||||
RhythmResult2 = dbCorrection.RhythmResult2,
|
||||
BreakFromVerse1VOrder = dbCorrection.BreakFromVerse1VOrder,
|
||||
BreakFromVerse1VOrderResult = dbCorrection.BreakFromVerse1VOrderResult,
|
||||
BreakFromVerse2VOrder = dbCorrection.BreakFromVerse2VOrder,
|
||||
BreakFromVerse2VOrderResult = dbCorrection.BreakFromVerse2VOrderResult,
|
||||
BreakFromVerse3VOrder = dbCorrection.BreakFromVerse3VOrder,
|
||||
BreakFromVerse3VOrderResult = dbCorrection.BreakFromVerse3VOrderResult,
|
||||
BreakFromVerse4VOrder = dbCorrection.BreakFromVerse4VOrder,
|
||||
BreakFromVerse4VOrderResult = dbCorrection.BreakFromVerse4VOrderResult,
|
||||
Note = dbCorrection.Note,
|
||||
Date = dbCorrection.Date,
|
||||
Reviewed = dbCorrection.Reviewed,
|
||||
ReviewNote = dbCorrection.ReviewNote,
|
||||
ReviewDate = dbCorrection.ReviewDate,
|
||||
UserNickname = string.IsNullOrEmpty(dbCorrection.User.NickName) ? dbCorrection.User.Id.ToString() : dbCorrection.User.NickName
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// unreview poem section correction count
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user