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)%>
点击链接查看最新回复<%= 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 @@ -+ + <%= 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)%>
+<%= h @message.author %>(<%= @message.author.show_name %>)