summaryrefslogtreecommitdiff
path: root/help/app/models/ticket.rb
diff options
context:
space:
mode:
authorjessib <jessib@leap.se>2013-01-17 10:39:15 -0800
committerjessib <jessib@leap.se>2013-01-17 10:39:15 -0800
commit7d7741f7d26c3ae7ee1dc347a6b1a1142a3c2824 (patch)
tree5ec11b9600d4330ec94f56dda779634cd7dcae1b /help/app/models/ticket.rb
parent2485527650c4832d764d318e91c10bafde8b8ae5 (diff)
parentb550cd14f33b9664fe6b547dc56107fae7d12caf (diff)
Merge branch 'master' into feature/unauthenticated_tickets
Conflicts: help/app/views/tickets/_comment.html.haml help/app/views/tickets/_new_comment.html.haml
Diffstat (limited to 'help/app/models/ticket.rb')
-rw-r--r--help/app/models/ticket.rb81
1 files changed, 2 insertions, 79 deletions
diff --git a/help/app/models/ticket.rb b/help/app/models/ticket.rb
index 262d5a4..ed1ff9d 100644
--- a/help/app/models/ticket.rb
+++ b/help/app/models/ticket.rb
@@ -47,84 +47,7 @@ class Ticket < CouchRest::Model::Base
view :by_is_open_and_created_at
view :by_is_open_and_updated_at
-
- #TODO: This view is only used in tests--should we keep it?
- view :by_includes_post_by,
- :map =>
- "function(doc) {
- var arr = {}
- if (doc['type'] == 'Ticket' && doc.comments) {
- doc.comments.forEach(function(comment){
- if (comment.posted_by && !arr[comment.posted_by]) {
- //don't add duplicates
- arr[comment.posted_by] = true;
- emit(comment.posted_by, 1);
- }
- });
- }
- }", :reduce => "function(k,v,r) { return sum(v); }"
-
- view :by_includes_post_by_and_is_open_and_updated_at,
- :map =>
- "function(doc) {
- var arr = {}
- if (doc['type'] == 'Ticket' && doc.comments) {
- doc.comments.forEach(function(comment){
- if (comment.posted_by && !arr[comment.posted_by]) {
- //don't add duplicates
- arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.is_open, doc.updated_at], 1);
- }
- });
- }
- }", :reduce => "function(k,v,r) { return sum(v); }"
-
- view :by_includes_post_by_and_is_open_and_created_at,
- :map =>
- "function(doc) {
- var arr = {}
- if (doc['type'] == 'Ticket' && doc.comments) {
- doc.comments.forEach(function(comment){
- if (comment.posted_by && !arr[comment.posted_by]) {
- //don't add duplicates
- arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.is_open, doc.created_at], 1);
- }
- });
- }
- }", :reduce => "function(k,v,r) { return sum(v); }"
-
- view :by_includes_post_by_and_updated_at,
- :map =>
- "function(doc) {
- var arr = {}
- if (doc['type'] == 'Ticket' && doc.comments) {
- doc.comments.forEach(function(comment){
- if (comment.posted_by && !arr[comment.posted_by]) {
- //don't add duplicates
- arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.updated_at], 1);
- }
- });
- }
- }", :reduce => "function(k,v,r) { return sum(v); }"
-
-
- view :by_includes_post_by_and_created_at,
- :map =>
- "function(doc) {
- var arr = {}
- if (doc['type'] == 'Ticket' && doc.comments) {
- doc.comments.forEach(function(comment){
- if (comment.posted_by && !arr[comment.posted_by]) {
- //don't add duplicates
- arr[comment.posted_by] = true;
- emit([comment.posted_by, doc.created_at], 1);
- }
- });
- }
- }", :reduce => "function(k,v,r) { return sum(v); }"
-
+ load_views(Rails.root.join('help', 'app', 'designs', 'ticket'))
end
validates :title, :presence => true
@@ -132,7 +55,7 @@ class Ticket < CouchRest::Model::Base
# html5 has built-in validation which isn't ideal, as it says 'please enter an email address' for invalid email addresses, which implies an email address is required, and it is not.
- validates :email, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :if => :email #email address is optional
+ validates :email, :allow_blank => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/
#TODO:
#def set_created_by