First step into getting versioning/publishing working for blog posts and pages

Publishing/versioning/draft is now mostly working according to spec, next big thing to work on is scheduled publishing (use the TaskScheduler)

--HG--
extra : convert_revision : svn%3A5ff7c347-ad56-4c35-b696-ccb81de16e03/trunk%4045915
This commit is contained in:
rpaquay
2010-01-24 07:46:16 +00:00
parent 980b741a25
commit 966462667e
22 changed files with 82 additions and 81 deletions

View File

@@ -19,7 +19,7 @@ namespace Orchard.Tests.ContentManagement.Models {
public DeltaHandler(IRepository<DeltaRecord> repository) { public DeltaHandler(IRepository<DeltaRecord> repository) {
Filters.Add(new ActivatingFilter<Delta>(x => x == "delta")); Filters.Add(new ActivatingFilter<Delta>(x => x == "delta"));
Filters.Add(new StorageFilter<DeltaRecord>(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }
} }

View File

@@ -15,7 +15,7 @@ namespace Orchard.Tests.ContentManagement.Models {
public GammaHandler(IRepository<GammaRecord> repository) { public GammaHandler(IRepository<GammaRecord> repository) {
Filters.Add(new ActivatingFilter<Gamma>(x => x == "gamma")); Filters.Add(new ActivatingFilter<Gamma>(x => x == "gamma"));
Filters.Add(new StorageFilter<GammaRecord>(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }

View File

@@ -1,4 +1,3 @@
using JetBrains.Annotations;
using Orchard.Core.Common.Models; using Orchard.Core.Common.Models;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.Core.Common.ViewModels; using Orchard.Core.Common.ViewModels;
@@ -11,7 +10,6 @@ using Orchard.Security;
using Orchard.Services; using Orchard.Services;
namespace Orchard.Core.Common.Providers { namespace Orchard.Core.Common.Providers {
[UsedImplicitly]
public class CommonAspectHandler : ContentHandler { public class CommonAspectHandler : ContentHandler {
private readonly IClock _clock; private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService; private readonly IAuthenticationService _authenticationService;
@@ -40,12 +38,17 @@ namespace Orchard.Core.Common.Providers {
OnActivated<CommonAspect>(PropertySetHandlers); OnActivated<CommonAspect>(PropertySetHandlers);
OnActivated<CommonAspect>(AssignCreatingOwner); OnActivated<CommonAspect>(AssignCreatingOwner);
OnActivated <ContentPart<CommonRecord>>(AssignCreatingDates); OnActivated<ContentPart<CommonRecord>>(AssignCreatingDates);
OnActivated<ContentPart<CommonVersionRecord>>(AssignCreatingDates); OnActivated<ContentPart<CommonVersionRecord>>(AssignCreatingDates);
OnLoaded<CommonAspect>(LazyLoadHandlers);
OnVersioning<CommonAspect>(CopyOwnerAndContainer);
OnVersioned<ContentPart<CommonVersionRecord>>(AssignVersioningDates); OnVersioned<ContentPart<CommonVersionRecord>>(AssignVersioningDates);
OnPublishing<ContentPart<CommonRecord>>(AssignPublishingDates); OnPublishing<ContentPart<CommonRecord>>(AssignPublishingDates);
OnPublishing<ContentPart<CommonVersionRecord>>(AssignPublishingDates); OnPublishing<ContentPart<CommonVersionRecord>>(AssignPublishingDates);
OnLoaded<CommonAspect>(LazyLoadHandlers);
//OnGetDisplayViewModel<CommonAspect>(); //OnGetDisplayViewModel<CommonAspect>();
OnGetEditorViewModel<CommonAspect>(GetEditor); OnGetEditorViewModel<CommonAspect>(GetEditor);
@@ -55,7 +58,7 @@ namespace Orchard.Core.Common.Providers {
public Localizer T { get; set; } public Localizer T { get; set; }
void AssignCreatingOwner(ActivatedContentContext context, CommonAspect part) { void AssignCreatingOwner(ActivatedContentContext context, CommonAspect part) {
// and use the current user as Owner // and use the current user as Owner
if (part.Record.OwnerId == 0) { if (part.Record.OwnerId == 0) {
part.Owner = _authenticationService.GetAuthenticatedUser(); part.Owner = _authenticationService.GetAuthenticatedUser();
@@ -101,6 +104,11 @@ namespace Orchard.Core.Common.Providers {
part.Record.PublishedUtc = _clock.UtcNow; part.Record.PublishedUtc = _clock.UtcNow;
} }
private static void CopyOwnerAndContainer(VersionContentContext c, CommonAspect c1, CommonAspect c2) {
c2.Owner = c1.Owner;
c2.Container = c1.Container;
}
void LazyLoadHandlers(LoadContentContext context, CommonAspect aspect) { void LazyLoadHandlers(LoadContentContext context, CommonAspect aspect) {
// add handlers that will load content for id's just-in-time // add handlers that will load content for id's just-in-time
aspect.OwnerField.Loader(() => _contentManager.Get<IUser>(aspect.Record.OwnerId)); aspect.OwnerField.Loader(() => _contentManager.Get<IUser>(aspect.Record.OwnerId));

View File

@@ -5,6 +5,6 @@ namespace Orchard.Core.Common.Records {
public class CommonVersionRecord : ContentPartVersionRecord { public class CommonVersionRecord : ContentPartVersionRecord {
public virtual DateTime? CreatedUtc { get; set; } public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; } public virtual DateTime? PublishedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; } public virtual DateTime? ModifiedUtc { get; set; }
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Orchard.Core.Settings.Models {
public SiteSettingsHandler(IRepository<SiteSettingsRecord> repository){ public SiteSettingsHandler(IRepository<SiteSettingsRecord> repository){
Filters.Add(new ActivatingFilter<SiteSettings>("site")); Filters.Add(new ActivatingFilter<SiteSettings>("site"));
Filters.Add(new StorageFilter<SiteSettingsRecord>(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }
} }

View File

@@ -9,7 +9,7 @@ namespace Orchard.Core.Themes.Models {
public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) { public ThemeSiteSettingsHandler(IRepository<ThemeSiteSettingsRecord> repository) {
_themeSiteSettingsRepository = repository; _themeSiteSettingsRepository = repository;
Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site")); Filters.Add(new ActivatingFilter<ThemeSiteSettings>("site"));
Filters.Add(new StorageFilter<ThemeSiteSettingsRecord>(_themeSiteSettingsRepository)); Filters.Add(StorageFilter.For(_themeSiteSettingsRepository));
Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings", "Parts/Themes.SiteSettings")); Filters.Add(new TemplateFilterForRecord<ThemeSiteSettingsRecord>("ThemeSiteSettings", "Parts/Themes.SiteSettings"));
} }
} }

View File

@@ -5,9 +5,6 @@ using Orchard.Blogs.Models;
using Orchard.Blogs.Services; using Orchard.Blogs.Services;
using Orchard.Blogs.ViewModels; using Orchard.Blogs.ViewModels;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Mvc.Results; using Orchard.Mvc.Results;
using Orchard.UI.Notify; using Orchard.UI.Notify;
@@ -44,7 +41,7 @@ namespace Orchard.Blogs.Controllers {
var model = new CreateBlogPostViewModel { var model = new CreateBlogPostViewModel {
BlogPost = _services.ContentManager.BuildEditorModel(blogPost) BlogPost = _services.ContentManager.BuildEditorModel(blogPost)
}; };
return View(model); return View(model);
} }
@@ -132,11 +129,25 @@ namespace Orchard.Blogs.Controllers {
if (blog == null) if (blog == null)
return new NotFoundResult(); return new NotFoundResult();
BlogPost post = _blogPostService.Get(postId, VersionOptions.Latest); // Get draft (create a new version if needed)
BlogPost post = _blogPostService.Get(postId, VersionOptions.DraftRequired);
if (post == null) if (post == null)
return new NotFoundResult(); return new NotFoundResult();
// Validate form input
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.UpdateEditorModel(post, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
//TODO: (erikpo) Move this duplicate code somewhere else //TODO: (erikpo) Move this duplicate code somewhere else
DateTime? publishDate = null; DateTime? publishDate = null;
bool publishNow = false; bool publishNow = false;
@@ -155,21 +166,8 @@ namespace Orchard.Blogs.Controllers {
_blogPostService.Publish(post); _blogPostService.Publish(post);
else if (publishDate != null) else if (publishDate != null)
_blogPostService.Publish(post, publishDate.Value); _blogPostService.Publish(post, publishDate.Value);
else { else
_blogPostService.Unpublish(post); _blogPostService.Unpublish(post);
}
var model = new BlogPostEditViewModel {
BlogPost = _services.ContentManager.UpdateEditorModel(post, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
_services.TransactionManager.Cancel();
return View(model);
}
if (publishNow) if (publishNow)
_services.Notifier.Information(T("Blog post has been published")); _services.Notifier.Information(T("Blog post has been published"));

View File

@@ -11,7 +11,7 @@ namespace Orchard.Blogs.Models {
Filters.Add(new ActivatingFilter<Blog>(BlogDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<Blog>(BlogDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(BlogDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonAspect>(BlogDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<RoutableAspect>(BlogDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutableAspect>(BlogDriver.ContentType.Name));
Filters.Add(new StorageFilter<BlogRecord>(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }
} }

View File

@@ -28,9 +28,10 @@ namespace Orchard.Blogs.Models {
Filters.Add(new ActivatingFilter<BlogPost>(BlogPostDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<BlogPost>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(BlogPostDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonAspect>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<RoutableAspect>(BlogPostDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutableAspect>(BlogPostDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(BlogPostDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<BodyAspect>(BlogPostDriver.ContentType.Name));
Filters.Add(new StorageFilter<CommonVersionRecord>(commonRepository)); Filters.Add(StorageFilter.For(commonRepository));
Action<Blog> updateBlogPostCount = Action<Blog> updateBlogPostCount =
(blog => { (blog => {

View File

@@ -87,21 +87,18 @@ namespace Orchard.Blogs.Services {
public void Publish(BlogPost blogPost) { public void Publish(BlogPost blogPost) {
_contentManager.Publish(blogPost.ContentItem); _contentManager.Publish(blogPost.ContentItem);
//TODO: (erikpo) Not sure if this is needed or not
blogPost.Published = DateTime.UtcNow;
} }
public void Publish(BlogPost blogPost, DateTime publishDate) { public void Publish(BlogPost blogPost, DateTime publishDate) {
//TODO: Implement task scheduling
//TODO: (erikpo) This logic should move out of blogs and pages and into content manager //TODO: (erikpo) This logic should move out of blogs and pages and into content manager
if (blogPost.Published != null && blogPost.Published.Value >= DateTime.UtcNow) //if (blogPost.Published != null && blogPost.Published.Value >= DateTime.UtcNow)
_contentManager.Unpublish(blogPost.ContentItem); // _contentManager.Unpublish(blogPost.ContentItem);
blogPost.Published = publishDate; //blogPost.Published = publishDate;
} }
public void Unpublish(BlogPost blogPost) { public void Unpublish(BlogPost blogPost) {
_contentManager.Unpublish(blogPost.ContentItem); _contentManager.Unpublish(blogPost.ContentItem);
//TODO: (erikpo) Not sure if this is needed or not
blogPost.Published = null;
} }
private IContentQuery<ContentItem, CommonRecord> GetBlogQuery(ContentPart<BlogRecord> blog, VersionOptions versionOptions) { private IContentQuery<ContentItem, CommonRecord> GetBlogQuery(ContentPart<BlogRecord> blog, VersionOptions versionOptions) {

View File

@@ -9,7 +9,7 @@ namespace Orchard.Comments.Models {
public CommentHandler(IRepository<CommentRecord> commentsRepository) { public CommentHandler(IRepository<CommentRecord> commentsRepository) {
Filters.Add(new ActivatingFilter<Comment>(CommentDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<Comment>(CommentDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<CommonAspect>(CommentDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonAspect>(CommentDriver.ContentType.Name));
Filters.Add(new StorageFilter<CommentRecord>(commentsRepository)); Filters.Add(StorageFilter.For(commentsRepository));
} }
} }
} }

View File

@@ -8,7 +8,7 @@ namespace Orchard.Comments.Models {
public CommentSettingsHandler(IRepository<CommentSettingsRecord> repository) { public CommentSettingsHandler(IRepository<CommentSettingsRecord> repository) {
_commentSettingsRepository = repository; _commentSettingsRepository = repository;
Filters.Add(new ActivatingFilter<CommentSettings>("site")); Filters.Add(new ActivatingFilter<CommentSettings>("site"));
Filters.Add(new StorageFilter<CommentSettingsRecord>(_commentSettingsRepository)); Filters.Add(StorageFilter.For(_commentSettingsRepository));
Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings")); Filters.Add(new TemplateFilterForRecord<CommentSettingsRecord>("CommentSettings", "Parts/Comments.SiteSettings"));
OnActivated<CommentSettings>(DefaultSettings); OnActivated<CommentSettings>(DefaultSettings);
} }

View File

@@ -15,7 +15,7 @@ namespace Orchard.Comments.Models {
Filters.Add(new ActivatingFilter<HasComments>("sandboxpage")); Filters.Add(new ActivatingFilter<HasComments>("sandboxpage"));
Filters.Add(new ActivatingFilter<HasComments>("blogpost")); Filters.Add(new ActivatingFilter<HasComments>("blogpost"));
Filters.Add(new StorageFilter<HasCommentsRecord>(hasCommentsRepository)); Filters.Add(StorageFilter.For(hasCommentsRepository));
OnActivated<HasComments>((ctx, x) => { OnActivated<HasComments>((ctx, x) => {
x.CommentsActive = true; x.CommentsActive = true;

View File

@@ -1,5 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Orchard.Comments.Models; using Orchard.Comments.Models;
@@ -10,7 +9,6 @@ using Orchard.ContentManagement;
using Orchard.Security; using Orchard.Security;
using Orchard.Services; using Orchard.Services;
using Orchard.Settings; using Orchard.Settings;
using Orchard.UI.Notify;
namespace Orchard.Comments.Services { namespace Orchard.Comments.Services {
public interface ICommentService : IDependency { public interface ICommentService : IDependency {
@@ -39,25 +37,20 @@ namespace Orchard.Comments.Services {
public virtual int CommentedOn { get; set; } public virtual int CommentedOn { get; set; }
} }
[UsedImplicitly]
public class CommentService : ICommentService { public class CommentService : ICommentService {
private readonly IRepository<ClosedCommentsRecord> _closedCommentsRepository; private readonly IRepository<ClosedCommentsRecord> _closedCommentsRepository;
private readonly IClock _clock;
private readonly ICommentValidator _commentValidator; private readonly ICommentValidator _commentValidator;
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly IClock _clock;
public CommentService(IRepository<CommentRecord> commentRepository, public CommentService(IRepository<ClosedCommentsRecord> closedCommentsRepository,
IRepository<ClosedCommentsRecord> closedCommentsRepository,
IRepository<HasCommentsRecord> hasCommentsRepository,
ICommentValidator commentValidator,
IContentManager contentManager,
IClock clock, IClock clock,
IAuthorizer authorizer, ICommentValidator commentValidator,
INotifier notifier) { IContentManager contentManager) {
_closedCommentsRepository = closedCommentsRepository; _closedCommentsRepository = closedCommentsRepository;
_clock = clock;
_commentValidator = commentValidator; _commentValidator = commentValidator;
_contentManager = contentManager; _contentManager = contentManager;
_clock = clock;
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
} }

View File

@@ -15,7 +15,7 @@ namespace Orchard.Media.Models {
public class MediaSettingsHandler : ContentHandler { public class MediaSettingsHandler : ContentHandler {
public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) { public MediaSettingsHandler(IRepository<MediaSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<MediaSettings>("site")); Filters.Add(new ActivatingFilter<MediaSettings>("site"));
Filters.Add(new StorageFilter<MediaSettingsRecord>(repository) ); Filters.Add(StorageFilter.For(repository) );
OnActivated<MediaSettings>(DefaultSettings); OnActivated<MediaSettings>(DefaultSettings);
} }

View File

@@ -180,6 +180,18 @@ namespace Orchard.Pages.Controllers {
if (!Services.Authorizer.Authorize(Permissions.EditOthersPages, page, T("Couldn't edit page"))) if (!Services.Authorizer.Authorize(Permissions.EditOthersPages, page, T("Couldn't edit page")))
return new HttpUnauthorizedResult(); return new HttpUnauthorizedResult();
// Validate form input
var model = new PageEditViewModel {
Page = Services.ContentManager.UpdateEditorModel(page, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
Services.TransactionManager.Cancel();
return View(model);
}
//TODO: (erikpo) Move this duplicate code somewhere else //TODO: (erikpo) Move this duplicate code somewhere else
DateTime? publishDate = null; DateTime? publishDate = null;
@@ -202,18 +214,6 @@ namespace Orchard.Pages.Controllers {
else else
_pageService.Unpublish(page); _pageService.Unpublish(page);
var model = new PageEditViewModel {
Page = Services.ContentManager.UpdateEditorModel(page, this)
};
TryUpdateModel(model);
if (!ModelState.IsValid) {
Services.TransactionManager.Cancel();
return View(model);
}
if (publishNow) if (publishNow)
Services.Notifier.Information(T("Page has been published")); Services.Notifier.Information(T("Page has been published"));
else if (publishDate != null) else if (publishDate != null)

View File

@@ -30,7 +30,7 @@ namespace Orchard.Pages.Models {
Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(PageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<ContentPart<CommonVersionRecord>>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<RoutableAspect>(PageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutableAspect>(PageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(PageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<BodyAspect>(PageDriver.ContentType.Name));
Filters.Add(new StorageFilter<CommonVersionRecord>(commonRepository)); Filters.Add(StorageFilter.For(commonRepository));
OnPublished<Page>((context, p) => ProcessSlug(p)); OnPublished<Page>((context, p) => ProcessSlug(p));
} }

View File

@@ -4,13 +4,16 @@ using System.Linq;
using Orchard.Pages.Models; using Orchard.Pages.Models;
using Orchard.Core.Common.Records; using Orchard.Core.Common.Records;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.Services;
namespace Orchard.Pages.Services { namespace Orchard.Pages.Services {
public class PageService : IPageService { public class PageService : IPageService {
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly IClock _clock;
public PageService(IContentManager contentManager) { public PageService(IContentManager contentManager, IClock clock) {
_contentManager = contentManager; _contentManager = contentManager;
_clock = clock;
} }
public IEnumerable<Page> Get() { public IEnumerable<Page> Get() {
@@ -73,21 +76,16 @@ namespace Orchard.Pages.Services {
public void Publish(Page page) { public void Publish(Page page) {
_contentManager.Publish(page.ContentItem); _contentManager.Publish(page.ContentItem);
//TODO: (erikpo) Not sure if this is needed or not
page.Published = DateTime.UtcNow;
} }
public void Publish(Page page, DateTime publishDate) { public void Publish(Page page, DateTime publishDate) {
//TODO: (erikpo) This logic should move out of blogs and pages and into content manager //TODO: Implement task scheduling
if (page.Published != null && page.Published.Value >= DateTime.UtcNow) //if (page.Published != null && page.Published.Value >= _clock.UtcNow)
_contentManager.Unpublish(page.ContentItem); // _contentManager.Unpublish(page.ContentItem);
page.Published = publishDate;
} }
public void Unpublish(Page page) { public void Unpublish(Page page) {
_contentManager.Unpublish(page.ContentItem); _contentManager.Unpublish(page.ContentItem);
//TODO: (erikpo) Not sure if this is needed or not
page.Published = null;
} }
} }
} }

View File

@@ -19,13 +19,13 @@ namespace Orchard.Sandbox.Models {
Filters.Add(new ActivatingFilter<CommonAspect>(SandboxPageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<CommonAspect>(SandboxPageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<RoutableAspect>(SandboxPageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<RoutableAspect>(SandboxPageDriver.ContentType.Name));
Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPageDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<BodyAspect>(SandboxPageDriver.ContentType.Name));
Filters.Add(new StorageFilter<SandboxPageRecord>(pageRepository) ); Filters.Add(StorageFilter.For(pageRepository) );
// add settings to site, and simple record-template gui // add settings to site, and simple record-template gui
Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsRecord>>("site")); Filters.Add(new ActivatingFilter<ContentPart<SandboxSettingsRecord>>("site"));
Filters.Add(new StorageFilter<SandboxSettingsRecord>(settingsRepository)); Filters.Add(StorageFilter.For(settingsRepository));
Filters.Add(new TemplateFilterForRecord<SandboxSettingsRecord>("SandboxSettings", "Parts/Sandbox.SiteSettings")); Filters.Add(new TemplateFilterForRecord<SandboxSettingsRecord>("SandboxSettings", "Parts/Sandbox.SiteSettings"));
} }

View File

@@ -14,7 +14,7 @@ namespace Orchard.Tags.Models {
public class TagSettingsHandler : ContentHandler { public class TagSettingsHandler : ContentHandler {
public TagSettingsHandler(IRepository<TagSettingsRecord> repository) { public TagSettingsHandler(IRepository<TagSettingsRecord> repository) {
Filters.Add(new ActivatingFilter<TagSettings>("site")); Filters.Add(new ActivatingFilter<TagSettings>("site"));
Filters.Add(new StorageFilter<TagSettingsRecord>(repository)); Filters.Add(StorageFilter.For(repository));
Filters.Add(new TemplateFilterForRecord<TagSettingsRecord>("TagSettings", "Parts/Tags.SiteSettings")); Filters.Add(new TemplateFilterForRecord<TagSettingsRecord>("TagSettings", "Parts/Tags.SiteSettings"));
OnActivated<TagSettings>(DefaultSettings); OnActivated<TagSettings>(DefaultSettings);
} }

View File

@@ -6,7 +6,7 @@ namespace Orchard.Users.Models {
public class UserHandler : ContentHandler { public class UserHandler : ContentHandler {
public UserHandler(IRepository<UserRecord> repository) { public UserHandler(IRepository<UserRecord> repository) {
Filters.Add(new ActivatingFilter<User>(UserDriver.ContentType.Name)); Filters.Add(new ActivatingFilter<User>(UserDriver.ContentType.Name));
Filters.Add(new StorageFilter<UserRecord>(repository)); Filters.Add(StorageFilter.For(repository));
} }
} }
} }

View File

@@ -17,6 +17,12 @@ namespace Orchard.ContentManagement.Handlers {
protected readonly IRepository<TRecord> _repository; protected readonly IRepository<TRecord> _repository;
public StorageFilter(IRepository<TRecord> repository) { public StorageFilter(IRepository<TRecord> repository) {
if (this.GetType() == typeof(StorageFilter<TRecord>) && typeof(TRecord).IsSubclassOf(typeof(ContentPartVersionRecord))) {
throw new ArgumentException(
string.Format("Use {0} (or {1}.For<TRecord>()) for versionable record types", typeof (StorageVersionFilter<>).Name, typeof(StorageFilter).Name),
"repository");
}
_repository = repository; _repository = repository;
} }