- Migrating Email module to the new shape API.

--HG--
branch : dev
This commit is contained in:
Suha Can 2010-10-15 15:16:41 -07:00
parent cf328c0807
commit 3d72236e81
6 changed files with 23 additions and 9 deletions

View File

@ -9,6 +9,8 @@ namespace Orchard.Email.Drivers {
// Thus the encryption/decryption will be done when accessing the part's property
public class SmtpSettingsPartDriver : ContentPartDriver<SmtpSettingsPart> {
private const string TemplateName = "Parts/SmtpSettings";
public SmtpSettingsPartDriver() {
T = NullLocalizer.Instance;
}
@ -18,12 +20,14 @@ namespace Orchard.Email.Drivers {
protected override string Prefix { get { return "SmtpSettings"; } }
protected override DriverResult Editor(SmtpSettingsPart part, dynamic shapeHelper) {
return ContentPartTemplate(part, "Parts/Smtp.SiteSettings");
return ContentShape("Parts_SmtpSettings_Editor",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
}
protected override DriverResult Editor(SmtpSettingsPart part, IUpdateModel updater, dynamic shapeHelper) {
updater.TryUpdateModel(part, Prefix, null, null);
return Editor(part, shapeHelper);
return ContentShape("Parts_SmtpSettings_Editor",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: part, Prefix: Prefix));
}
}
}

View File

@ -82,7 +82,7 @@
<Content Include="Views\Web.config" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\EditorTemplates\Parts\Smtp.SiteSettings.cshtml" />
<Content Include="Views\EditorTemplates\Parts\SmtpSettings.cshtml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Orchard\Orchard.Framework.csproj">
@ -98,6 +98,9 @@
<Name>Orchard.Users</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Placement.info" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,3 @@
<Placement>
<Place Parts_SmtpSettings_Editor="Primary:10"/>
</Placement>

View File

@ -36,12 +36,8 @@ namespace Orchard.Tags.Drivers {
if (!_authorizationService.TryCheckAccess(Permissions.ApplyTag, CurrentUser, part))
return null;
var model = new EditTagsViewModel {
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
};
return ContentShape("Parts_Tags_Editor",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: BuildEditorViewModel(part), Prefix: Prefix));
}
protected override DriverResult Editor(TagsPart part, IUpdateModel updater, dynamic shapeHelper) {
@ -59,5 +55,11 @@ namespace Orchard.Tags.Drivers {
return ContentShape("Parts_Tags_Editor",
() => shapeHelper.EditorTemplate(TemplateName: TemplateName, Model: model, Prefix: Prefix));
}
private static EditTagsViewModel BuildEditorViewModel(TagsPart part) {
return new EditTagsViewModel {
Tags = string.Join(", ", part.CurrentTags.Select((t, i) => t.TagName).ToArray())
};
}
}
}

View File

@ -113,7 +113,9 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Placement.info" />
<Content Include="Placement.info">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />