From b9ea3e589e23de6b357c6bc3ce467aaac10bfce6 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 17 Jan 2015 11:18:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E7=B3=BB=E7=BB=9F=E3=80=8B=E9=A1=B5=E9=9D=A2=20Signed?= =?UTF-8?q?-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Firefox - Internal Server.launch | 1 + ...Internet Explorer - Internal Server.launch | 1 + app/controllers/application_controller.rb | 5 ++ app/controllers/my_controller.rb | 3 + app/controllers/projects_controller.rb | 6 +- app/controllers/users_controller.rb | 3 + app/models/mailer.rb | 7 ++- app/views/layouts/mailer.html.erb | 63 +++++++++++-------- app/views/mailer/_issue.html.erb | 48 ++++++++++---- app/views/mailer/issue_add.html.erb | 13 +--- app/views/mailer/issue_add.text.erb | 10 +-- 11 files changed, 105 insertions(+), 55 deletions(-) diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch index f21eed9f2..678ced8a0 100644 --- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Firefox - Internal Server.launch @@ -2,6 +2,7 @@ + diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch index 2134fa92c..f7b0844d8 100644 --- a/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/Internet Explorer - Internal Server.launch @@ -2,6 +2,7 @@ + diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fe9f6c1b6..06e5dac30 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -275,7 +275,12 @@ class ApplicationController < ActionController::Base end end end + def auth_login1(token = params[:token]) + if(!User.current.logged? && !token.nil?) + User.current =try_to_autologin1 + end + end def authorize_allowed(ctrl = params[:controller], action = params[:action], global = false) #modify by NWB if @project diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 8ee8d099e..8f00c49cd 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -17,6 +17,9 @@ class MyController < ApplicationController layout "users_base" + # edit + before_filter :auth_login1, :only => [:account] + # before_filter :require_login helper :issues diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5d43a4e20..4e81354f1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -31,14 +31,16 @@ class ProjectsController < ApplicationController menu_item :feedback, :only => :feedback menu_item l(:label_course_file), :only => :index menu_item l(:label_course_news), :only => :index - +# edit + before_filter :authorize1, :only => [:show] +# before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches] # before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, # :statistics, :feedback, :course, :enterprise_course, :course_enterprise, :project_respond, :share, # :show_projects_score, :issue_score_index, :news_score_index, :file_score_index, :code_submit_score_index, :projects_topic_score_index] #此条勿删 课程相关权限 ,:new_homework,:homework,:feedback,,:member - before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] + before_filter :authorize, :only => [:settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy, :calendar] before_filter :file, :statistics, :watcherlist diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7b4d488a9..ee8711e7e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -29,6 +29,9 @@ class UsersController < ApplicationController #Ended by young + # edit + before_filter :auth_login1, :only => [:show] + # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, diff --git a/app/models/mailer.rb b/app/models/mailer.rb index b432461c7..bee0640da 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -109,9 +109,14 @@ class Mailer < ActionMailer::Base token = Token.new(:user => User.find_by_mail(recipients), :action => 'autologin') token.save - @token = token + @token = token @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) + # edit + @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + @user_url = url_for(:controller => 'my', :action => 'account', :user => User.find_by_mail(recipients) , :token => @token.value) + # cc = issue.watcher_recipients - issue.recipients subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index dd2de21b7..de7f4a837 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -1,33 +1,46 @@ +Trustie项目邮件 + + + + -<%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_header).html_safe %> -<%= yield %> -
-<%= Redmine::WikiFormatting.to_html(Setting.text_formatting, Setting.emails_footer).html_safe %> +
+
+
+

亲爱的Trustie用户,您好!

+
+ <%= yield %> +
+
<%= link_to("退订该邮件?", @user_url) %>
+
+
diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index f0dc88d8b..326a21aaa 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -1,15 +1,39 @@ -

<%= link_to(h("#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}"), issue_url) %>

- + +

+ + <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url) %> + 在 + <%= link_to(h("#{@issue.project.name}"),@project_url) %>中有了一个与您相关的最新活动,请您关注!

+
    -
  • <%=l(:field_author)%>: <%=h issue.author %>
  • -
  • <%=l(:field_status)%>: <%=h issue.status %>
  • -
  • <%=l(:field_priority)%>: <%=h issue.priority %>
  • -
  • <%=l(:field_assigned_to)%>: <%=h issue.assigned_to %>
  • -
  • <%=l(:field_category)%>: <%=h issue.category %>
  • -
  • <%=l(:field_fixed_version)%>: <%=h issue.fixed_version %>
  • -<% issue.custom_field_values.each do |c| %> -
  • <%=h c.custom_field.name %>: <%=h show_value(c) %>
  • -<% end %> +
  • 标题:<%= link_to(issue.subject, issue_url) %>
  • +
  • 来源:<%= link_to(h("#{issue.project.name}"),@project_url) %>项目缺陷
  • +
  • 内容: +

    <%= textilizable(issue, :description, :only_path => false) %>

    +
  • +
  • 附件: +

    + <% unless @issue.attachments.nil? %> + <% @issue.attachments.each do |attach| %> + <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %>
    + <% end %> + <% end %> + +

    +
+ +
+
+ +<%# issue.custom_field_values.each do |c| %> + diff --git a/app/views/mailer/issue_add.html.erb b/app/views/mailer/issue_add.html.erb index 3f0fce917..f51dad121 100644 --- a/app/views/mailer/issue_add.html.erb +++ b/app/views/mailer/issue_add.html.erb @@ -1,15 +1,8 @@ +
-<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => h(@issue.author)) %> -
    + <%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> - <% unless @issue.attachments.nil? %> - <% @issue.attachments.each do |attach| %> -
  • <%= l(:label_attachment) %><%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %>
  • - <% end %> -<% end %> -
-
+
-<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> \ No newline at end of file diff --git a/app/views/mailer/issue_add.text.erb b/app/views/mailer/issue_add.text.erb index 4fb52b94c..07411a134 100644 --- a/app/views/mailer/issue_add.text.erb +++ b/app/views/mailer/issue_add.text.erb @@ -1,11 +1,11 @@ -<%= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %> - +<%= link_to(h("#{@issue.author}"+"(#{@issue.author_id.firstname+@issue.author_id.lastname})"), @issue_author_url) %>在<%= link_to(h("#{@issue.project.name}"),@project_url) %> +<%#= l(:text_issue_added, :id => "##{@issue.project_index}", :author => @issue.author) %> !--> +<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> <% @issue.attachments.each do |attach| %> - <%= l(:label_attachment) %> <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %> <%= l(:label_added) %> <% end %> ---------------------------------------- - -<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> +<%= link_to( "我要回复", @issue_url) %> + <%#= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> From 1602d2e439793613044db53eff0a7d480a5215a8 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 17 Jan 2015 11:46:45 +0800 Subject: [PATCH 2/4] Signed-off-by: alan <547533434@qq.com> --- app/views/mailer/_issue.text.erb | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/app/views/mailer/_issue.text.erb b/app/views/mailer/_issue.text.erb index 7ab8acfeb..6be5544b8 100644 --- a/app/views/mailer/_issue.text.erb +++ b/app/views/mailer/_issue.text.erb @@ -1,13 +1,18 @@ -<%= "#{issue.tracker.name} ##{issue.project_index}: #{issue.subject}" %> -<%= issue_url %> - -* <%=l(:field_author)%>: <%= issue.author %> -* <%=l(:field_status)%>: <%= issue.status %> -* <%=l(:field_priority)%>: <%= issue.priority %> -* <%=l(:field_assigned_to)%>: <%= issue.assigned_to %> -* <%=l(:field_category)%>: <%= issue.category %> -* <%=l(:field_fixed_version)%>: <%= issue.fixed_version %> -<% issue.custom_field_values.each do |c| %>* <%= c.custom_field.name %>: <%= show_value(c) %> -<% end -%> ----------------------------------------- -<%= issue.description %> + + <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url) %> + 在 + <%= link_to(h("#{@issue.project.name}"),@project_url) %>中有了一个与您相关的最新活动,请您关注! +标题:<%= link_to(issue.subject, issue_url) %> + 来源:<%= link_to(h("#{issue.project.name}"),@project_url) %>| 项目缺陷< + 内容: + <%= textilizable(issue, :description, :only_path => false) %> + 附件: + + <% unless @issue.attachments.nil? %> + <% @issue.attachments.each do |attach| %> + <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %> + <% end %> + <% end %> + + + <%= link_to( "我要回复", issue_url) %> From ade07203312286e6f207bb6b76ad2060fbb6a1f9 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 17 Jan 2015 14:19:54 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E9=87=8D=E7=BD=AE=20Signed-off-by:=20alan=20?= =?UTF-8?q?<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 4 +++- app/models/mailer.rb | 24 ++++++++++++++++-------- app/views/layouts/mailer.html.erb | 2 +- app/views/mailer/_issue.html.erb | 25 ++++++++++++++----------- app/views/mailer/_issue.text.erb | 7 ++++--- app/views/mailer/issue_add.text.erb | 11 +---------- app/views/mailer/issue_edit.html.erb | 6 ++++-- app/views/mailer/issue_edit.text.erb | 6 ++++-- 8 files changed, 47 insertions(+), 38 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ee8711e7e..58af43da3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,8 +15,10 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class UsersController < ApplicationController + layout :setting_layout #Added by young + before_filter :auth_login1, :only => [:show, :user_activities] menu_item :activity menu_item :user_information, :only => :info menu_item :user_course, :only => :user_courses @@ -30,7 +32,7 @@ class UsersController < ApplicationController #Ended by young # edit - before_filter :auth_login1, :only => [:show] + # before_filter :can_show_course, :only => [:user_courses,:user_homeworks] before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info, diff --git a/app/models/mailer.rb b/app/models/mailer.rb index bee0640da..72e60a0bf 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -105,18 +105,18 @@ class Mailer < ActionMailer::Base @author = issue.author @issue = issue + user = User.find_by_mail(recipients) - - token = Token.new(:user => User.find_by_mail(recipients), :action => 'autologin') + token = Token.new(:user =>user , :action => 'autologin') token.save @token = token @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :token => @token.value) # edit - @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value) + @issue_author_url = url_for(user_activities_url(@author,:token => @token.value)) @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) - @user_url = url_for(:controller => 'my', :action => 'account', :user => User.find_by_mail(recipients) , :token => @token.value) - # + + @user_url = url_for(my_account_url(user,:token => @token.value)) cc = issue.watcher_recipients - issue.recipients subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" @@ -149,10 +149,18 @@ class Mailer < ActionMailer::Base references issue @author = journal.user + user = User.find_by_mail(recipients) + + token = Token.new(:user =>user , :action => 'autologin') + token.save + @token = token + + + # edit + @issue_author_url = url_for(:controller => 'users', :action => 'show', :id => issue.author_id, :token => @token.value) + @project_url = url_for(:controller => 'projects', :action => 'show', :id => issue.project_id, :token => @token.value) + @user_url = url_for(my_account_url(user,:token => @token.value)) - token = Token.new(:user => User.find_by_mail(recipients), :action => 'autologin') - token.save - @token = token @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value) diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb index de7f4a837..aa43b9194 100644 --- a/app/views/layouts/mailer.html.erb +++ b/app/views/layouts/mailer.html.erb @@ -14,7 +14,7 @@ ol,ul,li{ list-style-type:none} .cl{ clear:both; overflow:hidden; } a{ text-decoration:none; } a:hover{ text-decoration:underline; } - +.mail_box,ul,li{ list-style-type:none} .mail{ width:600px; margin:20px; height:auto; color:#4b4b4b; font-size:14px; } .mail a{color:#1b55a7; font-weight: bold; } .mail_content{ margin-top:30px;} diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index 326a21aaa..c5e136dfc 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -6,23 +6,26 @@ <%= link_to(h("#{@issue.project.name}"),@project_url) %>中有了一个与您相关的最新活动,请您关注!

    -
  • 标题:<%= link_to(issue.subject, issue_url) %>
  • -
  • 来源:<%= link_to(h("#{issue.project.name}"),@project_url) %>项目缺陷
  • -
  • 内容: -

    <%= textilizable(issue, :description, :only_path => false) %>

    +
  • 标题:<%= link_to(issue.subject, issue_url) %>
  • +
  • 来源:<%= issue.project.name %>项目缺陷
  • +
  • 内容: + <%= issue.description %>
  • -
  • 附件: -

    - <% unless @issue.attachments.nil? %> +

  • + + <% unless @issue.attachments.nil? %> + 附件: + <% @issue.attachments.each do |attach| %> - <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %><%= l(:label_added) %>
    - <% end %> +

    <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %>

    + <% end %>
    <% end %> -

    +
- +
+
-<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> -<% @issue.attachments.each do |attach| %> - <%= link_to_attachment(attach, :download => true, :token => @token.value, :only_path => false) %> <%= l(:label_added) %> -<% end %> - ----------------------------------------- -<%= link_to( "我要回复", @issue_url) %> - <%#= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> +<%= render :partial => 'issue', :formats => [:text], :locals => { :issue => @issue, :issue_url => @issue_url } %> diff --git a/app/views/mailer/issue_edit.html.erb b/app/views/mailer/issue_edit.html.erb index 8af66d891..3cbd1b02a 100644 --- a/app/views/mailer/issue_edit.html.erb +++ b/app/views/mailer/issue_edit.html.erb @@ -2,10 +2,12 @@
    <% details_to_strings(@journal.details, false, :only_path => false, :token => @token.value).each do |string| %> -
  • <%= string %>
  • + <% if (!string.include? l(:label_attachment)) && (!string.include? "attachments") %> +
  • <%= string %>
  • + <% end %> <% end %>
-<%= textilizable(@journal, :notes, :only_path => false) %> +<%= l(:field_content)%>:<%= @journal.notes %>
<%= render :partial => 'issue', :formats => [:html], :locals => { :issue => @issue, :issue_url => @issue_url } %> diff --git a/app/views/mailer/issue_edit.text.erb b/app/views/mailer/issue_edit.text.erb index a5614595c..5b93b6fe0 100644 --- a/app/views/mailer/issue_edit.text.erb +++ b/app/views/mailer/issue_edit.text.erb @@ -1,11 +1,13 @@ <%= l(:text_issue_updated, :id => "##{@issue.project_index}", :author => @journal.user) %> <% details_to_strings(@journal.details, true, :token => @token.value).each do |string| -%> -<%= string %> + <% if (!string.include? l(:label_attachment)) && (!string.include? "attachments") %> +
  • <%= string %>
  • + <% end %> <% end -%> <% if @journal.notes? -%> -<%= @journal.notes %> + <%= l(:field_content)%>:<%= @journal.notes %> <% end -%> ---------------------------------------- From ebf63b9ba2e2f355fa85c7eea71da174fc8e124e Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 17 Jan 2015 14:31:56 +0800 Subject: [PATCH 4/4] Signed-off-by: alan <547533434@qq.com> --- app/views/mailer/_issue.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index c5e136dfc..5979877a3 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -7,7 +7,7 @@
    • 标题:<%= link_to(issue.subject, issue_url) %>
    • -
    • 来源:<%= issue.project.name %>项目缺陷
    • +
    • 来源:<%= issue.project.name %>项目<%= issue.tracker.name%>
    • 内容: <%= issue.description %>