From d345dac18b572d4c503ce4d7327a48027d7f3704 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Mon, 24 Mar 2025 11:33:49 +0330 Subject: [PATCH] #467 cat editor --- .../Areas/Admin/Pages/ReviewCatEdits.cshtml | 111 +++++++++++++++--- .../Admin/Pages/ReviewCatEdits.cshtml.cs | 67 +++++++++++ .../GanjoorService-ModerateCatCorrection.cs | 2 +- 3 files changed, 161 insertions(+), 19 deletions(-) diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml b/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml index bc520479..38f919e5 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml +++ b/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml @@ -13,6 +13,56 @@ return; } +@if (Model.Correction == null) +{ +

ویرایشی وجود ندارد.

+ return; +} + + + - - - - + + + + + + - - - - - + + + + + @if (!string.IsNullOrEmpty(Model.Correction.Note)) { @@ -105,7 +180,7 @@ } - + @@ -113,6 +188,6 @@ - +
@@ -24,7 +74,7 @@
- بررسی + بررسی
@@ -51,12 +101,6 @@
- درست نیست -
تغییرات متن @@ -64,36 +108,67 @@
-

@Model.Correction.OriginalDescription

+

@Model.Correction.OriginalDescription

-

@Model.Correction.Description

+

@Model.Correction.Description

-

@Model.Correction.OriginalDescription

+

@Model.Correction.OriginalDescription

+ @if (Model.Correction.Result == RMuseum.Models.Ganjoor.CorrectionReviewResult.NotChanged) + { + + + +
+ + } + else + { + + + +
+ + } +
+ +
+ +
+ +
+

دلیل را در یادداشت بررسی بنویسید.

+

 

یادداشت بررسی:
diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml.cs b/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml.cs index 47ea9a20..f97d3527 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml.cs +++ b/GanjooRazor/Areas/Admin/Pages/ReviewCatEdits.cshtml.cs @@ -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 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(await correctionResponse.Content.ReadAsStringAsync())); + } + + Correction = JsonConvert.DeserializeObject(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(err); + } + return new BadRequestObjectResult(err); + } + + return new OkObjectResult(true); + } + else + { + return new BadRequestObjectResult("لطفاً از گنجور خارج و مجدداً به آن وارد شوید."); + } + } + } } } diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateCatCorrection.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateCatCorrection.cs index 02cd925a..f1936b5d 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateCatCorrection.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateCatCorrection.cs @@ -112,7 +112,7 @@ namespace RMuseum.Services.Implementation await _notificationService.PushNotification(dbCorrection.UserId, "بررسی ویرایش پیشنهادی شما برای بخش", $"با سپاس از زحمت و همت شما ویرایش پیشنهادیتان برای {dbPage.FullTitle} بررسی شد.{Environment.NewLine}" + - $"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «ویرایش‌های بخش‌های من» را مشاهده بفرمایید.{Environment.NewLine}" + $"جهت مشاهدهٔ نتیجهٔ بررسی در میز کاربری خود بخش «ویرایش‌های بخش‌های من» را مشاهده بفرمایید.{Environment.NewLine}" );