Skip to content

Commit 3f6f2c4

Browse files
committed
Merge branch 'issue-1878-News-blog-comments-Product-reviews-add-filter-by-Approved-status' into develop
# Conflicts: # upgradescripts/3.80-the next version/upgrade.sql
2 parents 058736e + 3ef7737 commit 3f6f2c4

File tree

15 files changed

+209
-13
lines changed

15 files changed

+209
-13
lines changed

src/Libraries/Nop.Services/Blogs/BlogService.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,19 @@ public virtual void UpdateBlogPost(BlogPost blogPost)
244244
/// <param name="customerId">Customer identifier; 0 to load all records</param>
245245
/// <param name="storeId">Store identifier; pass 0 to load all records</param>
246246
/// <param name="blogPostId">Blog post ID; 0 or null to load all records</param>
247+
/// <param name="approved">A value indicating whether to content is approved; null to load all records</param>
247248
/// <param name="fromUtc">Item creation from; null to load all records</param>
248249
/// <param name="toUtc">Item creation to; null to load all records</param>
249250
/// <param name="commentText">Search comment text; null to load all records</param>
250251
/// <returns>Comments</returns>
251252
public virtual IList<BlogComment> GetAllComments(int customerId = 0, int storeId = 0, int? blogPostId = null,
252-
DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null)
253+
bool? approved = null, DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null)
253254
{
254255
var query = _blogCommentRepository.Table;
255256

257+
if (approved.HasValue)
258+
query = query.Where(comment => comment.IsApproved == approved);
259+
256260
if (blogPostId > 0)
257261
query = query.Where(comment => comment.BlogPostId == blogPostId);
258262

src/Libraries/Nop.Services/Blogs/IBlogService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,13 @@ IPagedList<BlogPost> GetAllBlogPostsByTag(int storeId = 0,
9292
/// <param name="customerId">Customer identifier; 0 to load all records</param>
9393
/// <param name="storeId">Store identifier; pass 0 to load all records</param>
9494
/// <param name="blogPostId">Blog post ID; 0 or null to load all records</param>
95+
/// <param name="approved">A value indicating whether to content is approved; null to load all records</param>
9596
/// <param name="fromUtc">Item creation from; null to load all records</param>
9697
/// <param name="toUtc">Item creation to; null to load all records</param>
9798
/// <param name="commentText">Search comment text; null to load all records</param>
9899
/// <returns>Comments</returns>
99100
IList<BlogComment> GetAllComments(int customerId = 0, int storeId = 0, int? blogPostId = null,
100-
DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null);
101+
bool? approved = null, DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null);
101102

102103
/// <summary>
103104
/// Gets a blog comment

src/Libraries/Nop.Services/News/INewsService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,13 @@ IPagedList<NewsItem> GetAllNews(int languageId = 0, int storeId = 0,
6666
/// <param name="customerId">Customer identifier; 0 to load all records</param>
6767
/// <param name="storeId">Store identifier; pass 0 to load all records</param>
6868
/// <param name="newsItemId">News item ID; 0 or null to load all records</param>
69+
/// <param name="approved">A value indicating whether to content is approved; null to load all records</param>
6970
/// <param name="fromUtc">Item creation from; null to load all records</param>
7071
/// <param name="toUtc">Item creation to; null to load all records</param>
7172
/// <param name="commentText">Search comment text; null to load all records</param>
7273
/// <returns>Comments</returns>
7374
IList<NewsComment> GetAllComments(int customerId = 0, int storeId = 0, int? newsItemId = null,
74-
DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null);
75+
bool? approved = null, DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null);
7576

7677
/// <summary>
7778
/// Gets a news comment

src/Libraries/Nop.Services/News/NewsService.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,19 @@ public virtual void UpdateNews(NewsItem news)
172172
/// <param name="customerId">Customer identifier; 0 to load all records</param>
173173
/// <param name="storeId">Store identifier; pass 0 to load all records</param>
174174
/// <param name="newsItemId">News item ID; 0 or null to load all records</param>
175+
/// <param name="approved">A value indicating whether to content is approved; null to load all records</param>
175176
/// <param name="fromUtc">Item creation from; null to load all records</param>
176177
/// <param name="toUtc">Item creation to; null to load all records</param>
177-
/// <param name="commentText">Search comment text or comment title; null to load all records</param>
178+
/// <param name="commentText">Search comment text; null to load all records</param>
178179
/// <returns>Comments</returns>
179180
public virtual IList<NewsComment> GetAllComments(int customerId = 0, int storeId = 0, int? newsItemId = null,
180-
DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null)
181+
bool? approved = null, DateTime? fromUtc = null, DateTime? toUtc = null, string commentText = null)
181182
{
182183
var query = _newsCommentRepository.Table;
183184

185+
if (approved.HasValue)
186+
query = query.Where(comment => comment.IsApproved == approved);
187+
184188
if (newsItemId > 0)
185189
query = query.Where(comment => comment.NewsItemId == newsItemId);
186190

src/Presentation/Nop.Web/Administration/Controllers/BlogController.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,17 @@ public ActionResult Comments(int? filterByBlogPostId)
332332
return AccessDeniedView();
333333

334334
ViewBag.FilterByBlogPostId = filterByBlogPostId;
335-
return View();
335+
var model = new BlogCommentListModel();
336+
337+
//"approved" property
338+
//0 - all
339+
//1 - approved only
340+
//2 - disapproved only
341+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.Blog.Comments.List.SearchApproved.All"), Value = "0" });
342+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.Blog.Comments.List.SearchApproved.ApprovedOnly"), Value = "1" });
343+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.Blog.Comments.List.SearchApproved.DisapprovedOnly"), Value = "2" });
344+
345+
return View(model);
336346
}
337347

338348
[HttpPost]
@@ -347,7 +357,11 @@ public ActionResult Comments(int? filterByBlogPostId, DataSourceRequest command,
347357
var createdOnToValue = model.CreatedOnTo == null ? null
348358
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);
349359

350-
var comments = _blogService.GetAllComments(0, 0, filterByBlogPostId, createdOnFromValue, createdOnToValue, model.SearchText);
360+
bool? approved = null;
361+
if (model.SearchApprovedId > 0)
362+
approved = model.SearchApprovedId == 1;
363+
364+
var comments = _blogService.GetAllComments(0, 0, filterByBlogPostId, approved, createdOnFromValue, createdOnToValue, model.SearchText);
351365

352366
var storeNames = _storeService.GetAllStores().ToDictionary(store => store.Id, store => store.Name);
353367

src/Presentation/Nop.Web/Administration/Controllers/NewsController.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,17 @@ public ActionResult Comments(int? filterByNewsItemId)
339339
return AccessDeniedView();
340340

341341
ViewBag.FilterByNewsItemId = filterByNewsItemId;
342-
return View();
342+
var model = new NewsCommentListModel();
343+
344+
//"approved" property
345+
//0 - all
346+
//1 - approved only
347+
//2 - disapproved only
348+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.News.Comments.List.SearchApproved.All"), Value = "0" });
349+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.News.Comments.List.SearchApproved.ApprovedOnly"), Value = "1" });
350+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.ContentManagement.News.Comments.List.SearchApproved.DisapprovedOnly"), Value = "2" });
351+
352+
return View(model);
343353
}
344354

345355
[HttpPost]
@@ -354,7 +364,11 @@ public ActionResult Comments(int? filterByNewsItemId, DataSourceRequest command,
354364
var createdOnToValue = model.CreatedOnTo == null ? null
355365
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);
356366

357-
var comments = _newsService.GetAllComments(0, 0, filterByNewsItemId, createdOnFromValue, createdOnToValue, model.SearchText);
367+
bool? approved = null;
368+
if (model.SearchApprovedId > 0)
369+
approved = model.SearchApprovedId == 1;
370+
371+
var comments = _newsService.GetAllComments(0, 0, filterByNewsItemId, approved, createdOnFromValue, createdOnToValue, model.SearchText);
358372

359373
var storeNames = _storeService.GetAllStores().ToDictionary(store => store.Id, store => store.Name);
360374

src/Presentation/Nop.Web/Administration/Controllers/ProductReviewController.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,15 @@ public ActionResult List()
110110
var stores = _storeService.GetAllStores().Select(st => new SelectListItem() { Text = st.Name, Value = st.Id.ToString() });
111111
foreach (var selectListItem in stores)
112112
model.AvailableStores.Add(selectListItem);
113+
114+
//"approved" property
115+
//0 - all
116+
//1 - approved only
117+
//2 - disapproved only
118+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.ProductReviews.List.SearchApproved.All"), Value = "0" });
119+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.ProductReviews.List.SearchApproved.ApprovedOnly"), Value = "1" });
120+
model.AvailableApprovedOptions.Add(new SelectListItem { Text = _localizationService.GetResource("Admin.Catalog.ProductReviews.List.SearchApproved.DisapprovedOnly"), Value = "2" });
121+
113122
return View(model);
114123
}
115124

@@ -125,7 +134,11 @@ public ActionResult List(DataSourceRequest command, ProductReviewListModel model
125134
DateTime? createdToFromValue = (model.CreatedOnTo == null) ? null
126135
: (DateTime?)_dateTimeHelper.ConvertToUtcTime(model.CreatedOnTo.Value, _dateTimeHelper.CurrentTimeZone).AddDays(1);
127136

128-
var productReviews = _productService.GetAllProductReviews(0, null,
137+
bool? approved = null;
138+
if (model.SearchApprovedId > 0)
139+
approved = model.SearchApprovedId == 1;
140+
141+
var productReviews = _productService.GetAllProductReviews(0, approved,
129142
createdOnFromValue, createdToFromValue, model.SearchText, model.SearchStoreId, model.SearchProductId, command.Page - 1, command.PageSize);
130143
var gridModel = new DataSourceResult
131144
{

src/Presentation/Nop.Web/Administration/Models/Blogs/BlogCommentListModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.DataAnnotations;
34
using System.Web.Mvc;
45
using Nop.Web.Framework;
@@ -8,6 +9,11 @@ namespace Nop.Admin.Models.Blogs
89
{
910
public partial class BlogCommentListModel : BaseNopModel
1011
{
12+
public BlogCommentListModel()
13+
{
14+
AvailableApprovedOptions = new List<SelectListItem>();
15+
}
16+
1117
[NopResourceDisplayName("Admin.ContentManagement.Blog.Comments.List.CreatedOnFrom")]
1218
[UIHint("DateNullable")]
1319
public DateTime? CreatedOnFrom { get; set; }
@@ -19,5 +25,10 @@ public partial class BlogCommentListModel : BaseNopModel
1925
[NopResourceDisplayName("Admin.ContentManagement.Blog.Comments.List.SearchText")]
2026
[AllowHtml]
2127
public string SearchText { get; set; }
28+
29+
[NopResourceDisplayName("Admin.ContentManagement.Blog.Comments.List.SearchApproved")]
30+
public int SearchApprovedId { get; set; }
31+
32+
public IList<SelectListItem> AvailableApprovedOptions { get; set; }
2233
}
2334
}

src/Presentation/Nop.Web/Administration/Models/Catalog/ProductReviewListModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public partial class ProductReviewListModel : BaseNopModel
1212
public ProductReviewListModel()
1313
{
1414
AvailableStores = new List<SelectListItem>();
15+
AvailableApprovedOptions = new List<SelectListItem>();
1516
}
1617

1718
[NopResourceDisplayName("Admin.Catalog.ProductReviews.List.CreatedOnFrom")]
@@ -32,6 +33,10 @@ public ProductReviewListModel()
3233
[NopResourceDisplayName("Admin.Catalog.ProductReviews.List.SearchProduct")]
3334
public int SearchProductId { get; set; }
3435

36+
[NopResourceDisplayName("Admin.Catalog.ProductReviews.List.SearchApproved")]
37+
public int SearchApprovedId { get; set; }
38+
3539
public IList<SelectListItem> AvailableStores { get; set; }
40+
public IList<SelectListItem> AvailableApprovedOptions { get; set; }
3641
}
3742
}

src/Presentation/Nop.Web/Administration/Models/News/NewsCommentListModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.ComponentModel.DataAnnotations;
34
using System.Web.Mvc;
45
using Nop.Web.Framework;
@@ -8,6 +9,11 @@ namespace Nop.Admin.Models.News
89
{
910
public partial class NewsCommentListModel : BaseNopModel
1011
{
12+
public NewsCommentListModel()
13+
{
14+
AvailableApprovedOptions = new List<SelectListItem>();
15+
}
16+
1117
[NopResourceDisplayName("Admin.ContentManagement.News.Comments.List.CreatedOnFrom")]
1218
[UIHint("DateNullable")]
1319
public DateTime? CreatedOnFrom { get; set; }
@@ -19,5 +25,10 @@ public partial class NewsCommentListModel : BaseNopModel
1925
[NopResourceDisplayName("Admin.ContentManagement.News.Comments.List.SearchText")]
2026
[AllowHtml]
2127
public string SearchText { get; set; }
28+
29+
[NopResourceDisplayName("Admin.ContentManagement.News.Comments.List.SearchApproved")]
30+
public int SearchApprovedId { get; set; }
31+
32+
public IList<SelectListItem> AvailableApprovedOptions { get; set; }
2233
}
2334
}

0 commit comments

Comments
 (0)