From 86347cab8924b8538fe276964f414baff34c83c8 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 27 Apr 2015 16:44:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E7=8E=B0=E5=9C=A8=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87rake=20redmine:email:test[guange]=20=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=B5=8B=E8=AF=95=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- config/configuration.yml | 17 +++++++++-------- lib/tasks/email.rake | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index eacead013..a930b5467 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -817,12 +817,12 @@ class Mailer < ActionMailer::Base headers[:references] = @references_objects.collect {|o| "<#{self.class.message_id_for(o)}>"}.join(' ') end + set_language_if_valid @initial_language super headers do |format| format.text format.html unless Setting.plain_text_mail? end - set_language_if_valid @initial_language end def initialize(*args) diff --git a/config/configuration.yml b/config/configuration.yml index 5eba1c71d..87a54a976 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -215,11 +215,12 @@ production: # specific configuration options for development environment # that overrides the default ones development: - delivery_method: :smtp - smtp_settings: - address: mail.trustie.net - port: 25 - domain: mail.trustie.net - authentication: :login - user_name: "mail@trustie.net" - password: "loong2010" + email_delivery: + delivery_method: :smtp + smtp_settings: + address: mail.trustie.net + port: 25 + domain: mail.trustie.net + authentication: :login + user_name: "mail@trustie.net" + password: "loong2010" diff --git a/lib/tasks/email.rake b/lib/tasks/email.rake index 5f9bf7769..5126d7a69 100644 --- a/lib/tasks/email.rake +++ b/lib/tasks/email.rake @@ -186,9 +186,9 @@ END_DESC ActionMailer::Base.raise_delivery_errors = true begin - Mailer.with_synched_deliveries do - Mailer.test_email(user).deliver - end + # Mailer.with_synched_deliveries do + Mailer.test_email(user).deliver! + # end puts l(:notice_email_sent, user.mail) rescue Exception => e abort l(:notice_email_error, e.message) From b70ada57e6fa0a9e2f1d41b351c7fb5398d894de Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 27 Apr 2015 21:54:49 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=9C=AA=E5=A4=84?= =?UTF-8?q?=E7=90=86text=E5=8F=91=E9=80=81=E7=B1=BB=E5=9E=8B=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=AF=8F=E6=97=A5=E5=8F=91=E9=80=81=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/mailer/issue_add.text.erb | 8 +++++++- app/views/mailer/issue_edit.text.erb | 8 +++++++- app/views/mailer/send_for_user_activities.text.erb | 8 +++++++- config/application.rb | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/views/mailer/issue_add.text.erb b/app/views/mailer/issue_add.text.erb index c5b391685..cc2eb814f 100644 --- a/app/views/mailer/issue_add.text.erb +++ b/app/views/mailer/issue_add.text.erb @@ -1,3 +1,9 @@ <%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> -<%= link_to( l(:mail_issue_footer), @user_url) %> \ No newline at end of file +<% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> + <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> + + <% else %> + <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> + <% end %> +<% end %> diff --git a/app/views/mailer/issue_edit.text.erb b/app/views/mailer/issue_edit.text.erb index 1434a7a33..d1d625cec 100644 --- a/app/views/mailer/issue_edit.text.erb +++ b/app/views/mailer/issue_edit.text.erb @@ -5,4 +5,10 @@ -------------------------------------------------------------------------------- <%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> -<%= link_to( l(:mail_issue_footer), @user_url) %> \ No newline at end of file +<% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> + <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> + + <% else %> + <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> + <% end %> +<% end %> diff --git a/app/views/mailer/send_for_user_activities.text.erb b/app/views/mailer/send_for_user_activities.text.erb index 4de42b8aa..59735225d 100644 --- a/app/views/mailer/send_for_user_activities.text.erb +++ b/app/views/mailer/send_for_user_activities.text.erb @@ -293,4 +293,10 @@ <% end %> - <%= link_to l(:mail_footer), @user_url, :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> +<% [:label_user_mail_option_all, :label_user_mail_option_day, :label_user_mail_option_none].each do |mail_option| %> + <% if Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten][@user.mail_notification] == mail_option %> + <%= l(mail_option) %> + <% else %> + <%= link_to l(mail_option), my_change_mail_notification_url(token: @token.value,mail_notification: Hash[*User::MAIL_NOTIFICATION_OPTIONS.flatten].invert[mail_option]), :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %> + <% end %> +<% end %> diff --git a/config/application.rb b/config/application.rb index 57ae436cb..4a0e56115 100644 --- a/config/application.rb +++ b/config/application.rb @@ -48,7 +48,7 @@ module RedmineApp # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de + config.i18n.default_locale = :zh # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" From 38ec84cde97a0685f6081b405823f7f0b5c49899 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Tue, 28 Apr 2015 10:33:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=B0=86=E5=88=A0=E9=99=A4=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=BA=93=E7=9A=84=E6=93=8D=E4=BD=9C=E7=BD=AE=E5=85=A5?= =?UTF-8?q?=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 20 +++------------ app/models/project.rb | 2 +- app/tasks/destroy_repository_task.rb | 25 +++++++++++++++++++ ...150428021035_add_hidden_to_repositories.rb | 5 ++++ db/schema.rb | 3 ++- 5 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 app/tasks/destroy_repository_task.rb create mode 100644 db/migrate/20150428021035_add_hidden_to_repositories.rb diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index c90cc1cc3..5fe953563 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -236,24 +236,10 @@ update end def destroy - @root_path=RepositoriesHelper::ROOT_PATH - @repo_name=User.current.login.to_s+"_"+@repository.identifier.to_s - @repository_name=User.current.login.to_s+"/"+@repository.identifier.to_s+".git" - @middle=User.current.login.to_s+"_"+@repository.identifier.to_s+"-write:" - @repository.destroy if request.delete? + DestroyRepositoryTask.new.destroy(User.current.id, @repository.id) + @repository.hidden = true + @repository.save redirect_to settings_project_url(@project, :tab => 'repositories') - if(@repository.type=="Repository::Git") - logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+ - "repository_name"+@repository_name+"user group"+@middle - system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd" - system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd" - system "rm -r "+@root_path+"htdocs/"+@repository_name - # if(@sed_user&&@sed_group&&@remove) - # else - # logger.info "An error occured when destory the repository"+"delete form passwd: \n"+ - # @sed_user+"delete from group"+@sed_group+"delete from file"+@remove - # end - end end def show diff --git a/app/models/project.rb b/app/models/project.rb index 07854822e..f257058ea 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -51,7 +51,7 @@ class Project < ActiveRecord::Base has_many :issue_categories, :dependent => :delete_all, :order => "#{IssueCategory.table_name}.name" has_many :boards, :dependent => :destroy, :order => "position ASC" has_one :repository, :conditions => ["is_default = ?", true] - has_many :repositories, :dependent => :destroy + has_many :repositories, :dependent => :destroy, conditions: "hidden=false" has_many :changesets, :through => :repository #added by xianbo for delete biding_project has_many :biding_projects, :dependent => :destroy diff --git a/app/tasks/destroy_repository_task.rb b/app/tasks/destroy_repository_task.rb new file mode 100644 index 000000000..3e434422e --- /dev/null +++ b/app/tasks/destroy_repository_task.rb @@ -0,0 +1,25 @@ +#coding=utf-8 +# + +class DestroyRepositoryTask + def destroy(user_id, rep_id) + user = User.find(user_id) + repository = Repository.find(rep_id) + + Rails.logger.info "start delete repository #{user} #{repository}" + @root_path=RepositoriesHelper::ROOT_PATH + @repo_name=user.login.to_s+"_"+repository.identifier.to_s + @repository_name=user.login.to_s+"/"+repository.identifier.to_s+".git" + @middle=user.login.to_s+"_"+repository.identifier.to_s+"-write:" + repository.destroy + if(repository.type=="Repository::Git") + Rails.logger.info "destory the repository value"+"root path"+@root_path+"repo_name"+@repo_name+ + "repository_name"+@repository_name+"user group"+@middle + system "sed -i /"+@repo_name+"/{d} "+@root_path+"htdocs/user.passwd" + system "sed -i /"+@middle+"/{d} "+@root_path+"htdocs/group.passwd" + system "rm -r "+@root_path+"htdocs/"+@repository_name + end + end + + handle_asynchronously :destroy,:queue => 'repository' +end diff --git a/db/migrate/20150428021035_add_hidden_to_repositories.rb b/db/migrate/20150428021035_add_hidden_to_repositories.rb new file mode 100644 index 000000000..13f10ce4f --- /dev/null +++ b/db/migrate/20150428021035_add_hidden_to_repositories.rb @@ -0,0 +1,5 @@ +class AddHiddenToRepositories < ActiveRecord::Migration + def change + add_column :repositories, :hidden, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 3e07b71db..dcbe017fb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150422034543) do +ActiveRecord::Schema.define(:version => 20150428021035) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1058,6 +1058,7 @@ ActiveRecord::Schema.define(:version => 20150422034543) do t.text "extra_info" t.string "identifier" t.boolean "is_default", :default => false + t.boolean "hidden", :default => false end add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"