Added conference list page, administration tools, and re-designed conference administration
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
require 'geocoder'
|
||||
require 'geocoder/railtie'
|
||||
require 'geocoder/calculations'
|
||||
|
||||
Geocoder::Railtie.insert
|
||||
|
||||
class City < ActiveRecord::Base
|
||||
geocoded_by :address
|
||||
translates :city
|
||||
|
||||
reverse_geocoded_by :latitude, :longitude, :address => :full_address
|
||||
after_validation :geocode, if: ->(obj){ obj.country_changed? or obj.territory_changed? or obj.city_changed? or obj.latitude.blank? or obj.longitude.blank? }
|
||||
|
||||
def address
|
||||
([city!, territory, country] - [nil, '']).join(', ')
|
||||
end
|
||||
|
||||
def get_translation(locale)
|
||||
location = Geocoder.search(address, language: locale.to_s).first
|
||||
|
||||
location.data['address_components'].each do | component |
|
||||
if component['types'].first == 'locality'
|
||||
return component['short_name']
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
def translate_city(locale)
|
||||
translation = get_translation(locale)
|
||||
set_column_for_locale(:city, locale, translation)
|
||||
save!
|
||||
|
||||
return translation
|
||||
end
|
||||
|
||||
def self.search(str)
|
||||
cache = CityCache.search(str)
|
||||
|
||||
# return the city if this search is in our cache
|
||||
return cache.city if cache.present?
|
||||
|
||||
# look up the city in the geocoder
|
||||
location = Geocoder.search(str, language: 'en').first
|
||||
|
||||
# see if the city is already present in our database
|
||||
city = City.find_by_place_id(location.data['place_id'])
|
||||
|
||||
# return the city if we found it in the db already
|
||||
return city if city.present?
|
||||
|
||||
# otherwise build a new city
|
||||
component_alises = {
|
||||
'locality' => :city,
|
||||
'administrative_area_level_1' => :territory,
|
||||
'country' => :country
|
||||
}
|
||||
city_data = {
|
||||
locale: :en,
|
||||
latitude: location.data['geometry']['location']['lat'],
|
||||
longitude: location.data['geometry']['location']['lng'],
|
||||
place_id: location.data['place_id']
|
||||
}
|
||||
location.data['address_components'].each do | component |
|
||||
property = component_alises[component['types'].first]
|
||||
city_data[property] = component['short_name'] if property.present?
|
||||
end
|
||||
|
||||
# save the new city
|
||||
city = City.new(city_data)
|
||||
city.save!
|
||||
|
||||
# and return it
|
||||
return city
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
class CityCache < ActiveRecord::Base
|
||||
self.table_name = :city_cache
|
||||
|
||||
belongs_to :city
|
||||
|
||||
def self.search(str)
|
||||
CityCache.find_by_search(str.downcase)
|
||||
end
|
||||
end
|
||||
+20
-20
@@ -1,27 +1,27 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :user
|
||||
|
||||
def comment_object
|
||||
model_type.classify.constantize.find(model_id)
|
||||
end
|
||||
def comment_object
|
||||
model_type.classify.constantize.find(model_id)
|
||||
end
|
||||
|
||||
def set_model(model)
|
||||
model_type = model.class.name.tableize
|
||||
model_id = model.id
|
||||
end
|
||||
def set_model(model)
|
||||
model_type = model.class.name.tableize
|
||||
model_id = model.id
|
||||
end
|
||||
|
||||
def self.for(model)
|
||||
where(model_type: model.class.name.tableize, model_id: model.id).order(created_at: :asc)
|
||||
end
|
||||
def self.for(model)
|
||||
where(model_type: model.class.name.tableize, model_id: model.id).order(created_at: :asc)
|
||||
end
|
||||
|
||||
def self.create_for(model, user, comment)
|
||||
create(
|
||||
model_type: model.class.name.tableize,
|
||||
model_id: model.id,
|
||||
user_id: user.id,
|
||||
comment: comment
|
||||
)
|
||||
end
|
||||
def self.create_for(model, user, comment)
|
||||
create(
|
||||
model_type: model.class.name.tableize,
|
||||
model_id: model.id,
|
||||
user_id: user.id,
|
||||
comment: comment
|
||||
)
|
||||
end
|
||||
|
||||
def add_comment(user, comment)
|
||||
Comment.create_for(self, user, comment)
|
||||
@@ -32,6 +32,6 @@ class Comment < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def reply?
|
||||
model_type == 'comments'
|
||||
model_type == 'comments'
|
||||
end
|
||||
end
|
||||
|
||||
+117
-52
@@ -1,71 +1,136 @@
|
||||
class Conference < ActiveRecord::Base
|
||||
translates :info, :title, :payment_message
|
||||
translates :info, :title, :payment_message
|
||||
|
||||
mount_uploader :cover, CoverUploader
|
||||
mount_uploader :poster, PosterUploader
|
||||
mount_uploader :cover, CoverUploader
|
||||
mount_uploader :poster, PosterUploader
|
||||
|
||||
belongs_to :conference_type
|
||||
belongs_to :conference_type
|
||||
belongs_to :city
|
||||
|
||||
has_many :conference_host_organizations, :dependent => :destroy
|
||||
has_many :organizations, :through => :conference_host_organizations
|
||||
has_many :event_locations
|
||||
|
||||
#has_many :conference_registration_form_fields, :order => 'position ASC', :dependent => :destroy#, :class_name => '::ConferenceRegistrationFormField'
|
||||
#has_many :registration_form_fields, :through => :conference_registration_form_fields
|
||||
has_many :conference_host_organizations, dependent: :destroy
|
||||
has_many :organizations, through: :conference_host_organizations
|
||||
has_many :conference_administrators, dependent: :destroy
|
||||
has_many :administrators, through: :conference_administrators, source: :user
|
||||
has_many :event_locations
|
||||
|
||||
has_many :workshops
|
||||
|
||||
has_many :workshops
|
||||
accepts_nested_attributes_for :conference_host_organizations, reject_if: proc {|u| u[:organization_id].blank?}, allow_destroy: true
|
||||
|
||||
accepts_nested_attributes_for :conference_host_organizations, :reject_if => proc {|u| u[:organization_id].blank?}, :allow_destroy => true
|
||||
before_create :make_slug
|
||||
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
|
||||
def host?(user)
|
||||
return false unless user.present?
|
||||
organizations.each do |o|
|
||||
return true if o.host?(user)
|
||||
end
|
||||
return false
|
||||
end
|
||||
def host_organization?(org)
|
||||
return false unless org.present?
|
||||
org_id = org.is_a?(Organization) ? org.id : org
|
||||
|
||||
def url(action = :show)
|
||||
path(action)
|
||||
end
|
||||
organizations.each do |o|
|
||||
return true if o.id = org_id
|
||||
end
|
||||
|
||||
def path(action = :show)
|
||||
action = action.to_sym
|
||||
'/conferences/' + conference_type.slug + '/' + slug + (action == :show ? '' : '/' + action.to_s)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def location
|
||||
organizations.first.location
|
||||
end
|
||||
def host?(user)
|
||||
if user.present?
|
||||
return true if user.administrator?
|
||||
|
||||
conference_administrators.each do |u|
|
||||
return true if user.id == u.id
|
||||
end
|
||||
|
||||
organizations.each do |o|
|
||||
return true if o.host?(user)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def registered?(user)
|
||||
registration = ConferenceRegistration.find_by(:user_id => user.id, :conference_id => id)
|
||||
return registration ? registration.is_attending : false
|
||||
end
|
||||
def url(action = :show)
|
||||
path(action)
|
||||
end
|
||||
|
||||
def registration_exists?(user)
|
||||
ConferenceRegistration.find_by(:user_id => user.id, :conference_id => id).present?
|
||||
end
|
||||
def path(action = :show)
|
||||
action = action.to_sym
|
||||
'/conferences/' + conference_type.slug + '/' + slug + (action == :show ? '' : '/' + action.to_s)
|
||||
end
|
||||
|
||||
def registration_open
|
||||
registration_status == :open
|
||||
end
|
||||
def location
|
||||
return nil unless organizations.present?
|
||||
organizations.first.location
|
||||
end
|
||||
|
||||
def registration_status
|
||||
s = read_attribute(:registration_status)
|
||||
s.present? ? s.to_sym : nil
|
||||
end
|
||||
def registered?(user)
|
||||
registration = ConferenceRegistration.find_by(:user_id => user.id, :conference_id => id)
|
||||
return registration ? registration.is_attending : false
|
||||
end
|
||||
|
||||
def registration_status=(new_registration_status)
|
||||
write_attribute :registration_status, new_registration_status.to_s
|
||||
end
|
||||
def registration_exists?(user)
|
||||
ConferenceRegistration.find_by(:user_id => user.id, :conference_id => id).present?
|
||||
end
|
||||
|
||||
def self.default_payment_amounts
|
||||
[25, 50, 100]
|
||||
end
|
||||
def registration_open
|
||||
registration_status == :open
|
||||
end
|
||||
|
||||
def registration_status
|
||||
s = read_attribute(:registration_status)
|
||||
s.present? ? s.to_sym : nil
|
||||
end
|
||||
|
||||
def registration_status=(new_registration_status)
|
||||
write_attribute :registration_status, new_registration_status.to_s
|
||||
end
|
||||
|
||||
def make_slug(reset = false)
|
||||
if reset
|
||||
self.slug = nil
|
||||
end
|
||||
|
||||
self.slug ||= Conference.generate_slug(
|
||||
conferencetype || :annual,
|
||||
conference_year,
|
||||
city_name.gsub(/\s/, '')
|
||||
)
|
||||
end
|
||||
|
||||
def city_name
|
||||
return city.city if city.present?
|
||||
return location.present? ? location.city : nil
|
||||
end
|
||||
|
||||
def conference_year
|
||||
self.year || (end_date.present? ? end_date.year : nil)
|
||||
end
|
||||
|
||||
def over?
|
||||
return false unless end_date.present?
|
||||
return end_date < DateTime.now
|
||||
end
|
||||
|
||||
def self.default_payment_amounts
|
||||
[25, 50, 100]
|
||||
end
|
||||
|
||||
def self.conference_types
|
||||
{
|
||||
annual: '%{city}%{year}',
|
||||
n: 'North%{year}',
|
||||
s: 'South%{year}',
|
||||
e: 'East%{year}',
|
||||
w: 'West%{year}',
|
||||
ne: 'Northeast%{year}',
|
||||
nw: 'Northwest%{year}',
|
||||
se: 'Southeast%{year}',
|
||||
sw: 'Southwest%{year}'
|
||||
}
|
||||
end
|
||||
|
||||
def self.generate_slug(type, year, city)
|
||||
Conference.conference_types[(type || :annual).to_sym].gsub('%{city}', city).gsub('%{year}', year.to_s)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
class ConferenceAdministrator < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :conference
|
||||
end
|
||||
@@ -1,58 +1,58 @@
|
||||
class ConferenceRegistration < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
belongs_to :user
|
||||
has_many :conference_registration_responses
|
||||
belongs_to :conference
|
||||
belongs_to :user
|
||||
has_many :conference_registration_responses
|
||||
|
||||
AttendingOptions = [:yes, :no]
|
||||
AttendingOptions = [:yes, :no]
|
||||
|
||||
def languages
|
||||
user.languages
|
||||
end
|
||||
def languages
|
||||
user.languages
|
||||
end
|
||||
|
||||
def self.all_housing_options
|
||||
[:none, :tent, :house]
|
||||
end
|
||||
def self.all_housing_options
|
||||
[:none, :tent, :house]
|
||||
end
|
||||
|
||||
def self.all_spaces
|
||||
[:bed_space, :floor_space, :tent_space]
|
||||
end
|
||||
def self.all_spaces
|
||||
[:bed_space, :floor_space, :tent_space]
|
||||
end
|
||||
|
||||
def self.all_bike_options
|
||||
[:yes, :no]
|
||||
end
|
||||
def self.all_bike_options
|
||||
[:yes, :no]
|
||||
end
|
||||
|
||||
def self.all_food_options
|
||||
[:meat, :vegetarian, :vegan]
|
||||
end
|
||||
def self.all_food_options
|
||||
[:meat, :vegetarian, :vegan]
|
||||
end
|
||||
|
||||
def self.all_considerations
|
||||
[:vegan, :smoking, :pets, :quiet]
|
||||
end
|
||||
def self.all_considerations
|
||||
[:vegan, :smoking, :pets, :quiet]
|
||||
end
|
||||
|
||||
def status(was = false)
|
||||
return :unregistered if user.firstname.blank? || self.send(was ? :city_was : :city).blank?
|
||||
return :registered if self.send(was ? :housing_was : :housing).present? || (self.send(was ? :can_provide_housing_was : :can_provide_housing) && (self.send(was ? :housing_data_was : :housing_data) || {})['availability'].present?)
|
||||
return :preregistered
|
||||
end
|
||||
def status(was = false)
|
||||
return :unregistered if user.nil? || user.firstname.blank? || self.send(was ? :city_was : :city).blank?
|
||||
return :registered if self.send(was ? :housing_was : :housing).present? || (self.send(was ? :can_provide_housing_was : :can_provide_housing) && (self.send(was ? :housing_data_was : :housing_data) || {})['availability'].present?)
|
||||
return :preregistered
|
||||
end
|
||||
|
||||
around_update :check_status
|
||||
around_update :check_status
|
||||
|
||||
def check_status
|
||||
yield
|
||||
|
||||
old_status = status(true)
|
||||
new_status = status
|
||||
def check_status
|
||||
yield
|
||||
|
||||
old_status = status(true)
|
||||
new_status = status
|
||||
|
||||
if old_status.present? && old_status != new_status
|
||||
if (conference.registration_status == :pre && new_status == :preregistered) ||
|
||||
(conference.registration_status == :open && new_status == :registered)
|
||||
if old_status.present? && old_status != new_status
|
||||
if (conference.registration_status == :pre && new_status == :preregistered) ||
|
||||
(conference.registration_status == :open && new_status == :registered)
|
||||
|
||||
UserMailer.send_mail :registration_confirmation do
|
||||
{
|
||||
:args => self
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
UserMailer.send_mail :registration_confirmation do
|
||||
{
|
||||
:args => self
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+13
-13
@@ -1,20 +1,20 @@
|
||||
class Event < ActiveRecord::Base
|
||||
translates :info, :title
|
||||
translates :info, :title
|
||||
|
||||
belongs_to :conference
|
||||
belongs_to :event_location
|
||||
belongs_to :conference
|
||||
belongs_to :event_location
|
||||
|
||||
def conference_day
|
||||
return nil unless start_time.present? && end_time.present?
|
||||
def conference_day
|
||||
return nil unless start_time.present? && end_time.present?
|
||||
|
||||
start_day = conference.start_date.change(hour: 0, minute: 0, second: 0)
|
||||
w_start_day = start_time.change(hour: 0, minute: 0, second: 0)
|
||||
return (((w_start_day - start_day) / 86400) + 1).to_i
|
||||
end
|
||||
start_day = conference.start_date.change(hour: 0, minute: 0, second: 0)
|
||||
w_start_day = start_time.change(hour: 0, minute: 0, second: 0)
|
||||
return (((w_start_day - start_day) / 86400) + 1).to_i
|
||||
end
|
||||
|
||||
def duration
|
||||
return nil unless start_time.present? && end_time.present?
|
||||
((end_time - start_time) / 60).to_i
|
||||
end
|
||||
def duration
|
||||
return nil unless start_time.present? && end_time.present?
|
||||
((end_time - start_time) / 60).to_i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class LocationsOrganization < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :organization
|
||||
|
||||
self.primary_key = :location_id
|
||||
end
|
||||
class LocationsOrganization < ActiveRecord::Base
|
||||
belongs_to :location
|
||||
belongs_to :organization
|
||||
|
||||
self.primary_key = :location_id
|
||||
end
|
||||
|
||||
+64
-58
@@ -1,71 +1,77 @@
|
||||
class Organization < ActiveRecord::Base
|
||||
mount_uploader :logo, LogoUploader
|
||||
mount_uploader :avatar, AvatarUploader
|
||||
mount_uploader :cover, CoverUploader
|
||||
mount_uploader :logo, LogoUploader
|
||||
mount_uploader :avatar, AvatarUploader
|
||||
mount_uploader :cover, CoverUploader
|
||||
|
||||
has_many :locations_organization
|
||||
has_many :locations, :through => :locations_organization
|
||||
has_many :locations_organization
|
||||
has_many :locations, through: :locations_organization
|
||||
|
||||
has_many :user_organization_relationships, :dependent => :destroy
|
||||
has_many :users, :through => :user_organization_relationships
|
||||
has_many :user_organization_relationships, dependent: :destroy
|
||||
has_many :users, through: :user_organization_relationships
|
||||
|
||||
accepts_nested_attributes_for :locations, :reject_if => proc {|l| l[id].blank?}
|
||||
accepts_nested_attributes_for :user_organization_relationships, :reject_if => proc {|u| u[:user_id].blank?}, :allow_destroy => true
|
||||
before_create :make_slug
|
||||
accepts_nested_attributes_for :locations, :reject_if => proc {|l| l[id].blank?}
|
||||
accepts_nested_attributes_for :user_organization_relationships, :reject_if => proc {|u| u[:user_id].blank?}, :allow_destroy => true
|
||||
before_create :make_slug
|
||||
|
||||
def location
|
||||
locations.first
|
||||
end
|
||||
def location
|
||||
locations.first
|
||||
end
|
||||
|
||||
def longitude
|
||||
location.longitude
|
||||
end
|
||||
def longitude
|
||||
location.longitude
|
||||
end
|
||||
|
||||
def latitude
|
||||
location.latitude
|
||||
end
|
||||
def latitude
|
||||
location.latitude
|
||||
end
|
||||
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
def to_param
|
||||
slug
|
||||
end
|
||||
|
||||
def host?(user)
|
||||
return false unless user.present?
|
||||
return true if user.administrator?
|
||||
|
||||
users.each do |u|
|
||||
return true if u.id == user.id
|
||||
end
|
||||
return false
|
||||
end
|
||||
def host?(user)
|
||||
return false unless user.present?
|
||||
return true if user.administrator?
|
||||
|
||||
users.each do |u|
|
||||
return true if u.id == user.id
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def generate_slug(name, location = nil)
|
||||
s = name.gsub(/[^a-z1-9]+/i, '-').chomp('-').gsub(/\-([A-Z])/, '\1')
|
||||
if Organization.find_by(:slug => s).present? && !location.nil?
|
||||
if location.city.present?
|
||||
s += '-' + location.city
|
||||
end
|
||||
if Organization.find_by(:slug => s).present? && location.territory.present?
|
||||
s += '-' + location.territory
|
||||
end
|
||||
if Organization.find_by(:slug => s).present?
|
||||
s += '-' + location.country
|
||||
end
|
||||
end
|
||||
attempt = 1
|
||||
ss = s
|
||||
def generate_slug(name, location = nil)
|
||||
s = name.gsub(/[^a-z1-9]+/i, '-').chomp('-').gsub(/\-([A-Z])/, '\1')
|
||||
if Organization.find_by(:slug => s).present? && !location.nil?
|
||||
if location.city.present?
|
||||
s += '-' + location.city
|
||||
end
|
||||
if Organization.find_by(:slug => s).present? && location.territory.present?
|
||||
s += '-' + location.territory
|
||||
end
|
||||
if Organization.find_by(:slug => s).present?
|
||||
s += '-' + location.country
|
||||
end
|
||||
end
|
||||
attempt = 1
|
||||
ss = s
|
||||
|
||||
while Organization.find_by(:slug => s)
|
||||
attempt += 1
|
||||
s = ss + '-' + attempt.to_s
|
||||
end
|
||||
s
|
||||
end
|
||||
while Organization.find_by(:slug => s)
|
||||
attempt += 1
|
||||
s = ss + '-' + attempt.to_s
|
||||
end
|
||||
s
|
||||
end
|
||||
|
||||
private
|
||||
def make_slug
|
||||
if !self.slug
|
||||
self.slug = generate_slug(self.name, self.locations && self.locations[0])
|
||||
end
|
||||
end
|
||||
def self.find_by_city(city)
|
||||
Organization.joins(:locations).where(locations: {
|
||||
city_id: city.is_a?(City) ? city.id : city
|
||||
})
|
||||
end
|
||||
|
||||
private
|
||||
def make_slug
|
||||
if !self.slug
|
||||
self.slug = generate_slug(self.name, self.locations && self.locations[0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
+48
-43
@@ -1,62 +1,67 @@
|
||||
class User < ActiveRecord::Base
|
||||
authenticates_with_sorcery! do |config|
|
||||
authenticates_with_sorcery! do |config|
|
||||
config.authentications_class = Authentication
|
||||
end
|
||||
|
||||
validates :email, uniqueness: true
|
||||
validates :email, uniqueness: true
|
||||
|
||||
mount_uploader :avatar, AvatarUploader
|
||||
mount_uploader :avatar, AvatarUploader
|
||||
|
||||
has_many :user_organization_relationships
|
||||
has_many :organizations, through: :user_organization_relationships
|
||||
has_many :authentications, :dependent => :destroy
|
||||
accepts_nested_attributes_for :authentications
|
||||
has_many :user_organization_relationships
|
||||
has_many :organizations, through: :user_organization_relationships
|
||||
has_many :conferences, through: :conference_administrators
|
||||
has_many :authentications, :dependent => :destroy
|
||||
accepts_nested_attributes_for :authentications
|
||||
|
||||
before_update do |user|
|
||||
user.locale ||= I18n.locale
|
||||
end
|
||||
before_update do |user|
|
||||
user.locale ||= I18n.locale
|
||||
end
|
||||
|
||||
before_save do |user|
|
||||
user.locale ||= I18n.locale
|
||||
end
|
||||
before_save do |user|
|
||||
user.locale ||= I18n.locale
|
||||
end
|
||||
|
||||
def can_translate?(to_locale = nil, from_locale = nil)
|
||||
is_translator unless to_locale.present?
|
||||
def can_translate?(to_locale = nil, from_locale = nil)
|
||||
is_translator unless to_locale.present?
|
||||
|
||||
from_locale = I18n.locale unless from_locale.present?
|
||||
return languages.present? &&
|
||||
to_locale.to_s != from_locale.to_s &&
|
||||
languages.include?(to_locale.to_s) &&
|
||||
languages.include?(from_locale.to_s)
|
||||
end
|
||||
from_locale = I18n.locale unless from_locale.present?
|
||||
return languages.present? &&
|
||||
to_locale.to_s != from_locale.to_s &&
|
||||
languages.include?(to_locale.to_s) &&
|
||||
languages.include?(from_locale.to_s)
|
||||
end
|
||||
|
||||
def name
|
||||
firstname || username || email
|
||||
end
|
||||
def name
|
||||
firstname || username || email
|
||||
end
|
||||
|
||||
def named_email
|
||||
name = firstname || username
|
||||
return email unless name
|
||||
return "#{name} <#{email}>"
|
||||
end
|
||||
def named_email
|
||||
name = firstname || username
|
||||
return email unless name
|
||||
return "#{name} <#{email}>"
|
||||
end
|
||||
|
||||
def administrator?
|
||||
role == 'administrator'
|
||||
end
|
||||
def administrator?
|
||||
role == 'administrator'
|
||||
end
|
||||
|
||||
def self.AVAILABLE_LANGUAGES
|
||||
[:en, :es, :fr, :ar]
|
||||
end
|
||||
def self.AVAILABLE_LANGUAGES
|
||||
[:en, :es, :fr, :ar]
|
||||
end
|
||||
|
||||
def self.get(email)
|
||||
user = where(email: email).first
|
||||
def self.get(email)
|
||||
user = where(email: email).first
|
||||
|
||||
unless user
|
||||
user = new(email: email)
|
||||
user.save!
|
||||
end
|
||||
unless user
|
||||
user = new(email: email)
|
||||
user.save!
|
||||
end
|
||||
|
||||
return user
|
||||
end
|
||||
return user
|
||||
end
|
||||
|
||||
def self.find_user(email)
|
||||
User.where('lower(email) = ?', email.downcase).first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class UserOrganizationRelationship < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :organization
|
||||
|
||||
Administrator = 'administrator'
|
||||
Member = 'member'
|
||||
|
||||
DefaultRelationship = Member
|
||||
|
||||
AllRelationships = [Administrator, Member]
|
||||
end
|
||||
class UserOrganizationRelationship < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :organization
|
||||
|
||||
Administrator = 'administrator'
|
||||
Member = 'member'
|
||||
|
||||
DefaultRelationship = Member
|
||||
|
||||
AllRelationships = [Administrator, Member]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user