More validation for Settings.

This commit is contained in:
Mark McDowall 2012-02-25 13:21:41 -08:00
commit c0e0bf7e66
16 changed files with 185 additions and 66 deletions

View file

@ -4,6 +4,7 @@ using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Sabnzbd;
using NzbDrone.Web.Helpers.Validation;
namespace NzbDrone.Web.Models
{
@ -12,16 +13,16 @@ namespace NzbDrone.Web.Models
public SelectList PrioritySelectList =
new SelectList(new[] {"Default", "Paused", "Low", "Normal", "High", "Force"});
[Required(ErrorMessage = "Please enter a valid host")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")]
[Description("Hostname or IP Address running SABnzbd")]
[RequiredIf("DownloadClient", (int)DownloadClientType.Sabnzbd, ErrorMessage = "Required when Download Client is SABnzbd")]
public String SabHost { get; set; }
[Required(ErrorMessage = "Please enter a valid port")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Port")]
[Description("Port for SABnzbd web interface")]
[RequiredIf("DownloadClient", (int)DownloadClientType.Sabnzbd, ErrorMessage = "Required when Download Client is SABnzbd")]
public int SabPort { get; set; }
[DataType(DataType.Text)]
@ -53,14 +54,16 @@ namespace NzbDrone.Web.Models
[Description("Priority to use when sending NZBs to SABnzbd")]
public SabPriorityType SabTvPriority { get; set; }
[Required(ErrorMessage = "Required so NzbDrone can sort downloads")]
[DisplayName("Download Client TV Directory")]
[Description("The directory where your download client downloads TV shows to (NzbDrone will sort them for you)")]
[Description("The directory where your download client downloads TV shows to")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string DownloadClientDropDirectory { get; set; }
[DisplayName("Blackhole Directory")]
[Description("The directory where your download client will pickup NZB files")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("DownloadClient", (int)DownloadClientType.Blackhole, ErrorMessage = "Required when Download Client is Blackhole")]
public string BlackholeDirectory { get; set; }
[DisplayName("Download Client")]

View file

@ -13,7 +13,7 @@ namespace NzbDrone.Web.Models
[DisplayName("Username")]
[Description("Username for NZB Matrix")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "USername Required when NZBMatrix is enabled")]
[RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "Username Required when NZBMatrix is enabled")]
public String NzbMatrixUsername { get; set; }
[DataType(DataType.Text)]

View file

@ -1,6 +1,8 @@
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using NzbDrone.Core.Model;
using NzbDrone.Web.Helpers.Validation;
namespace NzbDrone.Web.Models
{
@ -31,6 +33,7 @@ namespace NzbDrone.Web.Models
[DisplayName("Hosts")]
[Description("XBMC hosts with port, comma separated")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("XbmcEnabled", true, ErrorMessage = "Required when XBMC Notifications are enabled")]
public string XbmcHosts { get; set; }
[DataType(DataType.Text)]
@ -62,12 +65,14 @@ namespace NzbDrone.Web.Models
[DisplayName("Server")]
[Description("SMTP Server Hostname")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")]
public string SmtpServer{ get; set; }
[DataType(DataType.Text)]
[DisplayName("Port")]
[Description("SMTP Server Port")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")]
public int SmtpPort { get; set; }
[DisplayName("SSL")]
@ -91,12 +96,14 @@ namespace NzbDrone.Web.Models
[DisplayName("Send From Address")]
[Description("Sender Email address")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")]
public string SmtpFromAddress { get; set; }
[DataType(DataType.Text)]
[DisplayName("Send To Addresses")]
[Description("Comma separated list of addresses to email")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("SmtpEnabled", true, ErrorMessage = "Required when SMTP Notifications are enabled")]
public string SmtpToAddresses { get; set; }
//Twitter
@ -129,6 +136,7 @@ namespace NzbDrone.Web.Models
[DisplayName("Host running Growl")]
[Description("Host or IP Address:Port")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("GrowlEnabled", true, ErrorMessage = "Required when Growl Notifications are enabled")]
public string GrowlHost { get; set; }
[DataType(DataType.Text)]
@ -155,6 +163,7 @@ namespace NzbDrone.Web.Models
[DisplayName("API Keys")]
[Description("Comma-Separated list of API Keys")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("ProwlEnabled", true, ErrorMessage = "Required when Prowl Notifications are enabled")]
public string ProwlApiKeys { get; set; }
[DataType(DataType.Text)]
@ -186,11 +195,13 @@ namespace NzbDrone.Web.Models
[DisplayName("Server Host")]
[Description("Plex Server host with port")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
[RequiredIf("PlexUpdateLibrary", true, ErrorMessage = "Required when Plex Library Update is Enabled")]
public string PlexServerHost { get; set; }
[DataType(DataType.Text)]
[DisplayName("Client Hosts")]
[Description("Plex client hosts with port, comma separated for multiple clients")]
[RequiredIf("PlexNotifyOnGrab", true, ErrorMessage = "Required when Plex Notifications are enabled")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string PlexClientHosts { get; set; }

View file

@ -11,6 +11,7 @@ namespace NzbDrone.Web.Models
[DisplayName("Port")]
[Description("Port that NzbDrone runs on")]
[Range(1, 65535, ErrorMessage = "Port must be between 1 and 65535")]
[Required(ErrorMessage = "Port must be between 1 and 65535")]
public int Port { get; set; }
[DisplayName("Launch Browser")]