From a3fd5411198f95fd77124e9a513f48a09ac23196 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:15:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=82=AE=E4=BB=B6?= =?UTF-8?q?=E9=82=80=E8=AF=B7=E6=96=B0=E7=94=A8=E6=88=B7=E3=80=81=E5=B7=B2?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 +++--- app/helpers/account_helper.rb | 12 ++++++++++++ app/models/mailer.rb | 8 ++------ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c79d0862f..536ea6bba 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -247,9 +247,9 @@ class ProjectsController < ApplicationController # 1、自动注册 # 2、加入项目、创建角色 # 3、用户得分 - if params[:email] - user = User.find_by_mail(params[:email].to_s) - Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id) + 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]) end if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return diff --git a/app/helpers/account_helper.rb b/app/helpers/account_helper.rb index 7ad6fe65b..827557a40 100644 --- a/app/helpers/account_helper.rb +++ b/app/helpers/account_helper.rb @@ -47,6 +47,18 @@ module AccountHelper user end + # 自动创建一个新用户,但是初始状态是锁定的 + def automatically_register_lock(user, &block) + user.lock + user.last_login_on = Time.now + if user.save + UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) + else + yield if block_given? + end + user + end + def administrator_manually__register(user, &block) if user.save UserStatus.create(:user_id => user.id ,:changsets_count => 0, :watchers_count => 0) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 7756b7e27..2c3a94874 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -58,14 +58,10 @@ class Mailer < ActionMailer::Base us = UsersService.new # 自动激活用户 user = us.register_auto(login, @email, @password) - - Member.create(:role_ids => [4], :user_id => user.id,:project_id => project.id) - UserGrade.create(:user_id => user.id, :project_id => project.id) 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, :token => @token.value - ) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end @@ -77,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, :email => email, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id, :user => user.id, :mail => true, :token => @token.value) mail :to => email, :subject => @subject end From 975b19c5dec9b8a543727dddea2e8c58f4a0f823 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:35:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=BA=E9=99=B7?= =?UTF-8?q?=E2=80=9C=E6=B7=BB=E5=8A=A0=E4=BA=8E=E2=80=9D=E2=80=9C=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=8E=E2=80=9D=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/show.html.erb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index cff5aae06..112b64745 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -19,11 +19,11 @@

<%= @issue.author %> - <% if @issue.created_on != @issue.updated_on %> - 更新于 <%= format_time(@issue.created_on).html_safe %> - <% else %> - 添加于 <%= format_time(@issue.updated_on).html_safe %> - <% end %> + <%# if @issue.created_on != @issue.updated_on %> + 添加于 <%= format_time(@issue.created_on).html_safe %> + <%# else %> + <%#= format_time(@issue.updated_on).html_safe %> + <%# end %> 'action_menu' %> From fcb5444076d8fdd50ecb37a191fe2549f42fb818 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 10:43:50 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AB=9E=E8=B5=9B?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E9=A1=B5=E9=9D=A2=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/contests/index.html.erb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/views/contests/index.html.erb b/app/views/contests/index.html.erb index 170f11037..26e9e2114 100644 --- a/app/views/contests/index.html.erb +++ b/app/views/contests/index.html.erb @@ -46,9 +46,7 @@ <%= text_field_tag 'name', params[:name], :size => 30, :onkeyup => 'regexName1();', :width => "125px" %> <%= hidden_field_tag 'project_type', params[:project_type] %> <%#= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %> - - <%= l(:label_search)%> - + <%= submit_tag l(:label_search), :class => "enterprise", :name => "contests_search" %>
From 67061d0ee5eaaef4fd6698bad2ce929034d9afc7 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 22 May 2015 11:18:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=96=B0=E5=BB=BA?= =?UTF-8?q?=E9=87=8D=E5=90=8D=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/project.rb b/app/models/project.rb index f257058ea..47878dbec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -114,7 +114,7 @@ class Project < ActiveRecord::Base validates_presence_of :name, :identifier validates_uniqueness_of :identifier - validates_uniqueness_of :name + # validates_uniqueness_of :name validates_associated :wiki#, :repository # validates_length_of :description, :maximum => 255 validates_length_of :name, :maximum => 255