Permalink
Browse files

Merge commit '774ea2597b24aa22d6bb99ae47659d9b093a1d81' into HEAD

  • Loading branch information...
2 parents aa45d56 + 774ea25 commit 4b66534ff7010cc211dff2cddf96f1c453436535 Jenkins committed Sep 27, 2012
Showing with 39 additions and 16 deletions.
  1. +4 −0 lib/public/stylesheets/gov_feedback.css
  2. +22 −9 lib/validations.rb
  3. +6 −1 lib/views/author.erb
  4. +7 −6 lib/zendesk_ticket.rb
@@ -148,6 +148,10 @@ textarea {
border: 1px solid #BBB;
}
+input#other_department {
+ margin-left: 5px;
+}
+
span em {
font-size: 14px;
margin-bottom: 0.3em;
View
@@ -12,7 +12,7 @@ class Guard
#Content validations
def self.validationsForAmendContent(form_data)
@@errors = {}
- required = ["name", "email", "job", "department"]
+ required = ["name", "email", "job"]
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
self.checkOptionalDateFieldsAreComplete(form_data, [["Need by", "need_by_day", "need_by_month", "need_by_year"], ["Not before", "not_before_day", "not_before_month", "not_before_year"]])
@@ -32,9 +32,9 @@ def self.validationsForAmendContent(form_data)
def self.validationsForCreateUser(form_data)
@@errors = {}
if form_data[:uploaded_data] && self.doesFieldHaveValue(form_data[:uploaded_data][:filename])
- required = ["name", "email", "job", "department"]
+ required = ["name", "email", "job"]
else
- required = ["name", "email", "job", "department", "user_name", "user_email"]
+ required = ["name", "email", "job", "user_name", "user_email"]
end
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@ -49,9 +49,9 @@ def self.validationsForDeleteUser(form_data)
@@errors = {}
if form_data[:uploaded_data] && self.doesFieldHaveValue(form_data[:uploaded_data][:filename])
- required = ["name", "email", "job", "department"]
+ required = ["name", "email", "job"]
else
- required = ["name", "email", "job", "department", "user_name", "user_email"]
+ required = ["name", "email", "job", "user_name", "user_email"]
end
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@ -71,7 +71,7 @@ def self.validationsForDeleteUser(form_data)
#Campaign validations
def self.validationsForCampaign(form_data)
@@errors = {}
- required = ["name", "email", "job", "department", "campaign_name", "erg_number", "description"]
+ required = ["name", "email", "job", "campaign_name", "erg_number", "description"]
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
self.checkOptionalDateFieldsAreComplete(form_data, [["Start date", "start_day", "start_month", "start_year"]])
@@ -85,15 +85,15 @@ def self.validationsForCampaign(form_data)
#Tech issues
def self.validationsForBrokenLink(form_data)
@@errors = {}
- required = ["name", "email", "job", "department", "url"]
+ required = ["name", "email", "job", "url"]
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@errors
end
def self.validationsForPublishTool(form_data)
@@errors = {}
- required = ["name", "email", "job", "department", "url", "username"]
+ required = ["name", "email", "job", "url", "username"]
validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@errors
@@ -103,6 +103,7 @@ def self.validationsForPublishTool(form_data)
def self.validate(form_data, required, phone_fields, email_fields)
self.checkRequiredFieldsHaveValues(required, form_data)
+ self.validate_department_or_other_is_entered(form_data)
self.checkPhoneIsValid(phone_fields)
self.checkEmailIsValid(email_fields)
end
@@ -156,7 +157,6 @@ def self.checkOptionalDateFieldsAreComplete(form_data, optional_date_fields)
@@errors[arrayofday_month_year[0]] = "#{fields_in_error_message} not entered. Please enter complete date."
end
end
-
end
def self.doesFieldHaveValue(field_value)
@@ -193,6 +193,19 @@ def self.validate_not_before_date_is_equal_or_greater_than_need_by(not_before, n
end
end
+ def self.validate_department_or_other_is_entered(form_data)
+ other_department_is_required = form_data[:department].empty? || form_data[:department] == "other_department"
+
+ if other_department_is_required &&
+ (form_data[:other_department] && form_data[:other_department].strip.empty?)
+ @@errors["Department"] = "Department information is required for a valid request."
+ end
+
+ if not other_department_is_required
+ form_data[:other_department] = ""
+ end
+ end
+
def self.validate_file_type(field_name, file_type)
@@errors ||= {}
valid = false
View
@@ -26,7 +26,7 @@
</div>
<div>
<label for="department_list">Department</label>
- <select id="department_list" name="department" required aria-required="true">
+ <select id="department_list" name="department">
<% @departments.each do |key, value| %>
<% if value == @formdata["department"] %>
<option selected="selected" value="<%= value %>"><%= key %> </option>
@@ -37,6 +37,11 @@
</select>
<%= erb :errors, :locals => {"key" => "Department"} %>
</div>
+
+ <div>
+ <label class="long" for="other_department">Please specify the department if you didn't find the department in the list above</label>
+ <input id="other_department" name="other_department">
+ </div>
</fieldset>
</section>
View
@@ -4,12 +4,12 @@
class ZendeskTicket
attr_reader :name, :email, :department, :job, :phone, :comment, :subject, :tag, :need_by_date, :not_before_date, :file_token
- @@in_comments = {"amend-content" => [:url1, :url2, :url3],
- "create-user" => [:user_name, :user_email, :additional],
- "remove-user" => [:user_name, :user_email, :additional],
- "campaign" => [:campaign_name, :erg_number, :company, :description, :url, :additional],
- "broken-link" => [:url, :user_agent, :additional],
- "publish-tool" => [:username, :url, :user_agent, :additional]
+ @@in_comments = {"amend-content" => [:other_department, :url1, :url2, :url3],
+ "create-user" => [:other_department, :user_name, :user_email, :additional],
+ "remove-user" => [:other_department, :user_name, :user_email, :additional],
+ "campaign" => [:other_department, :campaign_name, :erg_number, :company, :description, :url, :additional],
+ "broken-link" => [:other_department, :url, :user_agent, :additional],
+ "publish-tool" => [:other_department, :username, :url, :user_agent, :additional]
}
@@in_subject = {"amend-content" => "Content change request",
@@ -33,6 +33,7 @@ def initialize(client, params, from_route)
@name = params[:name]
@email = params[:email]
@department = params[:department]
+
@job = params[:job]
if has_value(params[:phone])
@phone = remove_space_from_phone_number(params[:phone])

0 comments on commit 4b66534

Please sign in to comment.