Correcting RolesPart display in User views

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-10-05 14:45:12 -07:00
parent 3e93c19faa
commit 8ef28802a7
4 changed files with 28 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
@model UserRolesViewModel
@using Orchard.Roles.ViewModels
<fieldset>
<legend>@T("Roles")</legend>
@if (Model.Roles.Count > 0) {
@@ -8,14 +9,18 @@
if (string.Equals(entry.Name, "Authenticated", StringComparison.OrdinalIgnoreCase) || string.Equals(entry.Name, "Anonymous", StringComparison.OrdinalIgnoreCase)) {
continue;
}
Html.Hidden("Roles[" + index + "].RoleId", entry.RoleId);
Html.Hidden("Roles[" + index + "].Name", entry.Name);
@Html.Hidden("Roles[" + index + "].RoleId", entry.RoleId)
@Html.Hidden("Roles[" + index + "].Name", entry.Name)
<div>
@Html.CheckBox("Roles[" + index + "].Granted", entry.Granted)
<label class="forcheckbox" for="@"Roles[" + index + "]_Granted"">@entry.Name</label>
<label class="forcheckbox" for="@Html.FieldIdFor(m => m.Roles[index].Granted)">@entry.Name</label>
</div>
@++index;
index++;
}
}
else {<p>@T("There are no roles.")</p>}
else {
<p>@T("There are no roles.")</p>
}
</fieldset>

View File

@@ -105,8 +105,10 @@ namespace Orchard.Users.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageUsers, T("Not authorized to manage users")))
return new HttpUnauthorizedResult();
var user = Services.ContentManager.Get<UserPart>(id);
return View(new UserEditViewModel {
User = Services.ContentManager.Get<UserPart>(id)
User = Services.ContentManager.BuildEditorModel(user)
});
}
@@ -115,8 +117,9 @@ namespace Orchard.Users.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageUsers, T("Not authorized to manage users")))
return new HttpUnauthorizedResult();
var user = Services.ContentManager.Get(id);
var model = new UserEditViewModel {
User = Services.ContentManager.Get<UserPart>(id)
User = Services.ContentManager.UpdateEditorModel(user, this)
};
TryUpdateModel(model);

View File

@@ -28,6 +28,8 @@
@Html.ValidationMessageFor(m=>m.ConfirmPassword, "*")
</fieldset>
@Display(Model.User)
<fieldset>
<input class="button primaryAction" type="submit" value="@T("Add")" />
</fieldset>

View File

@@ -16,6 +16,8 @@
@Html.ValidationMessageFor(m=>m.Email, "*")
</fieldset>
@Display(Model.User)
<fieldset>
<input class="button primaryAction" type="submit" value="@T("Save") " />
</fieldset>