mirror of
https://github.com/chenasraf/snpr.git
synced 2026-05-18 01:39:01 +00:00
added notification-system for messages and commentreplies, parsing for ftdna and updated news-page
This commit is contained in:
@@ -5,6 +5,8 @@ class NewsController < ApplicationController
|
||||
@new_genotypes = Genotype.all(:order => "created_at DESC", :limit => 20)
|
||||
@new_users = User.all(:order => "created_at DESC", :limit => 20)
|
||||
@new_phenotypes = Phenotype.all(:order => "created_at DESC", :limit => 20)
|
||||
@new_phenotype_comments = PhenotypeComment.all(:order => "created_at DESC", :limit => 20)
|
||||
@new_snp_comments = SnpComment.all(:order => "created_at DESC", :limit => 20)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
|
||||
@@ -29,6 +29,14 @@ class PhenotypeCommentsController < ApplicationController
|
||||
@phenotype_comment.user_id = current_user.id
|
||||
@phenotype_comment.phenotype_id = params[:phenotype_comment][:phenotype_id]
|
||||
if @phenotype_comment.save
|
||||
if @phenotype_comment.reply_to_id != -1
|
||||
@reply_user = PhenotypeComment.find_by_id(@phenotype_comment.reply_to_id).user
|
||||
if@reply_user != nil
|
||||
if @reply_user.message_on_phenotype_comment_reply == true
|
||||
UserMailer.new_phenotype_comment(@phenotype_comment,@reply_user).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to "/phenotypes/"+@phenotype_comment.phenotype_id.to_s+"#comments", :notice => 'Comment succesfully created.'
|
||||
else
|
||||
render :action => "new"
|
||||
|
||||
@@ -33,6 +33,14 @@ class SnpCommentsController < ApplicationController
|
||||
@snp_comment.user_id = current_user.id
|
||||
@snp_comment.snp_id = params[:snp_comment][:snp_id]
|
||||
if @snp_comment.save
|
||||
if @snp_comment.reply_to_id != -1
|
||||
@reply_user = SnpComment.find_by_id(@snp_comment.reply_to_id).user
|
||||
if@reply_user != nil
|
||||
if @reply_user.message_on_snp_comment_reply == true
|
||||
UserMailer.new_snp_comment(@snp_comment,@reply_user).deliver
|
||||
end
|
||||
end
|
||||
end
|
||||
redirect_to "/snps/"+@snp_comment.snp_id.to_s + "#comments", :notice => 'Comment succesfully created.'
|
||||
else
|
||||
render :action => "new"
|
||||
|
||||
@@ -31,14 +31,26 @@ class Parsing
|
||||
if temp_array[0] != "Name"
|
||||
snp_array = [temp_array[0],temp_array[2],temp_array[3],temp_array[5]]
|
||||
else
|
||||
snp_array = []
|
||||
next
|
||||
end
|
||||
|
||||
elsif @genotype.filetype == "ftdna-illumina"
|
||||
temp_array = single_snp.split("\",\"")
|
||||
if temp_array[0].index("RSID") == nil
|
||||
if temp_array[0] != nil and temp_array[1] != nil and temp_array[2] != nil and temp_array[3] != nil
|
||||
snp_array = [temp_array[0].gsub("\"",""),temp_array[1].gsub("\"",""),temp_array[2].gsub("\"",""),temp_array[3].gsub("\"","").rstrip]
|
||||
else
|
||||
UserMailer.parsing_error(@genotype.user_id).deliver
|
||||
break
|
||||
end
|
||||
else
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
if snp_array.length == (4)
|
||||
if snp_array[0] != nil and snp_array[1] != nil and snp_array[2] != nil and snp_array[3] != nil
|
||||
# if we do not have the fitting SNP, make one and parse all paper-types for it
|
||||
|
||||
#snp = known_snps[snp_array[0]]
|
||||
snp = known_snps[snp_array[0]]
|
||||
if snp.nil?
|
||||
snp = Snp.new(:name => snp_array[0], :chromosome => snp_array[1], :position => snp_array[2], :ranking => 0)
|
||||
@@ -48,7 +60,7 @@ class Parsing
|
||||
|
||||
new_user_snps << [ @genotype.id, @genotype.user_id, snp_array[0], snp_array[3].rstrip ]
|
||||
else
|
||||
User.find_by_id(@genotype.user_id).toggle!(:has_sequence)
|
||||
UserMailer.parsing_error(@genotype.user_id).deliver
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,4 +23,27 @@ default :from => "donotreply@opensnp.org"
|
||||
@variation = variation
|
||||
mail(:subject => "openSNP.org: No genotyping files match your search",:to => target_address)
|
||||
end
|
||||
|
||||
def parsing_error(user_id)
|
||||
@user = User.find_by_id(user_id)
|
||||
mail(:subject => "openSNP.org: Something went wrong while parsing", :to=> @user.email)
|
||||
end
|
||||
|
||||
def new_message(user_id,message_id)
|
||||
@user = User.find_by_id(user_id)
|
||||
@message = Message.find_by_id(message_id)
|
||||
mail(:subject => "openSNP.org: You've got a new mail from #{User.find_by_id(@message.from_id).name}", :to => @user.email)
|
||||
end
|
||||
|
||||
def new_snp_comment(snp_comment,to_user)
|
||||
@user = to_user
|
||||
@snp_comment = snp_comment
|
||||
mail(:subject => "openSNP.org: You've got a reply to one of your SNP-comments", :to => @user.email)
|
||||
end
|
||||
|
||||
def new_phenotype_comment(phenotype_comment,to_user)
|
||||
@user = to_user
|
||||
@phenotype_comment = phenotype_comment
|
||||
mail(:subject => "openSNP.org: You've got a reply to one of your phenotype-comments", :to => @user.email)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,9 +14,11 @@ class Message < ActiveRecord::Base
|
||||
msg.sent = false
|
||||
msg.to_id = recipient
|
||||
msg.from_id = from
|
||||
msg.user_has_seen = false
|
||||
msg.user_has_seen = false
|
||||
msg.save
|
||||
|
||||
if User.find_by_id(recipient).message_on_message == true
|
||||
UserMailer.new_message(recipient,msg.id).deliver
|
||||
end
|
||||
self.update_attributes :from_id => from, :sent => true, :to_id => recipient, :user_has_seen => true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -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, :sex, :yearofbirth, :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, :message_on_message, :message_on_phenotype_comment_reply, :message_on_snp_comment_reply
|
||||
before_validation :clear_avatar
|
||||
|
||||
validates_attachment_size :avatar, :less_than=>1.megabyte
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
<span>deCODEme-format</span>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
<%= f.radio_button :filetype,"ftdna-illumina"%>
|
||||
<span>FamilyTreeDNA, Illumina-Format</span>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
<li><a href="#users">New users</a></li>
|
||||
<li><a href="#genotypes">New genotypes</a></li>
|
||||
<li><a href="#phenotypes">New phenotypes</a></li>
|
||||
<li><a href="#snpcomments">SNP-Comments</a></li>
|
||||
<li><a href="#phenotypecomments">Phenotype-Comments</a></li>
|
||||
</ul>
|
||||
<div id="general">
|
||||
<h5>«5 days after launch»</h5>
|
||||
@@ -72,3 +74,43 @@ Wow currently there are no things that do not work as expected. So far: Thanks t
|
||||
<% end %>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="phenotypecomments">
|
||||
<h2>Phenotype Comments</h2>
|
||||
<table class="common-table zebra-striped">
|
||||
<tr>
|
||||
<th>Phenotype</th>
|
||||
<th>Comment By</th>
|
||||
<th>Subject</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
<%@new_phenotype_comments.each do |pc|%>
|
||||
<tr>
|
||||
<td><%=link_to pc.phenotype.characteristic, pc.phenotype%></td>
|
||||
<td><%if pc.user != nil%><%=link_to pc.user.name, pc.user%><%else%>Deleted User<%end%></td>
|
||||
<td><%if pc.subject != ""%><%=pc.subject%><%else%>-<%end%></td>
|
||||
<td><%=pc.created_at%></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="snpcomments">
|
||||
<h2>SNP Comments</h2>
|
||||
<table class="common-table zebra-striped">
|
||||
<tr>
|
||||
<th>SNP</th>
|
||||
<th>Comment By</th>
|
||||
<th>Subject</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
<%@new_snp_comments.each do |pc|%>
|
||||
<tr>
|
||||
<td><%=link_to pc.snp.name, pc.snp%></td>
|
||||
<td><%if pc.user != nil%><%=link_to pc.user.name, pc.user%><%else%>Deleted User<%end%></td>
|
||||
<td><%if pc.subject != ""%><%=pc.subject%><%else%>-<%end%></td>
|
||||
<td><%=pc.created_at%></td>
|
||||
</tr>
|
||||
<%end%>
|
||||
</table>
|
||||
</div>
|
||||
14
app/views/user_mailer/new_message.text.erb
Normal file
14
app/views/user_mailer/new_message.text.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
Hello <%=@user.name%>,
|
||||
you just got a new message from <%=User.find_by_id(@message.from_id).name%> with the following subject: <%=@message.subject%>
|
||||
Below you find the text of the message:
|
||||
|
||||
--- SNIP ---
|
||||
|
||||
<%=@message.body%>
|
||||
|
||||
--- SNAP ---
|
||||
|
||||
You can read and reply to this message by clicking this link: <%=message_url(@message)%>
|
||||
|
||||
Cheers,
|
||||
your openSNP-team
|
||||
15
app/views/user_mailer/new_phenotype_comment.text.erb
Normal file
15
app/views/user_mailer/new_phenotype_comment.text.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
Hello <%=@user.name%>,
|
||||
<%=@phenotype_comment.user.name%> just replied to a phenotype comment on the Phenotype <%=@phenotype_comment.phenotype.characteristic%> from you.
|
||||
|
||||
This is the text of the reply:
|
||||
|
||||
--- SNIP ---
|
||||
|
||||
<%=@phenotype_comment.comment_text%>
|
||||
|
||||
--- SNAP ---
|
||||
|
||||
You can read and reply to this comment by clicking this link: <%=phenotype_url(@phenotype_comment.phenotype)%>#comments
|
||||
|
||||
Cheers,
|
||||
your openSNP-team
|
||||
15
app/views/user_mailer/new_snp_comment.text.erb
Normal file
15
app/views/user_mailer/new_snp_comment.text.erb
Normal file
@@ -0,0 +1,15 @@
|
||||
Hello <%=@user.name%>,
|
||||
<%=@snp_comment.user.name%> just replied to a SNP comment on the SNP <%=@snp_comment.snp.name%> from you.
|
||||
|
||||
This is the text of the reply:
|
||||
|
||||
--- SNIP ---
|
||||
|
||||
<%=@snp_comment.comment_text%>
|
||||
|
||||
--- SNAP ---
|
||||
|
||||
You can read and reply to this comment by clicking this link: <%=snp_url(@snp_comment.snp)%>#comments
|
||||
|
||||
Cheers,
|
||||
your openSNP-team
|
||||
10
app/views/user_mailer/parsing_error.text.erb
Normal file
10
app/views/user_mailer/parsing_error.text.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
Hello <%=@user.name%>,
|
||||
|
||||
We are sorry to inform you that there was at least one line in your genotyping-file, excluding the header, that could not be parsed correctly. This may be a minor problem or not. If you can't see your local genotypes for the SNPs or you encounter any other problems you could try to delete your genotyping file at <%=edit_user_url(@user)%>. Afterwards you can re-upload your genotyping file.
|
||||
|
||||
If you are sure that you set the correct filetype and everything else also should be okay, but this bug persists: Please let us know. Maybe your DTC-company changed the file-format they use.
|
||||
|
||||
If you need some help you can read the FAQ <%=faq_url()%> or contact us by replying to this mail.
|
||||
|
||||
Cheers,
|
||||
your openSNP-team.
|
||||
@@ -7,6 +7,7 @@
|
||||
<li><a href="#general">General</a></li>
|
||||
<li><a href="#phenotypes">Phenotypes</a></li>
|
||||
<li><a href="#details">Details</a></li>
|
||||
<li><a href="#notifications">Notifications</a></li>
|
||||
<li><a href="#deleting">Deleting</a></li>
|
||||
</ul>
|
||||
<div id="general">
|
||||
@@ -78,6 +79,22 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="notifications">
|
||||
<div class="well">
|
||||
<h2>Notifications</h2>
|
||||
<h6>Set up mail notifications to make sure you don't miss a thing that happens at openSNP</h6>
|
||||
<div class="clearfix">
|
||||
<%= f.label :message_on_message, "Messages"%>Get a mail on new messages: <%= f.check_box :message_on_message%>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<%= f.label :message_on_phenotype_comment_reply, "Phenotype Comments"%>Get a mail on each phenotype comment that is a reply to one of yours: <%= f.check_box :message_on_phenotype_comment_reply%>
|
||||
</div>
|
||||
<div class="clearfix">
|
||||
<%= f.label :message_on_snp_comment_reply, "SNP Comments"%>Get a mail on each SNP comment that is a reply to one of yours: <%= f.check_box :message_on_snp_comment_reply%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="deleting">
|
||||
<div class="well">
|
||||
<h2>Deleting</h2>
|
||||
|
||||
16
db/migrate/20111005210020_add_notifier_columns_to_user.rb
Normal file
16
db/migrate/20111005210020_add_notifier_columns_to_user.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class AddNotifierColumnsToUser < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :users, :message_on_message, :boolean, :default => true
|
||||
add_column :users, :message_on_snp_comment_reply, :boolean, :default => true
|
||||
add_column :users, :message_on_phenotype_comment_reply, :boolean, :default => true
|
||||
User.update_all ["message_on_message = ?", false]
|
||||
User.update_all ["message_on_snp_comment_reply = ?", false]
|
||||
User.update_all ["message_on_phenotype_comment_reply = ?", false]
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :users, :message_on_phenotype_comment_reply
|
||||
remove_column :users, :message_on_snp_comment_reply
|
||||
remove_column :users, :message_on_message
|
||||
end
|
||||
end
|
||||
29
db/schema.rb
29
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110926172905) do
|
||||
ActiveRecord::Schema.define(:version => 20111005210020) do
|
||||
|
||||
create_table "achievements", :force => true do |t|
|
||||
t.text "award"
|
||||
@@ -119,9 +119,9 @@ ActiveRecord::Schema.define(:version => 20110926172905) do
|
||||
t.string "allele_frequency"
|
||||
t.integer "ranking"
|
||||
t.integer "number_of_users", :default => 0
|
||||
t.datetime "mendeley_updated", :default => '2011-08-28 20:37:02'
|
||||
t.datetime "plos_updated", :default => '2011-08-28 20:37:02'
|
||||
t.datetime "snpedia_updated", :default => '2011-08-28 20:37:02'
|
||||
t.datetime "mendeley_updated", :default => '2011-08-31 01:26:24'
|
||||
t.datetime "plos_updated", :default => '2011-08-31 01:26:24'
|
||||
t.datetime "snpedia_updated", :default => '2011-08-31 01:26:24'
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
@@ -160,23 +160,26 @@ ActiveRecord::Schema.define(:version => 20110926172905) do
|
||||
t.string "crypted_password"
|
||||
t.string "persistence_token"
|
||||
t.string "perishable_token"
|
||||
t.boolean "has_sequence", :default => false
|
||||
t.boolean "has_sequence", :default => false
|
||||
t.string "sequence_link"
|
||||
t.text "description"
|
||||
t.boolean "finished_snp_parsing", :default => false
|
||||
t.integer "phenotype_creation_counter", :default => 0
|
||||
t.integer "phenotype_additional_counter", :default => 0
|
||||
t.boolean "finished_snp_parsing", :default => false
|
||||
t.integer "phenotype_creation_counter", :default => 0
|
||||
t.integer "phenotype_additional_counter", :default => 0
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "avatar_file_name"
|
||||
t.string "avatar_content_type"
|
||||
t.integer "avatar_file_size"
|
||||
t.datetime "avatar_updated_at"
|
||||
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"
|
||||
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"
|
||||
t.boolean "message_on_message", :default => false
|
||||
t.boolean "message_on_snp_comment_reply", :default => false
|
||||
t.boolean "message_on_phenotype_comment_reply", :default => false
|
||||
end
|
||||
|
||||
add_index "users", ["email"], :name => "index_users_on_email", :unique => true
|
||||
|
||||
Reference in New Issue
Block a user