fixed some minor bugs, added user-chrom.sex and user-yearofbirth

This commit is contained in:
Bastian Greshake
2011-09-26 18:37:51 +02:00
parent 1095954713
commit 28ad2e4a1e
7 changed files with 49 additions and 31 deletions

View File

@@ -37,7 +37,7 @@ class PhenotypesController < ApplicationController
@phenotype = Phenotype.find_by_characteristic(params[:phenotype][:characteristic])
end
unless @phenotype.known_phenotypes.include?(params[:user_phenotype][:variation])
if @phenotype.known_phenotypes.include?(params[:user_phenotype][:variation]) == false
@phenotype.known_phenotypes << params[:user_phenotype][:variation]
end

View File

@@ -10,7 +10,7 @@ class Zipgenotypingfiles
@user = User.find_by_id(up.user_id)
print @user
if @user.genotypes[0] != nil
@genotyping_files << @user.genotypes[0].fs_filename
@genotyping_files << @user.genotypes[0]
end
end
@@ -19,7 +19,7 @@ class Zipgenotypingfiles
if File.exists?(::Rails.root.to_s+"/public/data/zip/"+phenotype_id.to_s+"."+@time.to_s.gsub(" ","_")+".zip") == false
Zip::ZipFile.open(::Rails.root.to_s+"/public/data/zip/"+phenotype_id.to_s+"."+@time.to_s.gsub(" ","_")+".zip", Zip::ZipFile::CREATE) do |zipfile|
@genotyping_files.each do |gen_file|
zipfile.add(gen_file, "#{RAILS_ROOT}/public/data/"+ gen_file)
zipfile.add("user"+gen_file.user_id.to_s+"_file"+gen_file.id.to_s+"_yearofbirth"+gen_file.user.yearofbirth+"_sex"+gen_file.user.sex+"."+gen_file.filetype+".txt", "#{RAILS_ROOT}/public/data/"+ gen_file.fs_filename)
end
end
end

View File

@@ -9,7 +9,10 @@ class Phenotype < ActiveRecord::Base
text :characteristic
end
def known_phenotypes
read_attribute(:known_phenotypes) || []
after_create :default_array
def default_array
self.known_phenotypes ||= []
end
end

View File

@@ -1,7 +1,7 @@
class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>#", :head => "32x32#" }, :default_url => '/images/standard_:style.png'
attr_accessible :user_phenotypes_attributes, :variation, :characteristic, :name, :password_confirmation, :password, :email, :description, :homepages, :homepages_attributes,:avatar, :phenotype_creation_counter, :phenotype_additional_counter,:delete_avatar
attr_accessible :user_phenotypes_attributes, :variation, :characteristic, :name, :password_confirmation, :password, :email, :description, :homepages, :homepages_attributes,:avatar, :sex, :yearofbirth, :phenotype_creation_counter, :phenotype_additional_counter,:delete_avatar
before_validation :clear_avatar
validates_attachment_size :avatar, :less_than=>1.megabyte

View File

@@ -42,6 +42,14 @@
<div id="phenotypes">
<div class="well">
<h2>Your Phenotypes</h2>
<div class="clearfix">
<%= f.label :sex, "Chromosomal Sex"%>
<%= f.select :sex, options_for_select(["XX", "XY", "other", "rather not say"], :selected => @user.sex) %>
</div>
<div class="clearfix">
<%= f.label :yearofbirth, "Year of Birth"%>
<%= f.select :yearofbirth, options_for_select(((1900..2011).to_a << "rather not say").reverse, :selected => @user.yearofbirth) %>
</div>
<%= f.fields_for :user_phenotypes do |p| %>
<div class="field">

View File

@@ -0,0 +1,11 @@
class AddSexAgeColumnsToUser < ActiveRecord::Migration
def self.up
add_column :users, :sex, :string, :default => "rather not say"
add_column :users, :yearofbirth, :string, :default => "rather not say"
end
def self.down
remove_column :users, :sex
remove_column :users, :yearofbirth
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110926092220) do
ActiveRecord::Schema.define(:version => 20110926172905) do
create_table "achievements", :force => true do |t|
t.text "award"
@@ -30,18 +30,18 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
end
create_table "homepages", :force => true do |t|
t.string "url"
t.string "description"
t.text "url"
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
create_table "mendeley_papers", :force => true do |t|
t.string "first_author"
t.string "title"
t.string "mendeley_url"
t.string "doi"
t.text "first_author"
t.text "title"
t.text "mendeley_url"
t.text "doi"
t.integer "pub_year"
t.string "uuid"
t.boolean "open_access"
@@ -52,7 +52,7 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
end
create_table "messages", :force => true do |t|
t.string "subject"
t.text "subject"
t.integer "user_id"
t.text "body"
t.boolean "sent"
@@ -64,8 +64,8 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
end
create_table "phenotype_comments", :force => true do |t|
t.string "comment_text"
t.string "subject"
t.text "comment_text"
t.text "subject"
t.integer "user_id"
t.integer "phenotype_id"
t.integer "reply_to_id"
@@ -83,9 +83,9 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
end
create_table "plos_papers", :force => true do |t|
t.string "first_author"
t.string "title"
t.string "doi"
t.text "first_author"
t.text "title"
t.text "doi"
t.datetime "pub_date"
t.datetime "created_at"
t.datetime "updated_at"
@@ -94,8 +94,8 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
end
create_table "snp_comments", :force => true do |t|
t.string "comment_text"
t.string "subject"
t.text "comment_text"
t.text "subject"
t.integer "user_id"
t.integer "snp_id"
t.datetime "created_at"
@@ -105,7 +105,7 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
create_table "snpedia_papers", :force => true do |t|
t.string "url"
t.string "summary"
t.text "summary"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "snp_id"
@@ -119,15 +119,9 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
t.string "allele_frequency"
t.integer "ranking"
t.integer "number_of_users", :default => 0
<<<<<<< HEAD
t.datetime "mendeley_updated", :default => '2011-08-22 15:25:47'
t.datetime "plos_updated", :default => '2011-08-22 15:25:47'
t.datetime "snpedia_updated", :default => '2011-08-22 15:25:47'
=======
t.datetime "mendeley_updated", :default => '2011-08-13 15:18:53'
t.datetime "plos_updated", :default => '2011-08-13 15:18:53'
t.datetime "snpedia_updated", :default => '2011-08-13 15:18:53'
>>>>>>> baa3387dcbb11ce042acb224478742b6f726d077
t.datetime "mendeley_updated", :default => '2011-08-22 23:08:27'
t.datetime "plos_updated", :default => '2011-08-22 23:08:27'
t.datetime "snpedia_updated", :default => '2011-08-22 23:08:27'
t.datetime "created_at"
t.datetime "updated_at"
end
@@ -181,6 +175,8 @@ ActiveRecord::Schema.define(:version => 20110926092220) do
t.boolean "help_one", :default => false
t.boolean "help_two", :default => false
t.boolean "help_three", :default => false
t.string "sex", :default => "rather not say"
t.string "yearofbirth", :default => "rather not say"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true