The working basics

This commit is contained in:
Godwin
2014-03-09 14:43:33 -06:00
parent b490a97852
commit db60933506
628 changed files with 81918 additions and 1060 deletions
+19
View File
@@ -0,0 +1,19 @@
class Conference < ActiveRecord::Base
mount_uploader :cover, CoverUploader
mount_uploader :poster, PosterUploader
belongs_to :conference_type
has_many :conference_host_organizations, :dependent => :destroy
has_many :organizations, :through => :conference_host_organizations
has_many :conference_registration_form_fields, :order => 'position ASC', :dependent => :destroy#, :class_name => '::ConferenceRegistrationFormField'
has_many :registration_form_fields, :through => :conference_registration_form_fields
accepts_nested_attributes_for :conference_host_organizations, :reject_if => proc {|u| u[:organization_id].blank?}, :allow_destroy => true
def to_param
slug
end
end
+2
View File
@@ -0,0 +1,2 @@
class ConferenceAdmin < ActiveRecord::Base
end
@@ -0,0 +1,4 @@
class ConferenceHostOrganization < ActiveRecord::Base
belongs_to :conference
belongs_to :organization
end
+5
View File
@@ -0,0 +1,5 @@
class ConferenceRegistration < ActiveRecord::Base
has_many :conference_registration_responses
AttendingOptions = [:yes, :no]
end
@@ -0,0 +1,6 @@
class ConferenceRegistrationFormField < ActiveRecord::Base
belongs_to :conference
belongs_to :registration_form_field
acts_as_list
end
@@ -0,0 +1,5 @@
class ConferenceRegistrationResponse < ActiveRecord::Base
belongs_to :conference_registration
belongs_to :user
belongs_to :conference, :through => :conference_registration
end
+3
View File
@@ -0,0 +1,3 @@
class ConferenceType < ActiveRecord::Base
#belongs_to :conference
end
+20
View File
@@ -0,0 +1,20 @@
class Location < ActiveRecord::Base
#attr_accessible :title, :country, :territory, :city, :street, :postal_code, :latitude, :longitude
has_many :locations_organization
has_many :organizations, :through => :locations_organization
geocoded_by :full_address
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.street_changed? or obj.postal_code_changed? }
def full_address
addr = title
addr = (addr ? ', ' : '') + (street || '')
addr = (addr ? ', ' : '') + (city || '')
addr = (addr ? ', ' : '') + (territory || '')
addr = (addr ? ' ' : '') + (country || '')
addr = (addr ? ' ' : '') + (postal_code || '')
addr
end
end
+6
View File
@@ -0,0 +1,6 @@
class LocationsOrganization < ActiveRecord::Base
belongs_to :location
belongs_to :organization
self.primary_key = :location_id
end
+19
View File
@@ -0,0 +1,19 @@
class Organization < ActiveRecord::Base
mount_uploader :logo, LogoUploader
mount_uploader :avatar, AvatarUploader
mount_uploader :cover, CoverUploader
has_many :locations_organization
has_many :locations, :through => :locations_organization
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
def to_param
slug
end
end
+2
View File
@@ -0,0 +1,2 @@
class OrganizationStatus < ActiveRecord::Base
end
+67
View File
@@ -0,0 +1,67 @@
class RegistrationFormField < ActiveRecord::Base
Types = {
:single => [:title, :required, :input_type, :help],
:multiple => [:title, :required, :selection_type, :options, :other, :help]
}
Fields = {
:title => {:control => 'text_field'},
:input_type => {:control => 'select', :options => [[:text_field, :text_area, :number_field, :date_field, :time_field, :phone_field, :checkbox]], :option => true},
:selection_type => {:control => 'select', :options => [[:check_box, :radio_button, :select]], :option => true},
:options => {:control => 'text_area', :option => true},
:help => {:control => 'text_area'},
:other => {:control => 'check_box', :option => true},
:required => {:control => 'check_box'}
}
def self.TypesForField(field)
types = []
Types.each do |k, t|
if t.include?(field)
types << k
end
end
types
end
def input_type
get_from_options 'input_type'
end
def selection_type
get_from_options 'selection_type'
end
def other
get_from_options 'other'
end
def self.GetOptions(type, values)
o = {}
Fields.each do |k, f|
if f[:option] && Types[type.to_sym].include?(k)
o[k] = values[k]
end
end
o
end
def self.GetNonOptionKeys(type, values)
o = []
Fields.each do |k, f|
if !f[:option] && Types[type.to_sym].include?(k)
o << k
end
end
o
end
private
def get_from_options(key)
if options
_options = ActiveSupport::JSON.decode(options)
return _options[key]
end
nil
end
end
+3
View File
@@ -0,0 +1,3 @@
class Translation < I18n::Backend::ActiveRecord::Translation
has_paper_trail
end
+20
View File
@@ -0,0 +1,20 @@
class User < ActiveRecord::Base
authenticates_with_sorcery!
validates :password, presence: true, confirmation: true, length: { minimum: 3 }, unless: ("id?" || "password_confirmation?")
validates :password_confirmation, presence: true, unless: ("id?" || "password?")
validates :email, uniqueness: true
#validates_presence_of :avatar
#validates_integrity_of :avatar
#validates_processing_of :avatar
#has_secure_password validations: false
mount_uploader :avatar, AvatarUploader
has_many :user_organization_relationships
has_many :organizations, through: :user_organization_relationships
end
@@ -0,0 +1,11 @@
class UserOrganizationRelationship < ActiveRecord::Base
belongs_to :user
belongs_to :organization
Administrator = 'administrator'
Member = 'member'
DefaultRelationship = Member
AllRelationships = [Administrator, Member]
end
+2
View File
@@ -0,0 +1,2 @@
class Version < ActiveRecord::Base
end
@@ -0,0 +1,2 @@
class WorkshopPresentationStyle < ActiveRecord::Base
end
+2
View File
@@ -0,0 +1,2 @@
class WorkshopResource < ActiveRecord::Base
end
+2
View File
@@ -0,0 +1,2 @@
class WorkshopStream < ActiveRecord::Base
end