From f52058aaf38fa3feb61c244bcaa6a45ee3306fa4 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 26 May 2015 09:37:29 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E6=96=B0=E7=95=8C=E9=9D=A2=EF=BC=88=E6=9C=AA=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 1 + app/views/layouts/base.html.erb | 4 ++-- app/views/layouts/base_welcome.html.erb | 23 ++++++++--------------- app/views/welcome/index.html.erb | 4 ++-- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6e067fb83..787b1b050 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,6 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController + layout "base_welcome" include ApplicationHelper include WelcomeHelper helper :project_score diff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erb index 439c5f7b2..483cabac5 100644 --- a/app/views/layouts/base.html.erb +++ b/app/views/layouts/base.html.erb @@ -12,7 +12,7 @@ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> <%= javascript_include_tag "jquery.leanModal.min" %> -<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> +<%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= heads_for_theme %> <%= call_hook :view_layouts_base_html_head %> @@ -31,7 +31,7 @@
<%=render :partial => 'layouts/base_footer'%> - + diff --git a/app/views/layouts/base_welcome.html.erb b/app/views/layouts/base_welcome.html.erb index d04f492ef..6d3b900c6 100644 --- a/app/views/layouts/base_welcome.html.erb +++ b/app/views/layouts/base_welcome.html.erb @@ -5,10 +5,9 @@ <%=h html_title %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> - <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project', :media => 'all' %> + <%= javascript_include_tag "jquery.leanModal.min" %> - <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%> <%= csrf_meta_tag %> <%= favicon %> @@ -18,32 +17,26 @@ <%= yield :header_tags -%> - -
-
-
- <%=render :partial => 'layouts/base_header'%> + +
+ <%= render :partial => 'layouts/new_header' %> +
<%= render_flash_messages %> <%= yield %> <%= call_hook :view_layouts_base_content %>
- <%=render :partial => 'layouts/base_footer'%> + <%=render :partial => 'layouts/new_footer'%>
- -
-
<%= call_hook :view_layouts_base_body_bottom %> diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index dc8ef7f35..0cd9622a5 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -23,7 +23,7 @@ $(document).ready(function($) { $("#loggedas").find("a").attr("target", "_blank"); //$("#content .tabs_new~ .pagination").find("a").removeAttr("target"); - }); + });
@@ -45,7 +45,7 @@ <% if @organization.nil? %> <% unless @first_page.nil? %> <%= l(:label_welcome_trustie_project)%><%= l(:label_welcome_trustie_project_description)%> From 1b5c41b3ad696d3f0fce9ef569ef553f7adaf53e Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 27 May 2015 17:40:18 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/welcome_controller.rb | 2 +- app/services/users_service.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 787b1b050..d570c238e 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,7 +16,7 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController - layout "base_welcome" + # layout "base_welcome" include ApplicationHelper include WelcomeHelper helper :project_score diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 7d7976bb5..1121c98b4 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -62,7 +62,7 @@ class UsersService else @user.password = "" end - @user = automatically_register(@user) + @user = automatically_register_lock(@user) if @user.id != nil ue = @user.user_extensions ||= UserExtensions.new ue.user_id = @user.id From cae882b3d62b3ae5d0500c9563cca5c19dc58141 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 28 May 2015 14:44:04 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=A1=A8=20=E7=9B=B8=E5=85=B3=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/invite_list.rb | 5 +++++ app/models/project.rb | 2 +- app/models/user.rb | 4 ++++ db/migrate/20150528024616_create_invite_lists.rb | 10 ++++++++++ spec/factories/invite_lists.rb | 7 +++++++ spec/models/invite_list_spec.rb | 5 +++++ 6 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 app/models/invite_list.rb create mode 100644 db/migrate/20150528024616_create_invite_lists.rb create mode 100644 spec/factories/invite_lists.rb create mode 100644 spec/models/invite_list_spec.rb diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb new file mode 100644 index 000000000..605c35a07 --- /dev/null +++ b/app/models/invite_list.rb @@ -0,0 +1,5 @@ +class InviteList < ActiveRecord::Base + attr_accessible :project_id, :user_id + belongs_to :user + belongs_to :project +end diff --git a/app/models/project.rb b/app/models/project.rb index 47878dbec..249df8640 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,7 +67,7 @@ class Project < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy has_many :applied_projects - + has_many :invite_lists # end #ADDED BY NIE diff --git a/app/models/user.rb b/app/models/user.rb index 7b232bf13..fa3134a58 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -125,6 +125,10 @@ class User < Principal has_many :documents # 项目中关联的文档再次与人关联 # end + # 邮件邀请状态 + has_many :invite_lists + # end + ######added by nie has_many :project_infos, :dependent => :destroy has_one :user_status, :dependent => :destroy diff --git a/db/migrate/20150528024616_create_invite_lists.rb b/db/migrate/20150528024616_create_invite_lists.rb new file mode 100644 index 000000000..222a3a3f8 --- /dev/null +++ b/db/migrate/20150528024616_create_invite_lists.rb @@ -0,0 +1,10 @@ +class CreateInviteLists < ActiveRecord::Migration + def change + create_table :invite_lists do |t| + t.integer :project_id + t.integer :user_id + + t.timestamps + end + end +end diff --git a/spec/factories/invite_lists.rb b/spec/factories/invite_lists.rb new file mode 100644 index 000000000..c9ce0e826 --- /dev/null +++ b/spec/factories/invite_lists.rb @@ -0,0 +1,7 @@ +FactoryGirl.define do + factory :invite_list do + project_id 1 +user_id 1 + end + +end diff --git a/spec/models/invite_list_spec.rb b/spec/models/invite_list_spec.rb new file mode 100644 index 000000000..8da327964 --- /dev/null +++ b/spec/models/invite_list_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe InviteList, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From d9ae9c80614943f4983a8c06f38000cdf5cbf4a1 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 May 2015 14:36:44 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=8F=90=E9=86=92=EF=BC=88=E9=82=80=E8=AF=B7?= =?UTF-8?q?=EF=BC=9A=E6=9C=AA=E6=BF=80=E6=B4=BB=20=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=EF=BC=9A=E6=BF=80=E6=B4=BB=E5=B9=B6=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E9=A1=B9=E7=9B=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 16 ++++++++++++++-- app/models/mailer.rb | 4 ++-- config/locales/projects/zh.yml | 1 + 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b9e46daee..b8764cc48 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -248,8 +248,20 @@ class ProjectsController < ApplicationController # 2、加入项目、创建角色 # 3、用户得分 if params[:mail] - Member.create(:role_ids => [4], :user_id => params[:user],:project_id => params[:id]) - UserGrade.create(:user_id =>params[:user], :project_id => params[:id]) + user = User.find(params[:user_id]) + user.activate! + Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) + UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) + token = Token.get_token_from_user(user, 'autologin') + #user = User.try_to_autologin(token.value) + if user + start_user_session(user) + user.save + redirect_to project_member_path(params[:id]) + return + # account_ project_member_path(params[:id]) + flash[:notice] = l(:label_mail_invite_success) + end end if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 2c3a94874..4018f44a9 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -60,8 +60,8 @@ class Mailer < ActionMailer::Base user = us.register_auto(login, @email, @password) User.current = user unless User.current.nil? @user = user - @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) + + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user_id => user.id, :mail => true) mail :to => email, :subject => @subject end diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index 180b0322a..8ca078084 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -342,6 +342,7 @@ zh: label_invite_trustie_user_tips: "输入姓名、邮箱、昵称" label_user_role_null: 用户和角色不能留空! label_invite_project: 邀请您加入项目 + label_mail_invite_success: 您已成功加入项目! label_invite_success: 邀请成功 label_invite_members: 邀请用户 # From ee7c1eff32e6cdd8ecb3acd48385b9c55b0f1314 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 May 2015 14:50:27 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=B2=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E7=94=A8=E6=88=B7=E9=82=AE=E4=BB=B6=E9=82=80=E8=AF=B7?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 4018f44a9..2760af323 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -73,7 +73,7 @@ class Mailer < ActionMailer::Base @project_name = "#{project.name}" @user = user @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end From 697f891546a9be1772bc700587d3da7e87535365 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 May 2015 16:04:21 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=A7=81=E6=9C=89=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E9=82=80=E8=AF=B7=E6=9D=83=E9=99=90=E8=AE=A4?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 41 +++++++++++++------------- app/models/mailer.rb | 5 ++-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b8764cc48..fbafd16e9 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -243,26 +243,7 @@ class ProjectsController < ApplicationController # Author lizanle # Description 项目动态展示方法,删除了不必要的代码 def show - # params[:login]为邮箱邀请用户加入,主要功能: - # 1、自动注册 - # 2、加入项目、创建角色 - # 3、用户得分 - if params[:mail] - user = User.find(params[:user_id]) - user.activate! - Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) - UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) - token = Token.get_token_from_user(user, 'autologin') - #user = User.try_to_autologin(token.value) - if user - start_user_session(user) - user.save - redirect_to project_member_path(params[:id]) - return - # account_ project_member_path(params[:id]) - flash[:notice] = l(:label_mail_invite_success) - end - end + if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end @@ -411,6 +392,26 @@ class ProjectsController < ApplicationController # by young # include CoursesHelper def member + # params[:login]为邮箱邀请用户加入,主要功能: + # 1、自动注册 + # 2、加入项目、创建角色 + # 3、用户得分 + if params[:mail] + user = User.find(params[:user_id]) + user.activate! + Member.create(:role_ids => [4], :user_id => params[:user_id],:project_id => params[:id]) + UserGrade.create(:user_id => params[:user_id], :project_id => params[:id]) + token = Token.get_token_from_user(user, 'autologin') + #user = User.try_to_autologin(token.value) + if user + start_user_session(user) + user.save + redirect_to project_member_path(params[:id]) + return + # account_ project_member_path(params[:id]) + flash[:notice] = l(:label_mail_invite_success) + end + end ## 有角色参数的才是课程,没有的就是项目 @render_file = 'project_member_list' # 判断是否课程 diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 2760af323..dbc5d3cff 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -61,7 +61,7 @@ class Mailer < ActionMailer::Base User.current = user unless User.current.nil? @user = user - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user_id => user.id, :mail => true) + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true) mail :to => email, :subject => @subject end @@ -72,8 +72,9 @@ class Mailer < ActionMailer::Base @invitor_name = "#{invitor.name}" @project_name = "#{project.name}" @user = user + @project = project @token = Token.get_token_from_user(user, 'autologin') - @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'member', :id => project.id, :user_id => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end From 7197c33be4d552d68f3787c833a4b31d301bf7a4 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 29 May 2015 16:07:57 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E6=9A=82?= =?UTF-8?q?=E6=97=B6=E6=9C=AA=E5=AE=8C=E6=88=90=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/invite_list.rb | 4 ++-- app/models/project.rb | 2 +- app/models/user.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/invite_list.rb b/app/models/invite_list.rb index 605c35a07..f1ba8546f 100644 --- a/app/models/invite_list.rb +++ b/app/models/invite_list.rb @@ -1,5 +1,5 @@ class InviteList < ActiveRecord::Base attr_accessible :project_id, :user_id - belongs_to :user - belongs_to :project + # belongs_to :user + # belongs_to :project end diff --git a/app/models/project.rb b/app/models/project.rb index 249df8640..bf94df248 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -67,7 +67,7 @@ class Project < ActiveRecord::Base has_many :student, :through => :students_for_courses, :source => :user has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy has_many :applied_projects - has_many :invite_lists + # has_many :invite_lists # end #ADDED BY NIE diff --git a/app/models/user.rb b/app/models/user.rb index fa3134a58..4c30012d7 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -126,7 +126,7 @@ class User < Principal # end # 邮件邀请状态 - has_many :invite_lists + # has_many :invite_lists # end ######added by nie