From 24a8f4fe7d7c5c0b9e4798a5baf255bbbc217e12 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 23 Jan 2015 10:03:00 +0800 Subject: [PATCH 1/3] Signed-off-by: alan <547533434@qq.com> --- app/controllers/courses_controller.rb | 1 + app/models/course_group.rb | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index edd3f1b9d..dcd09959d 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -273,6 +273,7 @@ class CoursesController < ApplicationController if valid_attr.eql?('name') faker.name = valid_value + # faker.course_id = @course.id faker.valid? req[:valid] = faker.errors[:name].blank? req[:message] = faker.errors[:name] diff --git a/app/models/course_group.rb b/app/models/course_group.rb index 144c43c6e..c1236da93 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -12,11 +12,20 @@ class CourseGroup < ActiveRecord::Base before_destroy :set_member_nil attr_accessible :name - validates :name, :presence => true, :length => {:maximum => 20}, - :uniqueness => {case_sensitive: false} + validates :name, :presence => true, :length => {:maximum => 20} + validate_on_create :unique_name_and_course + + + def set_member_nil if self.members && self.members.count > 0 self.members.update_all("course_group_id = 0") end end + private + def unique_name_and_course + if CourseGroup.find(:conditions => ["name=? and course_id=?", name, course_id]).first + errors.add_to_base("该班名已被使用!") + end + end end From fdba8ca9868d25674bcd109d4b66b0784ba05539 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 23 Jan 2015 11:46:55 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=9C=B0=E5=9D=80=E7=9C=9F=E5=AE=9E=E6=80=A7=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E3=80=8B=E3=80=8A=E8=AF=BE=E7=A8=8B=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E9=87=8D=E5=90=8D=E5=87=BA=E9=94=99=E3=80=8B?= =?UTF-8?q?=E3=80=8A=E7=95=99=E8=A8=80=E6=A8=A1=E5=9D=97=E5=8F=91=E9=80=81?= =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=A8=A1=E6=9D=BF=E5=8A=9F=E8=83=BD=E3=80=8B?= =?UTF-8?q?=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- Gemfile | 2 +- app/controllers/courses_controller.rb | 2 +- app/models/course_group.rb | 6 +-- app/models/user.rb | 2 +- app/views/courses/member.html.erb | 3 +- app/views/mailer/_issue.html.erb | 2 +- app/views/mailer/_issue.text.erb | 2 +- .../mailer/journals_for_message_add.html.erb | 4 +- app/views/mailer/message_posted.html.erb | 49 +++++++++++++++---- config/configuration.yml | 8 +-- config/locales/zh.yml | 3 +- 12 files changed, 59 insertions(+), 26 deletions(-) diff --git a/.gitignore b/.gitignore index 0cd336786..944ad4ef2 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.bundle *.swp /config/database.yml +/config/configuration.yml /files/* /log/* /tmp/* @@ -14,5 +15,4 @@ /db/schema.rb /Gemfile.lock /lib/plugins/acts_as_versioned/test/debug.log -/config/configuration.yml .rbenv-gemsets diff --git a/Gemfile b/Gemfile index 5045cb822..dc834e68d 100644 --- a/Gemfile +++ b/Gemfile @@ -18,7 +18,7 @@ gem "builder", "3.0.0" gem 'acts-as-taggable-on', '2.4.1' gem 'spreadsheet' gem 'ruby-ole' -gem 'email_verifier' +#gem 'email_verifier' group :development do gem 'better_errors', path: 'lib/better_errors' diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index dcd09959d..b5e0362b3 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -273,7 +273,7 @@ class CoursesController < ApplicationController if valid_attr.eql?('name') faker.name = valid_value - # faker.course_id = @course.id + faker.course_id = params[:course_id] faker.valid? req[:valid] = faker.errors[:name].blank? req[:message] = faker.errors[:name] diff --git a/app/models/course_group.rb b/app/models/course_group.rb index c1236da93..c7fc81df4 100644 --- a/app/models/course_group.rb +++ b/app/models/course_group.rb @@ -13,7 +13,7 @@ class CourseGroup < ActiveRecord::Base attr_accessible :name validates :name, :presence => true, :length => {:maximum => 20} - validate_on_create :unique_name_and_course + validate :unique_name_and_course @@ -24,8 +24,8 @@ class CourseGroup < ActiveRecord::Base end private def unique_name_and_course - if CourseGroup.find(:conditions => ["name=? and course_id=?", name, course_id]).first - errors.add_to_base("该班名已被使用!") + if CourseGroup.where("name=? and course_id=?", name, course_id).first + errors.add(:name, :groupname_repeat) end end end diff --git a/app/models/user.rb b/app/models/user.rb index bef65fe54..06f59c764 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -188,7 +188,7 @@ class User < Principal validates_confirmation_of :password, :allow_nil => true validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true validate :validate_password_length - validates_email_realness_of :mail + #validates_email_realness_of :mail before_create :set_mail_notification before_save :update_hashed_password before_destroy :remove_references_before_destroy diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index 803be3731..e2c1fb418 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -6,7 +6,8 @@ $.get( '<%=valid_ajax_course_path%>', { valid: "name", - value: document.getElementById('group_name').value }, + value: document.getElementById('group_name').value, + course_id: <%= @course.id %> }, function (data) { if (!data.valid) { alert(data.message); diff --git a/app/views/mailer/_issue.html.erb b/app/views/mailer/_issue.html.erb index cd5fbc091..0ec585868 100644 --- a/app/views/mailer/_issue.html.erb +++ b/app/views/mailer/_issue.html.erb @@ -1,7 +1,7 @@

- <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> + <%= link_to(h("#{@author.login}(#{@author.show_name})"), @issue_author_url , :style=>'color:#1b55a7; font-weight:bold;') %> <%= l(:mail_issue_title_userin)%> <%= link_to(h("#{@issue.project.name}"), @project_url, :style=>'color:#1b55a7; font-weight:bold;') %><%= l(:mail_issue_title_active)%>

diff --git a/app/views/mailer/_issue.text.erb b/app/views/mailer/_issue.text.erb index 8848e494a..e0579824f 100644 --- a/app/views/mailer/_issue.text.erb +++ b/app/views/mailer/_issue.text.erb @@ -1,5 +1,5 @@ - <%= link_to(h("#{@issue.author}(#{@issue.author.show_name})"), @issue_author_url) %> + <%= link_to(h("#{@author.login}(#{@author.show_name})"), @issue_author_url) %> <%= l(:mail_issue_title_userin)%> <%= link_to(h("#{@issue.project.name}"),@project_url) %><%= l(:mail_issue_title_active)%> <%= l(:mail_issue_subject)%><%= link_to(issue.subject, issue_url) %> diff --git a/app/views/mailer/journals_for_message_add.html.erb b/app/views/mailer/journals_for_message_add.html.erb index 1aa8e45f8..f39b49026 100644 --- a/app/views/mailer/journals_for_message_add.html.erb +++ b/app/views/mailer/journals_for_message_add.html.erb @@ -1,5 +1,5 @@ 尊敬的用户,<%= @user %>给你留言了:
<%= @message %>
-

点击链接查看最新回复<%= link_to(@url, @url) %>

-         

<%= link_to(l(:lable_not_receive_mail),"http://" + Setting.host_name + "/my/account")%>

+

点击链接查看最新回复<%= link_to(@url, @url) %> +         <%= link_to(l(:lable_not_receive_mail),"http://" + Setting.host_name + "/my/account")%>

diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb index 4bb487405..e031c2e98 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -1,10 +1,41 @@ -

- <% if @message.project %> - <%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %> - <% elsif @message.course %> - <%=h @message.board.course.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url) %> - <% end %> -

-<%=h @message.author %> -<%= textilizable(@message, :content, :only_path => false) %> + + + + +

+ + <%= h @message.author %>(<%= @message.author.show_name %>) + <%= l(:mail_issue_title_userin)%> + + <% if @message.project %> + <%=h @message.board.project.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% elsif @message.course %> + <%=h @message.board.course.name %> - <%=h @message.board.name %>: <%= link_to(h(@message.subject), @message_url,:style=>'color:#1b55a7; font-weight:bold;') %> + <% end %> + <%= l(:mail_issue_title_active)%>

+
+ +
+ +
+
+ + diff --git a/config/configuration.yml b/config/configuration.yml index 9a9373e45..f17881485 100644 --- a/config/configuration.yml +++ b/config/configuration.yml @@ -87,12 +87,12 @@ default: - address: smtp.163.com + address: smtp.126.com port: 25 - domain: smtp.163.com + domain: smtp.126.com authentication: :plain - user_name: mcb592@163.com - password: 'mcb1989822' + user_name: "alanlong9278@126.com" + password: 'alanlong8788786' # Absolute path to the directory where attachments are stored. # The default is the 'files' directory in your Redmine instance. diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 77a5b4a1b..0f7d67cb8 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -152,7 +152,7 @@ zh: not_same_project: "不属于同一个项目" circular_dependency: "此关联将导致循环依赖" cant_link_an_issue_with_a_descendant: "问题不能关联到它的子任务" - + groupname_repeat: "该班名已存在" actionview_instancetag_blank_option: 请选择 @@ -598,6 +598,7 @@ zh: label_document_added: 文档已添加 label_forum_message_added: 发帖成功 label_forum_add: 贴吧创建成功 + label_message_reply: 回帖人 label_document_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该文档。) label_role: 角色 label_role_plural: 角色 From b20204fedd1846b1609b185fb96e1f3dd85abbb0 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 23 Jan 2015 13:42:25 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=8A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E9=87=8D=E5=8F=91=E4=B8=80=E6=A0=B7=E5=BC=95=E5=8F=91?= =?UTF-8?q?=E7=9A=84bug=E3=80=8B=20Signed-off-by:=20alan=20<547533434@qq.c?= =?UTF-8?q?om>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue_observer.rb | 3 ++- app/models/journal_observer.rb | 3 ++- app/models/mailer.rb | 16 +++++----------- app/views/mailer/message_posted.html.erb | 4 ---- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/app/models/issue_observer.rb b/app/models/issue_observer.rb index 50cbf2a42..e404a4a1c 100644 --- a/app/models/issue_observer.rb +++ b/app/models/issue_observer.rb @@ -19,7 +19,8 @@ class IssueObserver < ActiveRecord::Observer def after_create(issue) Thread.start do - recipients = issue.recipients + # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, + recipients = issue.recipients - issue.watcher_recipients + issue.watcher_recipients recipients.each do |rec| Mailer.issue_add(issue,rec).deliver if Setting.notified_events.include?('issue_added') end diff --git a/app/models/journal_observer.rb b/app/models/journal_observer.rb index 10d3f7b4b..b58464a9b 100644 --- a/app/models/journal_observer.rb +++ b/app/models/journal_observer.rb @@ -24,7 +24,8 @@ class JournalObserver < ActiveRecord::Observer (Setting.notified_events.include?('issue_priority_updated') && journal.new_value_for('priority_id').present?) ) Thread.start do - recipients = journal.recipients + # 将跟踪者与本项目的其他成员都设为收件方,并去重,不在进行抄送, + recipients = journal.recipients - journal.watcher_recipients + journal.watcher_recipients recipients.each do |rec| Mailer.issue_edit(journal,rec).deliver diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 23ac36054..1760d9004 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -147,13 +147,11 @@ class Mailer < ActionMailer::Base @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)) - cc = nil - if recipients == issue.recipients[0] - cc = issue.watcher_recipients - issue.recipients - end + + subject = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] (#{issue.status.name}) #{issue.subject}" mail(:to => recipients, - :cc => cc, + :subject => subject) end # issue.attachments.each do |attach| @@ -198,11 +196,7 @@ class Mailer < ActionMailer::Base - # Watchers in cc - cc = nil - if recipients == journal.recipients[0] - cc = journal.watcher_recipients - journal.recipients - end + s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] " s << "(#{issue.status.name}) " if journal.new_value_for('status_id') @@ -211,7 +205,7 @@ class Mailer < ActionMailer::Base @journal = journal # @issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue, :anchor => "change-#{journal.id}") mail(:to => recipients, - :cc => cc, + :subject => s) end diff --git a/app/views/mailer/message_posted.html.erb b/app/views/mailer/message_posted.html.erb index e031c2e98..1fe28e04f 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -1,8 +1,4 @@ - - - -

<%= h @message.author %>(<%= @message.author.show_name %>)