Merge branch '7.1.0' of https://github.com/umbraco/Umbraco-CMS into 7.1.0
This commit is contained in:
@@ -72,7 +72,16 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.IsTrue(ddoc.HasProperty(Constants.Conventions.Content.UrlAlias));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
[Test]
|
||||
public void U4_4559()
|
||||
{
|
||||
var doc = GetDynamicNode(1174);
|
||||
var result = doc.AncestorOrSelf(1);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1046, result.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test class to mimic UmbracoHelper when returning docs
|
||||
/// </summary>
|
||||
public class TestHelper
|
||||
|
||||
@@ -508,6 +508,15 @@ namespace Umbraco.Tests.PublishedContent
|
||||
Assert.AreEqual(1173, result.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void U4_4559()
|
||||
{
|
||||
var doc = GetNode(1174);
|
||||
var result = doc.AncestorOrSelf(1);
|
||||
Assert.IsNotNull(result);
|
||||
Assert.AreEqual(1046, result.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ancestors_Or_Self()
|
||||
{
|
||||
|
||||
@@ -24,6 +24,11 @@ namespace Umbraco.Web.Controllers
|
||||
MembershipCreateStatus status;
|
||||
var member = Members.RegisterMember(model, out status, model.LoginOnSuccess);
|
||||
|
||||
// Save the password
|
||||
var memberService = Services.MemberService;
|
||||
var m = memberService.GetByUsername(member.UserName);
|
||||
memberService.SavePassword(m, model.Password);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case MembershipCreateStatus.Success:
|
||||
|
||||
69
src/Umbraco.Web/Models/PublishedProperty.cs
Normal file
69
src/Umbraco.Web/Models/PublishedProperty.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Umbraco.Web.Models
|
||||
{
|
||||
public static class PublishedProperty
|
||||
{
|
||||
/// <summary>
|
||||
/// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType.
|
||||
/// </summary>
|
||||
/// <param name="propertyTypes">The published property types.</param>
|
||||
/// <param name="properties">The properties.</param>
|
||||
/// <param name="map">A mapping function.</param>
|
||||
/// <returns>A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType
|
||||
/// and taking values from the collection of Property.</returns>
|
||||
/// <remarks>Ensures that all conversions took place correctly.</remarks>
|
||||
internal static IEnumerable<IPublishedProperty> MapProperties(
|
||||
IEnumerable<PublishedPropertyType> propertyTypes, IEnumerable<Property> properties,
|
||||
Func<PublishedPropertyType, Property, object, IPublishedProperty> map)
|
||||
{
|
||||
var peResolver = PropertyEditorResolver.Current;
|
||||
var dtService = ApplicationContext.Current.Services.DataTypeService;
|
||||
return MapProperties(propertyTypes, properties, peResolver, dtService, map);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maps a collection of Property to a collection of IPublishedProperty for a specified collection of PublishedPropertyType.
|
||||
/// </summary>
|
||||
/// <param name="propertyTypes">The published property types.</param>
|
||||
/// <param name="properties">The properties.</param>
|
||||
/// <param name="map">A mapping function.</param>
|
||||
/// <param name="propertyEditorResolver">A PropertyEditorResolver instance.</param>
|
||||
/// <param name="dataTypeService">An IDataTypeService instance.</param>
|
||||
/// <returns>A collection of IPublishedProperty corresponding to the collection of PublishedPropertyType
|
||||
/// and taking values from the collection of Property.</returns>
|
||||
/// <remarks>Ensures that all conversions took place correctly.</remarks>
|
||||
internal static IEnumerable<IPublishedProperty> MapProperties(
|
||||
IEnumerable<PublishedPropertyType> propertyTypes, IEnumerable<Property> properties,
|
||||
PropertyEditorResolver propertyEditorResolver, IDataTypeService dataTypeService,
|
||||
Func<PublishedPropertyType, Property, object, IPublishedProperty> map)
|
||||
{
|
||||
return propertyTypes
|
||||
.Select(x =>
|
||||
{
|
||||
var p = properties.SingleOrDefault(xx => xx.Alias == x.PropertyTypeAlias);
|
||||
var v = p == null || p.Value == null ? null : p.Value;
|
||||
if (v != null)
|
||||
{
|
||||
var e = propertyEditorResolver.GetByAlias(x.PropertyEditorAlias);
|
||||
if (e != null)
|
||||
v = e.ValueEditor.ConvertDbToString(p, p.PropertyType, dataTypeService);
|
||||
}
|
||||
// fixme - means that the IPropertyValueConverter will always get a string
|
||||
// fixme and never an int or DateTime that's in the DB unless the value editor has
|
||||
// fixme a way to say it's OK to use what's in the DB?
|
||||
|
||||
return map(x, p, v);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@ using System.Web.Security;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
using Umbraco.Web.Models;
|
||||
|
||||
namespace Umbraco.Web.PublishedCache
|
||||
@@ -18,7 +20,7 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
private readonly IMember _member;
|
||||
private readonly MembershipUser _membershipUser;
|
||||
private readonly List<IPublishedProperty> _properties;
|
||||
private readonly IPublishedProperty[] _properties;
|
||||
private readonly PublishedContentType _publishedMemberType;
|
||||
|
||||
public MemberPublishedContent(IMember member, MembershipUser membershipUser)
|
||||
@@ -28,21 +30,18 @@ namespace Umbraco.Web.PublishedCache
|
||||
|
||||
_member = member;
|
||||
_membershipUser = membershipUser;
|
||||
_properties = new List<IPublishedProperty>();
|
||||
_publishedMemberType = PublishedContentType.Get(PublishedItemType.Member, _member.ContentTypeAlias);
|
||||
if (_publishedMemberType == null)
|
||||
{
|
||||
throw new InvalidOperationException("Could not get member type with alias " + _member.ContentTypeAlias);
|
||||
}
|
||||
foreach (var propType in _publishedMemberType.PropertyTypes)
|
||||
{
|
||||
var val = _member.Properties.Any(x => x.Alias == propType.PropertyTypeAlias) == false
|
||||
? string.Empty
|
||||
: _member.Properties[propType.PropertyTypeAlias].Value;
|
||||
_properties.Add(new RawValueProperty(propType, val ?? string.Empty));
|
||||
}
|
||||
|
||||
_properties = PublishedProperty.MapProperties(_publishedMemberType.PropertyTypes, _member.Properties,
|
||||
(t, p, v) => new RawValueProperty(t, v ?? string.Empty))
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
|
||||
#region Membership provider member properties
|
||||
public string Email
|
||||
{
|
||||
|
||||
@@ -352,6 +352,7 @@
|
||||
<Compile Include="Models\ImageCropData.cs" />
|
||||
<Compile Include="Models\IRenderModel.cs" />
|
||||
<Compile Include="Models\PostRedirectModel.cs" />
|
||||
<Compile Include="Models\PublishedProperty.cs" />
|
||||
<Compile Include="Mvc\RedirectToUmbracoUrlResult.cs" />
|
||||
<Compile Include="PublishedCache\MemberPublishedContent.cs" />
|
||||
<Compile Include="PublishedCache\RawValueProperty.cs" />
|
||||
|
||||
Reference in New Issue
Block a user