NOTE: rake db:migrate required. added generation column to users
This commit is contained in:
parent
0ebc3dbc37
commit
a9e488d9cb
7 changed files with 166 additions and 135 deletions
6
LiveSiteUpdatesNotes.txt
Normal file
6
LiveSiteUpdatesNotes.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
make sure that root individuals have same 'joinedwithcode' as 'code'
|
||||||
|
|
||||||
|
User.all.each do |u|
|
||||||
|
u.generation = u.get_generation
|
||||||
|
u.save
|
||||||
|
end
|
|
@ -10,6 +10,7 @@ module UsersHelper
|
||||||
user['value'] = u.name
|
user['value'] = u.name
|
||||||
user['profile'] = u.image.url(:square)
|
user['profile'] = u.image.url(:square)
|
||||||
user['mapCount'] = u.maps.count
|
user['mapCount'] = u.maps.count
|
||||||
|
user['generation'] = u.generation
|
||||||
user['created_at'] = u.created_at.strftime("%m/%d/%Y")
|
user['created_at'] = u.created_at.strftime("%m/%d/%Y")
|
||||||
user['rtype'] = "mapper"
|
user['rtype'] = "mapper"
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,22 @@ class User < ActiveRecord::Base
|
||||||
def generate_code
|
def generate_code
|
||||||
#generate a random 8 letter/digit code that they can use to invite people
|
#generate a random 8 letter/digit code that they can use to invite people
|
||||||
self.code = rand(36**8).to_s(36)
|
self.code = rand(36**8).to_s(36)
|
||||||
|
|
||||||
|
self.generation = self.get_generation
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_generation
|
||||||
|
if self.joinedwithcode == self.code
|
||||||
|
# if your joinedwithcode equals your code you must be GEN 0
|
||||||
|
gen = 0
|
||||||
|
elsif self.generation
|
||||||
|
# if your generation has already been calculated then just return that value
|
||||||
|
gen = self.generation
|
||||||
|
else
|
||||||
|
# if your generation hasn't been calculated, base it off the
|
||||||
|
# generation of the person whose code you joined with + 1
|
||||||
|
gen = User.find_by_code(self.joinedwithcode).get_generation + 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def settings
|
def settings
|
||||||
|
|
|
@ -144,7 +144,7 @@
|
||||||
<p>Mapping since: {{created_at}}</p>
|
<p>Mapping since: {{created_at}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mapperGeneration">
|
<div class="mapperGeneration">
|
||||||
<p>Generation: 1</p>
|
<p>Generation: {{generation}}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mapCount">
|
<div class="mapCount">
|
||||||
{{mapCount}}
|
{{mapCount}}
|
||||||
|
|
5
db/migrate/20141121204712_add_generation_to_users.rb
Normal file
5
db/migrate/20141121204712_add_generation_to_users.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddGenerationToUsers < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :generation, :integer
|
||||||
|
end
|
||||||
|
end
|
269
db/schema.rb
269
db/schema.rb
|
@ -1,134 +1,135 @@
|
||||||
# encoding: UTF-8
|
# encoding: UTF-8
|
||||||
# This file is auto-generated from the current state of the database. Instead
|
# This file is auto-generated from the current state of the database. Instead
|
||||||
# of editing this file, please use the migrations feature of Active Record to
|
# of editing this file, please use the migrations feature of Active Record to
|
||||||
# incrementally modify your database, and then regenerate this schema definition.
|
# incrementally modify your database, and then regenerate this schema definition.
|
||||||
#
|
#
|
||||||
# Note that this schema.rb definition is the authoritative source for your
|
# Note that this schema.rb definition is the authoritative source for your
|
||||||
# database schema. If you need to create the application database on another
|
# database schema. If you need to create the application database on another
|
||||||
# system, you should be using db:schema:load, not running all the migrations
|
# system, you should be using db:schema:load, not running all the migrations
|
||||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20140930013020) do
|
ActiveRecord::Schema.define(:version => 20141121204712) do
|
||||||
|
|
||||||
create_table "in_metacode_sets", :force => true do |t|
|
create_table "in_metacode_sets", :force => true do |t|
|
||||||
t.integer "metacode_id"
|
t.integer "metacode_id"
|
||||||
t.integer "metacode_set_id"
|
t.integer "metacode_set_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
|
add_index "in_metacode_sets", ["metacode_id"], :name => "index_in_metacode_sets_on_metacode_id"
|
||||||
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
|
add_index "in_metacode_sets", ["metacode_set_id"], :name => "index_in_metacode_sets_on_metacode_set_id"
|
||||||
|
|
||||||
create_table "mappings", :force => true do |t|
|
create_table "mappings", :force => true do |t|
|
||||||
t.text "category"
|
t.text "category"
|
||||||
t.integer "xloc"
|
t.integer "xloc"
|
||||||
t.integer "yloc"
|
t.integer "yloc"
|
||||||
t.integer "topic_id"
|
t.integer "topic_id"
|
||||||
t.integer "synapse_id"
|
t.integer "synapse_id"
|
||||||
t.integer "map_id"
|
t.integer "map_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "maps", :force => true do |t|
|
create_table "maps", :force => true do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.boolean "arranged"
|
t.boolean "arranged"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "permission"
|
t.text "permission"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.boolean "featured"
|
t.boolean "featured"
|
||||||
t.string "screenshot_file_name"
|
t.string "screenshot_file_name"
|
||||||
t.string "screenshot_content_type"
|
t.string "screenshot_content_type"
|
||||||
t.integer "screenshot_file_size"
|
t.integer "screenshot_file_size"
|
||||||
t.datetime "screenshot_updated_at"
|
t.datetime "screenshot_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "metacode_sets", :force => true do |t|
|
create_table "metacode_sets", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.boolean "mapperContributed"
|
t.boolean "mapperContributed"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
|
add_index "metacode_sets", ["user_id"], :name => "index_metacode_sets_on_user_id"
|
||||||
|
|
||||||
create_table "metacodes", :force => true do |t|
|
create_table "metacodes", :force => true do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.string "icon"
|
t.string "icon"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "color"
|
t.string "color"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "synapses", :force => true do |t|
|
create_table "synapses", :force => true do |t|
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "category"
|
t.text "category"
|
||||||
t.text "weight"
|
t.text "weight"
|
||||||
t.text "permission"
|
t.text "permission"
|
||||||
t.integer "node1_id"
|
t.integer "node1_id"
|
||||||
t.integer "node2_id"
|
t.integer "node2_id"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "topics", :force => true do |t|
|
create_table "topics", :force => true do |t|
|
||||||
t.text "name"
|
t.text "name"
|
||||||
t.text "desc"
|
t.text "desc"
|
||||||
t.text "link"
|
t.text "link"
|
||||||
t.text "permission"
|
t.text "permission"
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "metacode_id"
|
t.integer "metacode_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "image_file_name"
|
t.string "image_file_name"
|
||||||
t.string "image_content_type"
|
t.string "image_content_type"
|
||||||
t.integer "image_file_size"
|
t.integer "image_file_size"
|
||||||
t.datetime "image_updated_at"
|
t.datetime "image_updated_at"
|
||||||
t.string "audio_file_name"
|
t.string "audio_file_name"
|
||||||
t.string "audio_content_type"
|
t.string "audio_content_type"
|
||||||
t.integer "audio_file_size"
|
t.integer "audio_file_size"
|
||||||
t.datetime "audio_updated_at"
|
t.datetime "audio_updated_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", :force => true do |t|
|
create_table "users", :force => true do |t|
|
||||||
t.string "name"
|
t.string "name"
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.text "settings"
|
t.text "settings"
|
||||||
t.string "code", :limit => 8
|
t.string "code", :limit => 8
|
||||||
t.string "joinedwithcode", :limit => 8
|
t.string "joinedwithcode", :limit => 8
|
||||||
t.string "crypted_password"
|
t.string "crypted_password"
|
||||||
t.string "password_salt"
|
t.string "password_salt"
|
||||||
t.string "persistence_token"
|
t.string "persistence_token"
|
||||||
t.string "perishable_token"
|
t.string "perishable_token"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.string "encrypted_password", :limit => 128, :default => ""
|
t.string "encrypted_password", :limit => 128, :default => ""
|
||||||
t.string "remember_token"
|
t.string "remember_token"
|
||||||
t.datetime "remember_created_at"
|
t.datetime "remember_created_at"
|
||||||
t.string "reset_password_token"
|
t.string "reset_password_token"
|
||||||
t.datetime "last_sign_in_at"
|
t.datetime "last_sign_in_at"
|
||||||
t.string "last_sign_in_ip"
|
t.string "last_sign_in_ip"
|
||||||
t.integer "sign_in_count", :default => 0
|
t.integer "sign_in_count", :default => 0
|
||||||
t.datetime "current_sign_in_at"
|
t.datetime "current_sign_in_at"
|
||||||
t.string "current_sign_in_ip"
|
t.string "current_sign_in_ip"
|
||||||
t.datetime "reset_password_sent_at"
|
t.datetime "reset_password_sent_at"
|
||||||
t.boolean "admin"
|
t.boolean "admin"
|
||||||
t.string "image_file_name"
|
t.string "image_file_name"
|
||||||
t.string "image_content_type"
|
t.string "image_content_type"
|
||||||
t.integer "image_file_size"
|
t.integer "image_file_size"
|
||||||
t.datetime "image_updated_at"
|
t.datetime "image_updated_at"
|
||||||
end
|
t.integer "generation"
|
||||||
|
end
|
||||||
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
|
||||||
|
add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
||||||
end
|
|
||||||
|
end
|
||||||
|
|
2
test/fixtures/users.yml
vendored
2
test/fixtures/users.yml
vendored
|
@ -5,6 +5,7 @@ user:
|
||||||
email: user@user.com
|
email: user@user.com
|
||||||
encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW
|
encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW
|
||||||
code: qwertyui
|
code: qwertyui
|
||||||
|
joinedwithcode: qwertyui
|
||||||
admin: false
|
admin: false
|
||||||
|
|
||||||
admin:
|
admin:
|
||||||
|
@ -12,4 +13,5 @@ admin:
|
||||||
email: admin@admin.com
|
email: admin@admin.com
|
||||||
encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW
|
encrypted_password: $2a$10$psR68SWYNy5ZKQPs9FrFM.HuRMrTXO/YFzv.HaUmdCsQZsQrG1XAW
|
||||||
code: iuytrewq
|
code: iuytrewq
|
||||||
|
joinedwithcode: iuytrewq
|
||||||
admin: true
|
admin: true
|
||||||
|
|
Loading…
Reference in a new issue