diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs
index 07bb1958..2f7ca8a4 100644
--- a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs
+++ b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Net.Http;
+using System.Text;
using System.Threading.Tasks;
using GanjooRazor.Utils;
using Microsoft.AspNetCore.Mvc;
@@ -163,7 +164,15 @@ namespace GanjooRazor.Areas.Admin.Pages
}
}
-
+ var moderationResponse = await secureClient.PostAsync($"{APIRoot.Url}/api/ganjoor/correction/moderate",
+ new StringContent(JsonConvert.SerializeObject(Correction), Encoding.UTF8, "application/json"
+ ));
+
+ if(!moderationResponse.IsSuccessStatusCode)
+ {
+ return new BadRequestObjectResult(moderationResponse.Content.ReadAsStringAsync());
+ }
+
return new OkObjectResult(true);
}
else
diff --git a/RMuseum/Controllers/GanjoorController.cs b/RMuseum/Controllers/GanjoorController.cs
index c007f21f..83cc7ea1 100644
--- a/RMuseum/Controllers/GanjoorController.cs
+++ b/RMuseum/Controllers/GanjoorController.cs
@@ -922,8 +922,8 @@ namespace RMuseum.Controllers
///
///
[HttpPost]
- [Route("poem/correction/moderate")]
- [Authorize]
+ [Route("correction/moderate")]
+ [Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorPoemCorrectionViewModel))]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.NotFound)]
diff --git a/RMuseum/Models/Ganjoor/GanjoorPoemCorrection.cs b/RMuseum/Models/Ganjoor/GanjoorPoemCorrection.cs
index dd9d48aa..3b7d632b 100644
--- a/RMuseum/Models/Ganjoor/GanjoorPoemCorrection.cs
+++ b/RMuseum/Models/Ganjoor/GanjoorPoemCorrection.cs
@@ -70,7 +70,7 @@ namespace RMuseum.Models.Ganjoor
public RAppUser User { get; set; }
///
- /// reviewed (this is now unnecessary due to Result field and can be removed)
+ /// reviewed
///
public bool Reviewed { get; set; }
diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml
index 33897c19..912d36a3 100644
--- a/RMuseum/RMuseum.xml
+++ b/RMuseum/RMuseum.xml
@@ -4856,7 +4856,7 @@
- reviewed (this is now unnecessary due to Result field and can be removed)
+ reviewed
diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs
index 0861dc9f..7ce630f7 100644
--- a/RMuseum/Services/Implementation/GanjoorService.cs
+++ b/RMuseum/Services/Implementation/GanjoorService.cs
@@ -1307,7 +1307,7 @@ namespace RMuseum.Services.Implementation
public async Task> DeletePoemCorrections(Guid userId, int poemId)
{
var preCorrections = await _context.GanjoorPoemCorrections.Include(c => c.VerseOrderText)
- .Where(c => c.UserId == userId && c.PoemId == poemId && c.Result == CorrectionReviewResult.NotReviewed)
+ .Where(c => c.UserId == userId && c.PoemId == poemId && c.Reviewed == false)
.ToListAsync();
if (preCorrections.Count > 0)
{
@@ -1329,7 +1329,7 @@ namespace RMuseum.Services.Implementation
public async Task> SuggestPoemCorrection(GanjoorPoemCorrectionViewModel correction)
{
var preCorrections = await _context.GanjoorPoemCorrections.Include(c => c.VerseOrderText)
- .Where(c => c.UserId == correction.UserId && c.PoemId == correction.PoemId && c.Result == CorrectionReviewResult.NotReviewed)
+ .Where(c => c.UserId == correction.UserId && c.PoemId == correction.PoemId && c.Reviewed == false)
.ToListAsync();
var poem = (await GetPoemById(correction.PoemId, false, false, true, false, false, false, false, true, false)).Result;
@@ -1378,7 +1378,7 @@ namespace RMuseum.Services.Implementation
public async Task> GetLastUnreviewedUserCorrectionForPoem(Guid userId, int poemId)
{
var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User)
- .Where(c => c.UserId == userId && c.PoemId == poemId && c.Result == CorrectionReviewResult.NotReviewed)
+ .Where(c => c.UserId == userId && c.PoemId == poemId && c.Reviewed == false)
.OrderByDescending(c => c.Id)
.FirstOrDefaultAsync();
@@ -1451,7 +1451,7 @@ namespace RMuseum.Services.Implementation
public async Task> GetNextUnreviewedCorrection(int skip)
{
var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.User)
- .Where(c => c.Result == CorrectionReviewResult.NotReviewed)
+ .Where(c => c.Reviewed == false)
.OrderBy(c => c.Id)
.Skip(skip)
.FirstOrDefaultAsync();
@@ -1488,7 +1488,7 @@ namespace RMuseum.Services.Implementation
public async Task> GetUnreviewedCorrectionCount()
{
return new RServiceResult(await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText)
- .Where(c => c.Result == CorrectionReviewResult.NotReviewed)
+ .Where(c => c.Reviewed == false)
.CountAsync());
}
@@ -1508,15 +1508,26 @@ namespace RMuseum.Services.Implementation
dbCorrection.ReviewerUserId = userId;
dbCorrection.ReviewDate = DateTime.Now;
- dbCorrection.ApplicationOrder = 1 + await _context.GanjoorPoemCorrections.Where(c => c.Reviewed).MaxAsync(c => c.ApplicationOrder);
+ dbCorrection.ApplicationOrder = await _context.GanjoorPoemCorrections.Where(c => c.Reviewed).AnyAsync() ? 1 + await _context.GanjoorPoemCorrections.Where(c => c.Reviewed).MaxAsync(c => c.ApplicationOrder) : 1;
dbCorrection.Reviewed = true;
dbCorrection.AffectedThePoem = false;
if (dbCorrection == null)
return new RServiceResult(null);
+ var dbPoem = await _context.GanjoorPoems.Include(p => p.GanjoorMetre).Where(p => p.Id == moderation.PoemId).SingleOrDefaultAsync();
+
GanjoorModifyPageViewModel pageViewModel = new GanjoorModifyPageViewModel()
{
+ Title = dbPoem.Title,
+ UrlSlug = dbPoem.UrlSlug,
+ OldTag = dbPoem.OldTag,
+ OldTagPageUrl = dbPoem.OldTagPageUrl,
+ RhymeLetters = dbPoem.RhymeLetters,
+ Rhythm = dbPoem.GanjoorMetre.Rhythm,
+ HtmlText = dbPoem.HtmlText,
+ SourceName = dbPoem.SourceName,
+ SourceUrlSlug = dbPoem.SourceUrlSlug,
Note = dbCorrection.Note
};
@@ -1549,7 +1560,7 @@ namespace RMuseum.Services.Implementation
if(moderation.VerseOrderText.Length != dbCorrection.VerseOrderText.Count)
return new RServiceResult(null, "moderation.VerseOrderText.Length != dbCorrection.VerseOrderText.Count");
- var poemVerses = await _context.GanjoorVerses.AsNoTracking().Where(p => p.PoemId == dbCorrection.PoemId).ToListAsync();
+ var poemVerses = await _context.GanjoorVerses.AsNoTracking().Where(p => p.PoemId == dbCorrection.PoemId).OrderBy(v => v.VOrder).ToListAsync();
foreach (var moderatedVerse in moderation.VerseOrderText)
{