Shifting CommentPartSettings

This commit is contained in:
Sebastien Ros
2013-10-31 14:53:34 -07:00
parent 07c41a05b6
commit d4fd31ca71
9 changed files with 16 additions and 23 deletions

View File

@@ -108,7 +108,7 @@ namespace Orchard.Comments.Drivers {
if (currentUser != null) part.Author = currentUser.UserName;
var moderateComments = workContext.CurrentSite.As<CommentSettingsPart>().Record.ModerateComments;
var moderateComments = workContext.CurrentSite.As<CommentSettingsPart>().ModerateComments;
part.Status = moderateComments ? CommentStatus.Pending : CommentStatus.Approved;
var commentedOn = _contentManager.Get<ICommonPart>(part.CommentedOn);

View File

@@ -22,9 +22,9 @@ namespace Orchard.Comments.Drivers {
return ContentShape("Parts_Comments_SiteSettings", () => {
if (updater != null) {
updater.TryUpdateModel(part.Record, Prefix, null, null);
updater.TryUpdateModel(part, Prefix, null, null);
}
return shapeHelper.EditorTemplate(TemplateName: "Parts.Comments.SiteSettings", Model: part.Record, Prefix: Prefix);
return shapeHelper.EditorTemplate(TemplateName: "Parts.Comments.SiteSettings", Model: part, Prefix: Prefix);
})
.OnGroup("comments");
}

View File

@@ -1,17 +1,15 @@
using JetBrains.Annotations;
using Orchard.Comments.Models;
using Orchard.ContentManagement;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
using Orchard.Localization;
namespace Orchard.Comments.Handlers {
[UsedImplicitly]
public class CommentSettingsPartHandler : ContentHandler {
public CommentSettingsPartHandler(IRepository<CommentSettingsPartRecord> repository) {
public CommentSettingsPartHandler() {
T = NullLocalizer.Instance;
Filters.Add(new ActivatingFilter<CommentSettingsPart>("Site"));
Filters.Add(StorageFilter.For(repository));
}
public Localizer T { get; set; }

View File

@@ -31,11 +31,6 @@ namespace Orchard.Comments {
.Column<int>("CommentsPartRecord_id")
);
SchemaBuilder.CreateTable("CommentSettingsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("ModerateComments")
);
SchemaBuilder.CreateTable("CommentsPartRecord", table => table
.ContentPartRecord()
.Column<bool>("CommentsShown")

View File

@@ -1,10 +1,10 @@
using Orchard.ContentManagement;
namespace Orchard.Comments.Models {
public class CommentSettingsPart : ContentPart<CommentSettingsPartRecord> {
public class CommentSettingsPart : ContentPart {
public bool ModerateComments {
get { return Record.ModerateComments; }
set { Record.ModerateComments = value; }
get { return this.Retrieve(x => x.ModerateComments); }
set { this.Store(x => x.ModerateComments, value); }
}
}
}

View File

@@ -1,7 +0,0 @@
using Orchard.ContentManagement.Records;
namespace Orchard.Comments.Models {
public class CommentSettingsPartRecord : ContentPartRecord {
public virtual bool ModerateComments { get; set; }
}
}

View File

@@ -98,7 +98,6 @@
<Compile Include="ViewModels\CommentCountViewModel.cs" />
<Compile Include="Models\CommentSettingsPart.cs" />
<Compile Include="Handlers\CommentSettingsPartHandler.cs" />
<Compile Include="Models\CommentSettingsPartRecord.cs" />
<Compile Include="Handlers\CommentsPartHandler.cs" />
<Compile Include="Models\CommentsPart.cs" />
<Compile Include="Permissions.cs" />

View File

@@ -1,4 +1,4 @@
@model Orchard.Comments.Models.CommentSettingsPartRecord
@model Orchard.Comments.Models.CommentSettingsPart
<fieldset>
<legend>@T("Comments")</legend>

View File

@@ -120,6 +120,14 @@ namespace Upgrade.Controllers {
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_OutputCache_CacheSettingsPartRecord"), null);
// CommentSettingsPartRecord
_upgradeService.ExecuteReader("SELECT * FROM " + _upgradeService.GetPrefixedTableName("Orchard_Comment_CommentSettingsPartRecord"),
(reader, connection) => {
site.As<InfosetPart>().Store("CommentSettingsPart", "ModerateComments", (bool)reader["ModerateComments"]);
});
_upgradeService.ExecuteReader("DROP TABLE " + _upgradeService.GetPrefixedTableName("Orchard_Comment_CommentSettingsPartRecord"), null);
_orchardServices.Notifier.Information(T("Site Settings migrated successfully"));