Schedule maker, stats, and minor fixes

This commit is contained in:
Godwin
2016-07-05 22:40:53 -07:00
parent ee3b874110
commit 26f9dfde89
18 changed files with 913 additions and 184 deletions
+14
View File
@@ -36,4 +36,18 @@ class User < ActiveRecord::Base
return "#{name} <#{email}>"
end
def self.get(email)
user = where(email: email).first
unless user
# not really a good UX so we should fix this later
#do_404
#return
user = new(email: email)
user.save!
end
return user
end
end
+9 -3
View File
@@ -2,6 +2,7 @@ class Workshop < ActiveRecord::Base
translates :info, :title
belongs_to :conference
belongs_to :event_location
has_many :workshop_facilitators, :dependent => :destroy
has_many :users, :through => :workshop_facilitators
@@ -83,14 +84,19 @@ class Workshop < ActiveRecord::Base
end
def interested_count
return 0 unless id
interested.size
end
def interested
return [] unless id
return @interested if @interested.present?
collaborators = []
workshop_facilitators.each do |f|
collaborators << f.user_id unless f.role.to_sym == :requested || f.user_id.nil?
end
return 10 unless collaborators.present?
interested = WorkshopInterest.where("workshop_id=#{id} AND user_id NOT IN (#{collaborators.join ','})") || []
interested ? interested.size : 0
@interested = WorkshopInterest.where("workshop_id=#{id} AND user_id NOT IN (#{collaborators.join ','})") || []
end
def can_translate?(user, lang)