More improvements to registration, leaf input create, and charting

This commit is contained in:
2020-01-14 14:10:11 -05:00
parent 8452a9cce0
commit 046cda40b4
18 changed files with 180 additions and 77 deletions
+26 -13
View File
@@ -15,12 +15,14 @@ using LeafWeb.Core.Parsers;
using LeafWeb.Core.Utility;
using LeafWeb.WebCms.Models;
using LeafWeb.WebCms.Services;
using LeafWeb.WebCms.Utility;
namespace LeafWeb.WebCms.Controllers
{
public class ChartController : BaseController
{
public ActionResult Index(int? leafInputId)
public class ChartController : BaseController
{
[RequireRequestValue("leafInputId")]
public ActionResult Index(int? leafInputId)
{
if (!leafInputId.HasValue)
return View("DataError", model: "Must specify LeafInputId");
@@ -60,17 +62,28 @@ namespace LeafWeb.WebCms.Controllers
}
}
//private ChartViewModel GetTestChartViewModel()
//{
// return new ChartViewModel
// {
// AvailableCurveId = new []{"Valid", "Test"},
// LeafInputId = 2147483647,
// LeafInputIdentifier = "Chart Tests"
// };
//}
[RequireRequestValue("token")]
public ActionResult Index(string token)
{
var leafInput = DataService.GetLeafInput(token);
public ActionResult ChartCurve(int leafInputId, string curveId, bool base64 = false)
if (leafInput == null)
return View("DataError", model: "Leaf Input Token not found");
return Index(leafInput.Id);
}
//private ChartViewModel GetTestChartViewModel()
//{
// return new ChartViewModel
// {
// AvailableCurveId = new []{"Valid", "Test"},
// LeafInputId = 2147483647,
// LeafInputIdentifier = "Chart Tests"
// };
//}
public ActionResult ChartCurve(int leafInputId, string curveId, bool base64 = false)
{
var leafOutputFile = DataService.GetLeafOutput_ChartFile(leafInputId);
+20 -1
View File
@@ -8,6 +8,7 @@ using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
using LeafWeb.WebCms.App_Start;
using LeafWeb.WebCms.Models;
using Umbraco.Web;
namespace LeafWeb.WebCms.Controllers
{
@@ -37,6 +38,20 @@ namespace LeafWeb.WebCms.Controllers
if (ModelState.ContainsKey("TermsOfService"))
ModelState["TermsOfService"].Errors.Clear();
var membershipHelper = new Umbraco.Web.Security.MembershipHelper(UmbracoContext.Current);
var member = membershipHelper.GetCurrentMember();
if (member != null)
{
ModelState["Name"].Errors.Clear();
viewModel.Name = member.Name;
ModelState["Email"].Errors.Clear();
viewModel.Email = member.GetProperty("Email").Value as string;
ModelState["EmailConfirm"].Errors.Clear();
viewModel.EmailConfirm = viewModel.Email;
}
if (ModelState.IsValid) // HttpParamMatch indicates it's backing out from Confirm
{
// convert viewModel into Model
@@ -56,7 +71,11 @@ namespace LeafWeb.WebCms.Controllers
var msg = $"A data set has submitted for '{viewModel.Identifier}' from '{viewModel.SiteId}'. " + Environment.NewLine
+ $"When complete, an email will be delivered to {viewModel.Name} <{viewModel.Email}> with results.";
SetStatusMessage(HttpUtility.HtmlEncode(msg), StatusType.Success);
SetStatusMessage(
HttpUtility
.HtmlEncode(msg)
.Replace("\n", "<br/>"),
StatusType.Success);
var logger = LogManager.GetLogger(GetType());
logger.Info($"LeafInput: {leafInput.Id} Added, {leafInput.Identifier}, {leafInput.SiteId}, {leafInput.Email}");
+5 -5
View File
@@ -13,13 +13,13 @@ namespace LeafWeb.WebCms.Controllers
var member = memberService.GetByEmail(email);
if (member == null)
{
TempData["StatusMessage"] = $"User with email {email} not found.";
TempData["StatusMessage"] = $"Sorry, user with email {email} not found. Please try to register again, or use Contact Us to resolve the issue.";
TempData["StatusMessage-Type"] = "alert-danger";
}
else if (member.IsApproved)
{
TempData["StatusMessage"] = "You've already been verified, " + member.Name;
TempData["StatusMessage-Type"] = "alert-info";
TempData["StatusMessage-Type"] = "alert-info";
}
else
{
@@ -32,7 +32,7 @@ namespace LeafWeb.WebCms.Controllers
}
else if (storedToken != token)
{
TempData["StatusMessage"] = $"Bad token.";
TempData["StatusMessage"] = $"Sorry, your token cannot be found. Please try to register again, or use Contact Us to resolve the issue.";
TempData["StatusMessage-Type"] = "alert-danger";
}
else
@@ -44,10 +44,10 @@ namespace LeafWeb.WebCms.Controllers
member.SetValue("VerificationToken", string.Empty);
memberService.Save(member);
TempData["StatusMessage"] = "You have been verified, " + member.Name;
TempData["StatusMessage"] = "Thank you! Your email is now verified at " + member.Email;
TempData["StatusMessage-Type"] = "alert-success";
// TODO: rewrite url to their own page
// TODO: change redirectUrl to their own page
}
}
+1 -1
View File
@@ -14,7 +14,7 @@ using Umbraco.Web.Mvc;
namespace LeafWeb.WebCms.Controllers
{
[MemberAuthorize]
[MemberAuthorize(AllowGroup = "Administrator")]
public class QueueController : BaseController
{
private const int TimeSamples = 40;