diff --git a/.gitignore b/.gitignore index 0ac235089..85612a26d 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ /.bundle *.swp /config/database.yml +/config/configuration.yml /files/* /log/* /public/tmp/* @@ -15,5 +16,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 new file mode 100644 index 000000000..dc834e68d --- /dev/null +++ b/Gemfile @@ -0,0 +1,138 @@ +source 'http://rubygems.org' +#source 'http://ruby.sdutlinux.org/' + +unless RUBY_PLATFORM =~ /w32/ + # unix-like only + gem 'iconv' + gem 'rubyzip' + gem 'zip-zip' +end + +gem 'seems_rateable', path: 'lib/seems_rateable' +gem "rails", "3.2.13" +gem "jquery-rails", "~> 2.0.2" +gem "i18n", "~> 0.6.0" +gem "coderay", "~> 1.0.6" +gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] +gem "builder", "3.0.0" +gem 'acts-as-taggable-on', '2.4.1' +gem 'spreadsheet' +gem 'ruby-ole' +#gem 'email_verifier' + +group :development do + gem 'better_errors', path: 'lib/better_errors' + gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' +end + +group :test do + gem "shoulda", "~> 3.5.0" + gem "mocha", "~> 1.1.0" + gem 'capybara', '~> 2.4.1' + gem 'nokogiri', '~> 1.6.3' + gem 'factory_girl', '~> 4.4.0' + gem 'selenium-webdriver', '~> 2.42.0' + + + # platforms :mri, :mingw do + # group :rmagick do + # # RMagick 2 supports ruby 1.9 + # # RMagick 1 would be fine for ruby 1.8 but Bundler does not support + # # different requirements for the same gem on different platforms + # gem "rmagick", ">= 2.0.0" + # end + #end +end + +group :development, :test do + # gem "guard-rails", '~> 0.5.3' + gem 'spork-testunit', '~> 0.0.8' + # gem 'guard-spork', '~> 1.5.1' + # gem 'guard-test', '~> 1.0.0' + gem 'ruby-prof', '~> 0.15.1' unless RUBY_PLATFORM =~ /w32/ + gem 'pry' + gem 'pry-nav' + gem 'rspec-rails' , '2.13.1' + gem 'guard-rspec','2.5.0' +end + + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + gem 'therubyracer', :platforms => :ruby + + gem 'uglifier', '>= 1.0.3' +end + +# Optional gem for LDAP authentication +group :ldap do + gem "net-ldap", "~> 0.3.1" +end + + +# Optional gem for OpenID authentication +group :openid do + gem "ruby-openid", "~> 2.1.4", :require => "openid" + gem "rack-openid" +end + +# Optional gem for exporting the gantt to a PNG file, not supported with jruby +platforms :jruby do + # jruby-openssl is bundled with JRuby 1.7.0 + gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' + gem "activerecord-jdbc-adapter", "1.2.5" +end + +# Include database gems for the adapters found in the database +# configuration file +require 'erb' +require 'yaml' +database_file = File.join(File.dirname(__FILE__), "config/database.yml") +if File.exist?(database_file) + database_config = YAML::load(ERB.new(IO.read(database_file)).result) + adapters = database_config.values.map {|c| c['adapter']}.compact.uniq + if adapters.any? + adapters.each do |adapter| + case adapter + when 'mysql2' + gem "mysql2", "= 0.3.11", :platforms => [:mri, :mingw] + gem "activerecord-jdbcmysql-adapter", :platforms => :jruby + when 'mysql' + gem "mysql", "~> 2.8.1", :platforms => [:mri, :mingw] + gem "activerecord-jdbcmysql-adapter", :platforms => :jruby + when /postgresql/ + gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] + gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby + when /sqlite3/ + gem "sqlite3", :platforms => [:mri, :mingw] + gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby + when /sqlserver/ + gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw] + gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw] + else + warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") + end + end + else + warn("No adapter found in config/database.yml, please configure it first") + end +else + warn("Please configure your config/database.yml first") +end + +local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") +if File.exists?(local_gemfile) + puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v` + instance_eval File.read(local_gemfile) +end + +# Load plugins' Gemfiles +Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| + puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` + instance_eval File.read(file) +end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index edd3f1b9d..b5e0362b3 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 = 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 144c43c6e..c7fc81df4 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 :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.where("name=? and course_id=?", name, course_id).first + errors.add(:name, :groupname_repeat) + end + end end 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/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..1fe28e04f 100644 --- a/app/views/mailer/message_posted.html.erb +++ b/app/views/mailer/message_posted.html.erb @@ -1,10 +1,37 @@ -+ + <%= 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) %> - <% end %> - -<%=h @message.author %> + <%=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)%>
+