#467 cat editor
This commit is contained in:
parent
fa392dfca4
commit
d345dac18b
@ -13,6 +13,56 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@if (Model.Correction == null)
|
||||
{
|
||||
<p>ویرایشی وجود ندارد.</p>
|
||||
return;
|
||||
}
|
||||
|
||||
<script>
|
||||
function moderateCorrections(correctionId) {
|
||||
|
||||
$('#moderatecorrections').hide();
|
||||
$('#saving').text('در حال بررسی ...');
|
||||
|
||||
|
||||
var descriptionReviewResult = 'DontCare';
|
||||
if ($('#description_review_result_Approved').length > 0) { //has title
|
||||
descriptionReviewResult = $('input[name=description_review_result]:checked').val()
|
||||
}
|
||||
|
||||
|
||||
var url = '?handler=SendCorrectionsModeration';
|
||||
|
||||
var pms = {};
|
||||
|
||||
pms.correctionId= correctionId;
|
||||
pms.titleReviewResult = descriptionReviewResult;
|
||||
pms.titleReviewNote= $('#review_note') == null ? null : $('#review_note').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: JSON.stringify(pms),
|
||||
contentType: "application/json; charset=utf-8",
|
||||
dataType: "json",
|
||||
success: function() {
|
||||
location.reload(true);
|
||||
},
|
||||
error: function(e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
$('#moderatecorrections').show();
|
||||
$('#saving').text('');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@ -24,7 +74,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a role="button" id="moderatecorrections" style="cursor:pointer;width:100%;color:white;background-color:green;display:block" onclick="moderateSectionCorrections(@Model.Correction.Id)">بررسی</a>
|
||||
<a role="button" id="moderatecorrections" style="cursor:pointer;width:100%;color:white;background-color:green;display:block" onclick="moderateCorrections(@Model.Correction.Id)">بررسی</a>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post">
|
||||
@ -51,12 +101,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=2>
|
||||
<a role="button" onclick="notCorrect()" class="pagebutton">درست نیست</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
تغییرات متن
|
||||
@ -64,36 +108,67 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p class="red-color" id="title-lastedit-original">@Model.Correction.OriginalDescription</p>
|
||||
<p class="red-color" id="description-lastedit-original">@Model.Correction.OriginalDescription</p>
|
||||
</td>
|
||||
<td>
|
||||
<p class="green-color" id="title-lastedit-edited">@Model.Correction.Description</p>
|
||||
<p class="green-color" id="description-lastedit-edited">@Model.Correction.Description</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<p id="title-lastedit-compare">@Model.Correction.OriginalDescription</p>
|
||||
<p id="description-lastedit-compare">@Model.Correction.OriginalDescription</p>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
compareCorrectionBlocks('title-lastedit-original', 'title-lastedit-edited', 'title-lastedit-compare');
|
||||
compareCorrectionBlocks('description-lastedit-original', 'description-lastedit-edited', 'description-lastedit-compare');
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
@if (Model.Correction.Result == RMuseum.Models.Ganjoor.CorrectionReviewResult.NotChanged)
|
||||
{
|
||||
<input type="radio" id="description_review_result_Approved" name="description_review_result" class="radio-approved" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.Approved">
|
||||
<label for="description_review_result_Approved">@RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult.Approved)</label>
|
||||
|
||||
<br>
|
||||
<input type="radio" id="description_review_result_NotChanged" name="description_review_result" class="radio-notchanged" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.NotChanged" checked="checked">
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="radio" id="description_review_result_Approved" name="description_review_result" class="radio-approved" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.Approved" checked="checked">
|
||||
<label for="description_review_result_Approved">@RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult.Approved)</label>
|
||||
|
||||
<br>
|
||||
<input type="radio" id="description_review_result_NotChanged" name="description_review_result" class="radio-notchanged" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.NotChanged">
|
||||
}
|
||||
<label for="description_review_result_NotChanged">@RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult.NotChanged)</label><br>
|
||||
<input type="radio" id="description_review_result_RejectedBecauseWrong" name="description_review_result" class="radio-notcorrect" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.RejectedBecauseWrong">
|
||||
<label for="description_review_result_RejectedBecauseWrong">@RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult.RejectedBecauseWrong)</label><br>
|
||||
<input type="radio" id="description_review_result_RejectedBecauseVariant" name="description_review_result" class="radio-variant" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.RejectedBecauseVariant">
|
||||
<label for="description_review_result_RejectedBecauseUnnecessaryChange">تغییر سلیقهای یا بی دلیل است</label><br>
|
||||
<input type="radio" id="description_review_result_Rejected" name="description_review_result" class="radio-rejected" value="@RMuseum.Models.Ganjoor.CorrectionReviewResult.Rejected">
|
||||
<label for="description_review_result_Rejected">@RMuseum.Services.Implementation.CorrectionReviewResultConvertor.GetString(RMuseum.Models.Ganjoor.CorrectionReviewResult.Rejected)</label><br>
|
||||
<p>دلیل را در یادداشت بررسی بنویسید.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><p id="saving"> </p></td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@if (!string.IsNullOrEmpty(Model.Correction.Note))
|
||||
{
|
||||
@ -105,7 +180,7 @@
|
||||
</tr>
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td>یادداشت بررسی:</td>
|
||||
@ -113,6 +188,6 @@
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
@ -8,6 +8,11 @@ using RSecurityBackend.Models.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using RMuseum.Models.Ganjoor;
|
||||
using static GanjooRazor.Areas.Admin.Pages.ReviewEditsModel;
|
||||
using System.Text;
|
||||
using System;
|
||||
using Org.BouncyCastle.Asn1.Cmp;
|
||||
|
||||
namespace GanjooRazor.Areas.Admin.Pages
|
||||
{
|
||||
@ -89,5 +94,67 @@ namespace GanjooRazor.Areas.Admin.Pages
|
||||
}
|
||||
return Page();
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostSendCorrectionsModerationAsync([FromBody] PoemMoerationStructure pms)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
var correctionResponse = await secureClient.GetAsync($"{APIRoot.Url}/api/ganjoor/cat/correction/{pms.correctionId}");
|
||||
if (!correctionResponse.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await correctionResponse.Content.ReadAsStringAsync()));
|
||||
}
|
||||
|
||||
Correction = JsonConvert.DeserializeObject<GanjoorCatCorrectionViewModel>(await correctionResponse.Content.ReadAsStringAsync());
|
||||
|
||||
if (Correction.DescriptionHtml != null)
|
||||
{
|
||||
if (pms.titleReviewResult == null)
|
||||
{
|
||||
return new BadRequestObjectResult("لطفاً تغییرات متن را بازبینی کنید.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Correction.Result = (CorrectionReviewResult)Enum.Parse(typeof(CorrectionReviewResult), pms.titleReviewResult);
|
||||
Correction.ReviewNote = pms.titleReviewNote;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var moderationResponse = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/cat/correction/moderate",
|
||||
new StringContent(JsonConvert.SerializeObject(Correction), Encoding.UTF8, "application/json"
|
||||
));
|
||||
|
||||
if (!moderationResponse.IsSuccessStatusCode)
|
||||
{
|
||||
string err = await moderationResponse.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(err))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(moderationResponse.ReasonPhrase))
|
||||
{
|
||||
err = moderationResponse.ReasonPhrase;
|
||||
}
|
||||
else
|
||||
{
|
||||
err = $"Error Code: {moderationResponse.StatusCode}";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
err = JsonConvert.DeserializeObject<string>(err);
|
||||
}
|
||||
return new BadRequestObjectResult(err);
|
||||
}
|
||||
|
||||
return new OkObjectResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BadRequestObjectResult("لطفاً از گنجور خارج و مجدداً به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ namespace RMuseum.Services.Implementation
|
||||
await _notificationService.PushNotification(dbCorrection.UserId,
|
||||
"بررسی ویرایش پیشنهادی شما برای بخش",
|
||||
$"با سپاس از زحمت و همت شما ویرایش پیشنهادیتان برای <a href=\"https://ganjoor.net{dbCat.FullUrl}\" target=\"_blank\">{dbPage.FullTitle}</a> بررسی شد.{Environment.NewLine}" +
|
||||
$"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «<a href=\"https://ganjoor.net/User/Cdits\">ویرایشهای بخشهای من</a>» را مشاهده بفرمایید.{Environment.NewLine}"
|
||||
$"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «<a href=\"https://ganjoor.net/User/CatEdits\">ویرایشهای بخشهای من</a>» را مشاهده بفرمایید.{Environment.NewLine}"
|
||||
);
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user