Permalink
Browse files

Merge commit '5d4d4e62146aedea05596323ce41c79b068a7eed' into HEAD

  • Loading branch information...
2 parents 62b63b4 + 5d4d4e6 commit b957c47bad971af580a62eae2d58b152e950689f Jenkins committed Sep 12, 2012
Showing with 82 additions and 20 deletions.
  1. +30 −0 .gitignore
  2. +8 −8 lib/validations.rb
  3. +1 −1 lib/views/content/amend.erb
  4. +5 −0 lib/views/errors_old.erb
  5. +5 −0 lib/views/errors_with_margin.erb
  6. +1 −1 lib/views/upload.erb
  7. +32 −10 lib/zendesk_ticket.rb
View
@@ -0,0 +1,30 @@
+*.gem
+*.rbc
+.idea
+.DS_Store
+lib/.DS_Store
+lib/public/.DS_Store
+lib/public/javascripts/.DS_Store
+.bundle
+.config
+coverage
+InstalledFiles
+lib/bundler/man
+pkg
+rdoc
+spec/reports
+test/tmp
+test/version_tmp
+tmp
+
+# YARD artifacts
+.yardoc
+_yardoc
+doc/
+
+# temp ignored for avoiding problems caused by slimmer
+Gemfile
+Gemfile.lock
+config.ru
+config/zendesk.yml
+
View
@@ -8,15 +8,15 @@ class Guard
def self.validationsForNewNeed(form_data)
@@errors = {}
required = ["name", "email", "job", "department"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@errors
end
def self.validationsForAmendContent(form_data)
@@errors = {}
required = ["name", "email", "job", "department"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ 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"]])
need_by = validate_date_in_valid_range("Need by", "need_by_day", "need_by_month", "need_by_year", form_data)
@@ -39,7 +39,7 @@ def self.validationsForCreateUser(form_data)
else
required = ["name", "email", "job", "department", "user_name", "user_email"]
end
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
if form_data[:uploaded_data] && self.doesFieldHaveValue(form_data[:uploaded_data][:filename])
validate_upload_file("uploaded_data", form_data[:uploaded_data])
@@ -51,7 +51,7 @@ def self.validationsForCreateUser(form_data)
def self.validationsForResetPassword(form_data)
@@errors = {}
required = ["name", "email", "job", "department", "user_name", "user_email"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@errors
end
@@ -65,7 +65,7 @@ def self.validationsForDeleteUser(form_data)
required = ["name", "email", "job", "department", "user_name", "user_email"]
end
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
self.checkOptionalDateFieldsAreComplete(form_data, [["Not before", "not_before_day", "not_before_month", "not_before_year"]])
not_before = validate_date_in_valid_range("Not_before", "not_before_day", "not_before_month", "not_before_year", form_data)
@@ -83,7 +83,7 @@ def self.validationsForDeleteUser(form_data)
def self.validationsForCampaign(form_data)
@@errors = {}
required = ["name", "email", "job", "department", "campaign_name", "erg_number", "description"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
self.checkOptionalDateFieldsAreComplete(form_data, [["Start date", "start_day", "start_month", "start_year"]])
@@ -97,15 +97,15 @@ def self.validationsForCampaign(form_data)
def self.validationsForBrokenLink(form_data)
@@errors = {}
required = ["name", "email", "job", "department", "url"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ 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"]
- validate(form_data, required, {:phone => form_data["phone"]}, {:email => form_data["email"]})
+ validate(form_data, required, {"phone" => form_data["phone"]}, {"email" => form_data["email"]})
@@errors
end
@@ -24,7 +24,7 @@
<div class="upload">
<label for="file-added">Supporting documentation (optional)</label>
<br/>
- <input id="file-added" name="uploaded_data" type="file"/>
+ <input id="file-added" name="uploaded_data" type="file" accept="text/plain, application/pdf, .xls, .xlsx"/>
<%= erb :errors, :locals => {"key" => "uploaded_data"} %>
</div>
</fieldset>
View
@@ -0,0 +1,5 @@
+<span class="errors" style= "<% if @errors && @errors["#{key}"] %> display: inline; <%else%> display: none; visibility: hidden; <% end%>">
+ <% if @errors %>
+ <em> <%= @errors["#{key}"] %> </em>
+ <% end %>
+</span>
@@ -0,0 +1,5 @@
+<span class="errors" style= "<% if @errors && @errors["#{key}"] %> display: block; <%else%> display: none; visibility: hidden; <% end%>">
+ <% if @errors %>
+ <em style="margin-left:25%;"> <%= @errors["#{key}"] %> </em>
+ <% end %>
+</span>
View
@@ -2,7 +2,7 @@
<div class="upload">
<label for="<%= id %>">Do you want to upload a file? (20MB limit)</label>
<br/>
- <input id="<%= id %>" name="<%= name %>" type="file"/>
+ <input id="<%= id %>" name="<%= name %>" type="file" accept="text/plain, application/pdf, .xls, .xlsx"/>
<%= erb :errors, :locals => {"key" => name} %>
</div>
</fieldset>
View
@@ -31,7 +31,7 @@ class ZendeskTicket
"reset-password" => "password_reset",
"campaign" => "campaign",
"broken-link" => "broken_link",
- "publish-tool" => "publishing_tool"
+ "publish-tool" => "publishing_tool_tech"
}
def initialize(params, from_route)
@@ -85,27 +85,45 @@ def format_comment(from_route, params)
when "publish-tool" then
format_comment_for_tech_issues(from_route, params)
else
- @@in_comments[from_route].map { |comment_param| "[" + comment_param.to_s.capitalize + "]\n" + params[comment_param] }.join("\n\n")
+ comment = @@in_comments[from_route].map do |comment_param|
+ if params[comment_param] && !params[comment_param].empty?
+ "[" + comment_param.to_s.capitalize + "]\n" + params[comment_param]
+ end
+ end
+
+ if !comment.join().empty?
+ comment.join("\n\n")
+ else
+ comment.join
+ end
end
end
def format_comment_for_tech_issues(from_route, params)
all_comments = @@in_comments[from_route].map do |comment_param|
- comment = "[" + comment_param.to_s.capitalize + "]\n"
- if :url == comment_param
- comment += build_full_url_path(params[:url])
- else
- comment += params[comment_param]
+ comment = ""
+ if params[comment_param] && !params[comment_param].empty?
+ comment = "[" + comment_param.to_s.capitalize + "]\n"
+ if :url == comment_param
+ comment += build_full_url_path(params[:url])
+ else
+ comment += params[comment_param]
+ end
end
comment
end
- all_comments.join("\n\n")
+
+ if !all_comments.join.empty?
+ all_comments.join("\n\n")
+ else
+ all_comments.join
+ end
end
def format_comment_for_amend_content(params)
comments_sections = {"[URl(s) of content to be changed]" => [build_full_url_path(params[:url1]), build_full_url_path(params[:url2]), build_full_url_path(params[:url3])],
- "[Details of what should be added, amended or removed]" => [params[:add_content]],
- "[Additional Comments]" => [params[:additional]]
+ "[Details of what should be added, amended or removed]" => [params[:add_content]],
+ "[Additional Comments]" => [params[:additional]]
}
comments = comments_sections.map do |key, value|
@@ -147,6 +165,10 @@ def check_for_attachments(params)
filename = params[:uploaded_data][:filename]
@file_token << upload_file_to_create_file_token(tempfile, filename)
end
+
+ if !@file_token.empty? && @comment.empty?
+ @comment = "[Attachment(s)]"
+ end
end
def doesFieldHaveValue(field_value)

0 comments on commit b957c47

Please sign in to comment.