Skip to content

Commit 474c939

Browse files
committed
Merge branch '2.5' into task/webscheduler
Conflicts: src/Libraries/SmartStore.Data/SmartStore.Data.csproj
2 parents 80e8123 + 13e536d commit 474c939

17 files changed

Lines changed: 345 additions & 31 deletions

File tree

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* #727 Web-API: Option to deactivate TimestampOlderThanLastRequest validation
1414
* #731 Web-API: Allow deletion and inserting of product category and manufacturer assignments
1515
* #733 Option to set a display order for homepage products
16+
* #607 HTML capable full description for payment methods displayed in checkout
1617

1718
### Improvements
1819
* (Perf) Implemented static caches for URL aliases and localized properties. Increases app startup and request speed by up to 30%.

src/Libraries/SmartStore.Core/Domain/Payments/PaymentMethod.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
using System.Runtime.Serialization;
22
using SmartStore.Core.Domain.Common;
3+
using SmartStore.Core.Domain.Localization;
34

45
namespace SmartStore.Core.Domain.Payments
56
{
67
/// <summary>
78
/// Represents a payment method
89
/// </summary>
910
[DataContract]
10-
public partial class PaymentMethod : BaseEntity
11+
public partial class PaymentMethod : BaseEntity, ILocalizedEntity
1112
{
1213
/// <summary>
1314
/// Gets or sets the payment method system name
@@ -88,5 +89,11 @@ public AmountRestrictionContextType AmountRestrictionContext
8889
this.AmountRestrictionContextId = (int)value;
8990
}
9091
}
92+
93+
/// <summary>
94+
/// Gets or sets the full description
95+
/// </summary>
96+
[DataMember]
97+
public string FullDescription { get; set; }
9198
}
9299
}

src/Libraries/SmartStore.Data/Mapping/Payments/PaymentMethodMap.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public PaymentMethodMap()
1919
this.Property(x => x.MinimumOrderAmount).HasPrecision(18, 4);
2020
this.Property(x => x.MaximumOrderAmount).HasPrecision(18, 4);
2121

22+
this.Property(x => x.FullDescription).HasMaxLength(4000);
23+
2224
this.Ignore(x => x.CountryExclusionContext);
2325
this.Ignore(x => x.AmountRestrictionContext);
2426
}

src/Libraries/SmartStore.Data/Migrations/201507210952098_PaymentMethodDescription.Designer.cs

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
namespace SmartStore.Data.Migrations
2+
{
3+
using System;
4+
using System.Data.Entity.Migrations;
5+
using SmartStore.Data.Setup;
6+
7+
public partial class PaymentMethodDescription : DbMigration, ILocaleResourcesProvider, IDataSeeder<SmartObjectContext>
8+
{
9+
public override void Up()
10+
{
11+
AddColumn("dbo.PaymentMethod", "FullDescription", c => c.String(maxLength: 4000));
12+
}
13+
14+
public override void Down()
15+
{
16+
DropColumn("dbo.PaymentMethod", "FullDescription");
17+
}
18+
19+
public bool RollbackOnFailure
20+
{
21+
get { return false; }
22+
}
23+
24+
public void Seed(SmartObjectContext context)
25+
{
26+
context.MigrateLocaleResources(MigrateLocaleResources);
27+
}
28+
29+
public void MigrateLocaleResources(LocaleResourcesBuilder builder)
30+
{
31+
builder.AddOrUpdate("Admin.Configuration.Payment.Methods.ShortDescription",
32+
"Short description",
33+
"Kurzbeschreibung",
34+
"Specifies a short description of the payment method.",
35+
"Legt eine Kurzbeschreibung der Zahlungsmethode fest.");
36+
37+
builder.AddOrUpdate("Admin.Configuration.Payment.Methods.FullDescription",
38+
"Full description",
39+
"Langtext",
40+
"Specifies a full description of the payment method. It appears in the payment list in checkout.",
41+
"Legt eine vollständige Beschreibung der Zahlungsmethode fest. Sie erscheint in der Zahlungsliste im Kassenbereich.");
42+
}
43+
}
44+
}

src/Libraries/SmartStore.Data/Migrations/201507210952098_PaymentMethodDescription.resx

Lines changed: 126 additions & 0 deletions
Large diffs are not rendered by default.

src/Libraries/SmartStore.Data/SmartStore.Data.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@
303303
<Compile Include="Migrations\201507200832223_SortFilterHomepageProducts.Designer.cs">
304304
<DependentUpon>201507200832223_SortFilterHomepageProducts.cs</DependentUpon>
305305
</Compile>
306+
<Compile Include="Migrations\201507210952098_PaymentMethodDescription.cs" />
307+
<Compile Include="Migrations\201507210952098_PaymentMethodDescription.Designer.cs">
308+
<DependentUpon>201507210952098_PaymentMethodDescription.cs</DependentUpon>
309+
</Compile>
306310
<Compile Include="Migrations\201507242008201_WebScheduler.cs" />
307311
<Compile Include="Migrations\201507242008201_WebScheduler.Designer.cs">
308312
<DependentUpon>201507242008201_WebScheduler.cs</DependentUpon>
@@ -582,6 +586,9 @@
582586
<EmbeddedResource Include="Migrations\201507200832223_SortFilterHomepageProducts.resx">
583587
<DependentUpon>201507200832223_SortFilterHomepageProducts.cs</DependentUpon>
584588
</EmbeddedResource>
589+
<EmbeddedResource Include="Migrations\201507210952098_PaymentMethodDescription.resx">
590+
<DependentUpon>201507210952098_PaymentMethodDescription.cs</DependentUpon>
591+
</EmbeddedResource>
585592
<EmbeddedResource Include="Migrations\201507242008201_WebScheduler.resx">
586593
<DependentUpon>201507242008201_WebScheduler.cs</DependentUpon>
587594
</EmbeddedResource>

src/Presentation/SmartStore.Web/Administration/Controllers/PaymentController.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using SmartStore.Services.Shipping;
1515
using SmartStore.Web.Framework;
1616
using SmartStore.Web.Framework.Controllers;
17+
using SmartStore.Web.Framework.Mvc;
1718
using SmartStore.Web.Framework.Plugins;
1819

1920
namespace SmartStore.Admin.Controllers
@@ -32,6 +33,7 @@ public partial class PaymentController : AdminControllerBase
3233
private readonly ICustomerService _customerService;
3334
private readonly IShippingService _shippingService;
3435
private readonly ICountryService _countryService;
36+
private readonly ILocalizedEntityService _localizedEntityService;
3537

3638
#endregion
3739

@@ -46,7 +48,8 @@ public PaymentController(
4648
ILanguageService languageService,
4749
ICustomerService customerService,
4850
IShippingService shippingService,
49-
ICountryService countryService)
51+
ICountryService countryService,
52+
ILocalizedEntityService localizedEntityService)
5053
{
5154
this._services = services;
5255
this._paymentService = paymentService;
@@ -57,6 +60,7 @@ public PaymentController(
5760
this._customerService = customerService;
5861
this._shippingService = shippingService;
5962
this._countryService = countryService;
63+
this._localizedEntityService = localizedEntityService;
6064
}
6165

6266
#endregion
@@ -102,6 +106,8 @@ private void PreparePaymentMethodEditModel(PaymentMethodEditModel model, Payment
102106

103107
model.CountryExclusionContext = paymentMethod.CountryExclusionContext;
104108
model.AmountRestrictionContext = paymentMethod.AmountRestrictionContext;
109+
110+
model.FullDescription = paymentMethod.FullDescription;
105111
}
106112
}
107113

@@ -165,12 +171,23 @@ public ActionResult Edit(string systemName)
165171
var provider = _paymentService.LoadPaymentMethodBySystemName(systemName);
166172
var paymentMethod = _paymentService.GetPaymentMethodBySystemName(systemName);
167173

168-
var model = _pluginMediator.ToProviderModel<IPaymentMethod, PaymentMethodEditModel>(provider, true);
174+
var model = new PaymentMethodEditModel();
175+
var providerModel = _pluginMediator.ToProviderModel<IPaymentMethod, ProviderModel>(provider, true);
176+
177+
model.SystemName = providerModel.SystemName;
178+
model.IconUrl = providerModel.IconUrl;
179+
model.FriendlyName = providerModel.FriendlyName;
180+
model.Description = providerModel.Description;
169181

170182
AddLocales(_languageService, model.Locales, (locale, languageId) =>
171183
{
172184
locale.FriendlyName = _pluginMediator.GetLocalizedFriendlyName(provider.Metadata, languageId, false);
173185
locale.Description = _pluginMediator.GetLocalizedDescription(provider.Metadata, languageId, false);
186+
187+
if (paymentMethod != null)
188+
{
189+
locale.FullDescription = paymentMethod.GetLocalized(x => x.FullDescription, languageId, false, false);
190+
}
174191
});
175192

176193
PreparePaymentMethodEditModel(model, paymentMethod);
@@ -191,12 +208,6 @@ public ActionResult Edit(string systemName, bool continueEditing, PaymentMethodE
191208
_pluginMediator.SetSetting(provider.Metadata, "FriendlyName", model.FriendlyName);
192209
_pluginMediator.SetSetting(provider.Metadata, "Description", model.Description);
193210

194-
foreach (var localized in model.Locales)
195-
{
196-
_pluginMediator.SaveLocalizedValue(provider.Metadata, localized.LanguageId, "FriendlyName", localized.FriendlyName);
197-
_pluginMediator.SaveLocalizedValue(provider.Metadata, localized.LanguageId, "Description", localized.Description);
198-
}
199-
200211
var paymentMethod = _paymentService.GetPaymentMethodBySystemName(systemName);
201212

202213
if (paymentMethod == null)
@@ -212,11 +223,21 @@ public ActionResult Edit(string systemName, bool continueEditing, PaymentMethodE
212223
paymentMethod.CountryExclusionContext = model.CountryExclusionContext;
213224
paymentMethod.AmountRestrictionContext = model.AmountRestrictionContext;
214225

226+
paymentMethod.FullDescription = model.FullDescription;
227+
215228
if (paymentMethod.Id == 0)
216229
_paymentService.InsertPaymentMethod(paymentMethod);
217230
else
218231
_paymentService.UpdatePaymentMethod(paymentMethod);
219232

233+
foreach (var localized in model.Locales)
234+
{
235+
_pluginMediator.SaveLocalizedValue(provider.Metadata, localized.LanguageId, "FriendlyName", localized.FriendlyName);
236+
_pluginMediator.SaveLocalizedValue(provider.Metadata, localized.LanguageId, "Description", localized.Description);
237+
238+
_localizedEntityService.SaveLocalizedValue(paymentMethod, x => x.FullDescription, localized.FullDescription, localized.LanguageId);
239+
}
240+
220241
NotifySuccess(_services.Localization.GetResource("Admin.Common.DataEditSuccess"));
221242

222243
return (continueEditing ?

src/Presentation/SmartStore.Web/Administration/Models/Payments/PaymentMethodEditModel.cs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,27 @@
22
using System.Web.Mvc;
33
using SmartStore.Core.Domain.Common;
44
using SmartStore.Web.Framework;
5+
using SmartStore.Web.Framework.Localization;
56
using SmartStore.Web.Framework.Mvc;
67

78
namespace SmartStore.Admin.Models.Payments
89
{
9-
public class PaymentMethodEditModel : ProviderModel
10+
public class PaymentMethodEditModel : EntityModelBase, ILocalizedModel<PaymentMethodLocalizedModel>
1011
{
12+
public PaymentMethodEditModel()
13+
{
14+
Locales = new List<PaymentMethodLocalizedModel>();
15+
}
16+
17+
public IList<PaymentMethodLocalizedModel> Locales { get; set; }
18+
public string IconUrl { get; set; }
19+
20+
[SmartResourceDisplayName("Common.SystemName")]
21+
public string SystemName { get; set; }
22+
23+
[SmartResourceDisplayName("Common.FriendlyName")]
24+
public string FriendlyName { get; set; }
25+
1126
[SmartResourceDisplayName("Admin.Configuration.Payment.Methods.ExcludedCustomerRole")]
1227
public string[] ExcludedCustomerRoleIds { get; set; }
1328
public List<SelectListItem> AvailableCustomerRoles { get; set; }
@@ -33,5 +48,30 @@ public class PaymentMethodEditModel : ProviderModel
3348
[SmartResourceDisplayName("Admin.Configuration.Restrictions.AmountRestrictionContext")]
3449
public AmountRestrictionContextType AmountRestrictionContext { get; set; }
3550
public List<SelectListItem> AvailableAmountRestrictionContextTypes { get; set; }
51+
52+
[SmartResourceDisplayName("Admin.Configuration.Payment.Methods.ShortDescription")]
53+
[AllowHtml]
54+
public string Description { get; set; }
55+
56+
[SmartResourceDisplayName("Admin.Configuration.Payment.Methods.FullDescription")]
57+
[AllowHtml]
58+
public string FullDescription { get; set; }
59+
}
60+
61+
62+
public class PaymentMethodLocalizedModel : ILocalizedModelLocal
63+
{
64+
public int LanguageId { get; set; }
65+
66+
[SmartResourceDisplayName("Common.FriendlyName")]
67+
public string FriendlyName { get; set; }
68+
69+
[SmartResourceDisplayName("Admin.Configuration.Payment.Methods.ShortDescription")]
70+
[AllowHtml]
71+
public string Description { get; set; }
72+
73+
[SmartResourceDisplayName("Admin.Configuration.Payment.Methods.FullDescription")]
74+
[AllowHtml]
75+
public string FullDescription { get; set; }
3676
}
3777
}

src/Presentation/SmartStore.Web/Administration/Views/Payment/Edit.cshtml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
@helper TabGeneral()
3737
{
38-
@(Html.LocalizedEditor<PaymentMethodEditModel, ProviderLocalizedModel>("paymentmethod-general-localized",
38+
@(Html.LocalizedEditor<PaymentMethodEditModel, PaymentMethodLocalizedModel>("paymentmethod-general-localized",
3939
@<table class="adminContent">
4040
<tr>
4141
<td class="adminTitle">
@@ -55,6 +55,15 @@
5555
@Html.ValidationMessageFor(model => model.Locales[item].Description)
5656
</td>
5757
</tr>
58+
<tr>
59+
<td class="adminTitle">
60+
@Html.SmartLabelFor(model => model.Locales[item].FullDescription)
61+
</td>
62+
<td class="adminData">
63+
@Html.EditorFor(model => model.Locales[item].FullDescription, Html.RichEditorFlavor())
64+
@Html.ValidationMessageFor(model => model.Locales[item].FullDescription)
65+
</td>
66+
</tr>
5867
<tr>
5968
<td colspan="2">
6069
@Html.HiddenFor(model => model.Locales[item].LanguageId)
@@ -81,6 +90,15 @@
8190
@Html.ValidationMessageFor(model => model.Description)
8291
</td>
8392
</tr>
93+
<tr>
94+
<td class="adminTitle">
95+
@Html.SmartLabelFor(model => model.FullDescription)
96+
</td>
97+
<td class="adminData">
98+
@Html.EditorFor(x => x.FullDescription, Html.RichEditorFlavor())
99+
@Html.ValidationMessageFor(model => model.FullDescription)
100+
</td>
101+
</tr>
84102
</table>
85103
))
86104
}

0 commit comments

Comments
 (0)