* New features:
- New Client at estimation, ala ajax - Admins can now edit user's profiles
This commit is contained in:
parent
d9728c5998
commit
0755dd62b3
33 changed files with 634 additions and 234 deletions
|
|
@ -199,17 +199,20 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Profile the specified model.
|
||||
/// Profile the specified user.
|
||||
/// </summary>
|
||||
/// <param name="model">Model.</param>
|
||||
/// <param name="user">User name.</param>
|
||||
[Authorize]
|
||||
[HttpGet]
|
||||
public ActionResult Profile (Profile model)
|
||||
public ActionResult Profile (string user)
|
||||
{
|
||||
string username = Membership.GetUser ().UserName;
|
||||
ViewData ["UserName"] = username;
|
||||
model = new Profile (ProfileBase.Create (username));
|
||||
model.RememberMe = FormsAuthentication.GetAuthCookie (username, true) == null;
|
||||
ViewData ["ProfileUserName"] = user;
|
||||
string logdu = Membership.GetUser ().UserName;
|
||||
ViewData ["UserName"] = logdu;
|
||||
if (user == null)
|
||||
user = logdu;
|
||||
Profile model= new Profile (ProfileBase.Create (user));
|
||||
model.RememberMe = FormsAuthentication.GetAuthCookie (user, true) == null;
|
||||
return View (model);
|
||||
}
|
||||
|
||||
|
|
@ -221,10 +224,17 @@ namespace Yavsc.Controllers
|
|||
[Authorize]
|
||||
[HttpPost]
|
||||
// ASSERT("Membership.GetUser ().UserName is made of simple characters, no slash nor backslash"
|
||||
public ActionResult Profile (Profile model, HttpPostedFileBase AvatarFile)
|
||||
public ActionResult Profile (string username, Profile model, HttpPostedFileBase AvatarFile)
|
||||
{
|
||||
string username = Membership.GetUser ().UserName;
|
||||
ViewData ["UserName"] = username;
|
||||
|
||||
string logdu = Membership.GetUser ().UserName;
|
||||
ViewData ["UserName"] = logdu;
|
||||
if (username != logdu)
|
||||
if (!Roles.IsUserInRole ("Admin"))
|
||||
if (!Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("Your are not authorized to modify this profile");
|
||||
|
||||
ProfileBase prtoup = ProfileBase.Create (username);
|
||||
if (AvatarFile != null) {
|
||||
// if said valid, move as avatar file
|
||||
// else invalidate the model
|
||||
|
|
@ -244,24 +254,24 @@ namespace Yavsc.Controllers
|
|||
*/
|
||||
if (ModelState.IsValid) {
|
||||
if (model.avatar != null)
|
||||
HttpContext.Profile.SetPropertyValue ("avatar", model.avatar);
|
||||
HttpContext.Profile.SetPropertyValue ("Address", model.Address);
|
||||
HttpContext.Profile.SetPropertyValue ("BlogTitle", model.BlogTitle);
|
||||
HttpContext.Profile.SetPropertyValue ("BlogVisible", model.BlogVisible);
|
||||
HttpContext.Profile.SetPropertyValue ("CityAndState", model.CityAndState);
|
||||
HttpContext.Profile.SetPropertyValue ("ZipCode", model.ZipCode);
|
||||
HttpContext.Profile.SetPropertyValue ("Country", model.Country);
|
||||
HttpContext.Profile.SetPropertyValue ("WebSite", model.WebSite);
|
||||
HttpContext.Profile.SetPropertyValue ("Name", model.Name);
|
||||
HttpContext.Profile.SetPropertyValue ("Phone", model.Phone);
|
||||
HttpContext.Profile.SetPropertyValue ("Mobile", model.Mobile);
|
||||
HttpContext.Profile.SetPropertyValue ("BankCode", model.BankCode);
|
||||
HttpContext.Profile.SetPropertyValue ("WicketCode", model.WicketCode);
|
||||
HttpContext.Profile.SetPropertyValue ("AccountNumber", model.AccountNumber);
|
||||
HttpContext.Profile.SetPropertyValue ("BankedKey", model.BankedKey);
|
||||
HttpContext.Profile.SetPropertyValue ("BIC", model.BIC);
|
||||
HttpContext.Profile.SetPropertyValue ("IBAN", model.IBAN);
|
||||
HttpContext.Profile.Save ();
|
||||
prtoup.SetPropertyValue ("avatar", model.avatar);
|
||||
prtoup.SetPropertyValue ("Address", model.Address);
|
||||
prtoup.SetPropertyValue ("BlogTitle", model.BlogTitle);
|
||||
prtoup.SetPropertyValue ("BlogVisible", model.BlogVisible);
|
||||
prtoup.SetPropertyValue ("CityAndState", model.CityAndState);
|
||||
prtoup.SetPropertyValue ("ZipCode", model.ZipCode);
|
||||
prtoup.SetPropertyValue ("Country", model.Country);
|
||||
prtoup.SetPropertyValue ("WebSite", model.WebSite);
|
||||
prtoup.SetPropertyValue ("Name", model.Name);
|
||||
prtoup.SetPropertyValue ("Phone", model.Phone);
|
||||
prtoup.SetPropertyValue ("Mobile", model.Mobile);
|
||||
prtoup.SetPropertyValue ("BankCode", model.BankCode);
|
||||
prtoup.SetPropertyValue ("WicketCode", model.WicketCode);
|
||||
prtoup.SetPropertyValue ("AccountNumber", model.AccountNumber);
|
||||
prtoup.SetPropertyValue ("BankedKey", model.BankedKey);
|
||||
prtoup.SetPropertyValue ("BIC", model.BIC);
|
||||
prtoup.SetPropertyValue ("IBAN", model.IBAN);
|
||||
prtoup.Save ();
|
||||
FormsAuthentication.SetAuthCookie (username, model.RememberMe);
|
||||
ViewData ["Message"] = "Profile enregistré, cookie modifié.";
|
||||
|
||||
|
|
|
|||
|
|
@ -159,12 +159,14 @@ namespace Yavsc.Controllers
|
|||
[Authorize(Roles="Admin")]
|
||||
public ActionResult RemoveUser (string username, string submitbutton)
|
||||
{
|
||||
ViewData ["usertoremove"] = username;
|
||||
if (submitbutton == "Supprimer") {
|
||||
Membership.DeleteUser (username);
|
||||
ViewData["Message"]=
|
||||
string.Format("utilisateur \"{0}\" supprimé",username);
|
||||
ViewData ["usertoremove"] = null;
|
||||
}
|
||||
return RedirectToAction("UserList");
|
||||
return View ();
|
||||
}
|
||||
/// <summary>
|
||||
/// Removes the role.
|
||||
|
|
|
|||
|
|
@ -48,11 +48,20 @@ namespace Yavsc.Controllers
|
|||
/// Estimates this instance.
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
public ActionResult Estimates ()
|
||||
public ActionResult Estimates (string client)
|
||||
{
|
||||
string username = Membership.GetUser ().UserName;
|
||||
|
||||
return View (wfmgr.GetEstimates (username));
|
||||
Estimate [] estims = wfmgr.GetUserEstimates (username);
|
||||
ViewData ["UserName"] = username;
|
||||
ViewData ["ResponsibleCount"] =
|
||||
Array.FindAll (
|
||||
estims,
|
||||
x => x.Responsible == username).Length;
|
||||
ViewData ["ClientCount"] =
|
||||
Array.FindAll (
|
||||
estims,
|
||||
x => x.Client == username).Length;
|
||||
return View (estims);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -63,6 +72,7 @@ namespace Yavsc.Controllers
|
|||
[Authorize]
|
||||
public ActionResult Estimate (Estimate model, string submit)
|
||||
{
|
||||
string username = Membership.GetUser().UserName;
|
||||
// Obsolete, set in master page
|
||||
ViewData ["WebApiBase"] = Url.Content(Yavsc.WebApiConfig.UrlPrefixRelative);
|
||||
ViewData ["WABASEWF"] = ViewData ["WebApiBase"] + "/WorkFlow";
|
||||
|
|
@ -75,23 +85,23 @@ namespace Yavsc.Controllers
|
|||
}
|
||||
model = f;
|
||||
ModelState.Clear ();
|
||||
string username = HttpContext.User.Identity.Name;
|
||||
if (username != model.Responsible
|
||||
&& username != model.Client
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to view this estimate");
|
||||
}
|
||||
} else if (model.Id == 0) {
|
||||
if (string.IsNullOrWhiteSpace(model.Responsible))
|
||||
model.Responsible = username;
|
||||
}
|
||||
} else {
|
||||
string username = Membership.GetUser().UserName;
|
||||
|
||||
if (model.Id == 0) // if (submit == "Create")
|
||||
if (string.IsNullOrWhiteSpace (model.Responsible))
|
||||
model.Responsible = username;
|
||||
if (username != model.Responsible
|
||||
&& !Roles.IsUserInRole ("FrontOffice"))
|
||||
throw new UnauthorizedAccessException ("You're not allowed to modify this estimate");
|
||||
if (model.Id == 0) {
|
||||
model.Responsible = username;
|
||||
ModelState.Clear ();
|
||||
// TODO better, or ensure that the model state is checked
|
||||
// before insertion
|
||||
}
|
||||
|
||||
if (ModelState.IsValid) {
|
||||
if (model.Id == 0)
|
||||
model = wfmgr.CreateEstimate (
|
||||
|
|
|
|||
|
|
@ -86,9 +86,13 @@ namespace Yavsc.Controllers
|
|||
/// </summary>
|
||||
public ActionResult Index ()
|
||||
{
|
||||
string startPage = WebConfigurationManager.AppSettings ["StartPage"];
|
||||
/*
|
||||
* A very bad idea (a redirect permanent as home page):
|
||||
*
|
||||
* string startPage = WebConfigurationManager.AppSettings ["StartPage"];
|
||||
if (startPage != null)
|
||||
Redirect (startPage);
|
||||
*/
|
||||
ViewData ["Message"] = LocalizedText.Welcome;
|
||||
return View ();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue