Validation changes, moved JS for Client-Side validation to Settings/Index.aspx

Still need to sort out validation for Quality Cutoff (not part of the Model so it seems to cause issues).
This commit is contained in:
markus101 2011-02-14 16:45:31 -08:00
parent baeda11ece
commit b2524cf697
5 changed files with 29 additions and 27 deletions

View File

@ -11,6 +11,7 @@ namespace NzbDrone.Core.Repository.Quality
[SubSonicPrimaryKey(true)]
public int ProfileId { get; set; }
[Required (ErrorMessage = "A Name is Required")]
[DisplayName("Name")]
public string Name { get; set; }
public bool UserProfile { get; set; } //Allows us to tell the difference between default and user profiles

View File

@ -303,6 +303,8 @@ namespace NzbDrone.Web.Controllers
public ActionResult SaveQuality(QualityModel data)
{
try
{
if (ModelState.IsValid)
{
_configProvider.SetValue("DefaultQualityProfile", data.DefaultProfileId.ToString());
@ -312,7 +314,6 @@ namespace NzbDrone.Web.Controllers
_qualityProvider.Delete(dbProfile.ProfileId);
}
foreach (var profile in data.UserProfiles)
{
Logger.Debug(String.Format("Updating User Profile: {0}", profile));
@ -336,6 +337,7 @@ namespace NzbDrone.Web.Controllers
_qualityProvider.Add(profile);
}
}
}
catch (Exception e)
{

View File

@ -13,7 +13,6 @@ namespace NzbDrone.Web.Models
{
public List<QualityProfile> Profiles { get; set; }
public List<QualityProfile> UserProfiles { get; set; }
//public List<QualityTypes> Qualities { get; set; }
[DisplayName("Default Quality Profile")]
public int DefaultProfileId { get; set; }

View File

@ -23,8 +23,6 @@
}
</script>
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("SaveDownloads", "Settings", FormMethod.Post, new { id = "form", name = "form" }))

View File

@ -26,11 +26,13 @@
</script>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("SaveQuality", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
{%>
<fieldset>
<legend>Quality</legend>
<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>
<%--<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>--%>
<div class="rightSide" style="float: right; width: 65%;">
<div id="defaultQualityDiv" style="float: left; margin: 30px;">