diff --git a/Gemfile b/Gemfile index bfc0b773..a04059bf 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ unless RUBY_PLATFORM =~ /w32/ gem 'rubyzip' gem 'zip-zip' end + gem 'seems_rateable', path: 'lib/seems_rateable' gem "rails", "3.2.13" gem "jquery-rails", "~> 2.0.2" @@ -15,6 +16,11 @@ gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] gem "builder", "3.0.0" gem 'acts-as-taggable-on' +group :development do + gem 'better_errors', path: 'lib/better_errors' + gem 'rack-mini-profiler', path: 'lib/rack-mini-profiler' +end + # Optional gem for LDAP authentication group :ldap do gem "net-ldap", "~> 0.3.1" @@ -70,16 +76,6 @@ else warn("Please configure your config/database.yml first") end -group :development do - gem "rdoc", ">= 2.4.2" - if nil - gem 'thin' - gem 'rack-mini-profiler' - end -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` diff --git a/Gemfile.lock b/Gemfile.lock index 54d89f38..25cc9f48 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,16 @@ +PATH + remote: lib/better_errors + specs: + better_errors (1.1.0) + coderay (>= 1.0.0) + erubis (>= 2.6.6) + +PATH + remote: lib/rack-mini-profiler + specs: + rack-mini-profiler (0.9.1) + rack (>= 1.1.3) + PATH remote: lib/seems_rateable specs: @@ -105,6 +118,7 @@ DEPENDENCIES activerecord-jdbc-adapter (= 1.2.5) activerecord-jdbcmysql-adapter acts-as-taggable-on + better_errors! builder (= 3.0.0) coderay (~> 1.0.6) fastercsv (~> 1.5.0) @@ -112,8 +126,8 @@ DEPENDENCIES jquery-rails (~> 2.0.2) mysql2 (~> 0.3.11) net-ldap (~> 0.3.1) + rack-mini-profiler! rack-openid rails (= 3.2.13) - rdoc (>= 2.4.2) ruby-openid (~> 2.1.4) seems_rateable! diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index ab3d7b12..2a3ce15d 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -149,7 +149,6 @@ class AdminController < ApplicationController respond_to do |format| format.html { @groups = Group.all.sort - render :layout => @user_base_tag } format.api end @@ -196,4 +195,43 @@ class AdminController < ApplicationController [:text_rmagick_available, Object.const_defined?(:Magick)] ] end + #管理功能用户列表的搜索 + def search + sort_init 'login', 'asc' + sort_update %w(login firstname lastname mail admin created_on last_login_on) + + case params[:format] + when 'xml', 'json' + @offset, @limit = api_offset_and_limit({:limit => 15}) + else + @limit = 15#per_page_option + end + + @status = params[:status] || 1 + has = { + "show_changesets" => true + } + scope = User.logged.status(@status) + scope = scope.like(params[:name]) if params[:name].present? + @user_count = scope.count + @user_pages = Paginator.new @user_count, @limit, params['page'] + @user_base_tag = params[:id] ? 'base_users':'base' + @offset ||= @user_pages.reverse_offset + unless @offset == 0 + @users = scope.offset(@offset).limit(@limit).all.reverse + else + limit = @user_count % @limit + if limit == 0 + limit = @limit + end + @users = scope.offset(@offset).limit(limit).all.reverse + end + + respond_to do |format| + format.html { + @groups = Group.all.sort + } + format.api + end + end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index f9236d0b..5b81b729 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -52,9 +52,14 @@ class FilesController < ApplicationController end def create - if params[:tag_name] + if params[:add_tag] + @addTag=true + #render :back tag_saveEx - render :text =>"success" + #render :text =>"success" + respond_to do |format| + format.js + end else @addTag=false container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id])) @@ -64,7 +69,27 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.attachments_added(attachments[:files]).deliver end - redirect_to project_files_path(@project) + + # 临时用 + sort_init 'created_on', 'desc' + sort_update 'created_on' => "#{Attachment.table_name}.created_on", + 'filename' => "#{Attachment.table_name}.filename", + 'size' => "#{Attachment.table_name}.filesize", + 'downloads' => "#{Attachment.table_name}.downloads" + + @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun + @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + @attachtype = 0 + @contenttype = 0 + + respond_to do |format| + format.js + format.html { + redirect_to project_files_path(@project) + } + end + end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index d8e583bf..30c6c7e8 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -76,8 +76,7 @@ class MembersController < ApplicationController # ProjectInfo.create(:name => "test", :user_id => 123) end ## end - AppliedProject.deleteappiled(user_id, @project.id) - end + end else members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id]) user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id) @@ -95,6 +94,13 @@ class MembersController < ApplicationController end end + if members.present? && members.all? {|m| m.valid? } + members.each do |member| + AppliedProject.deleteappiled(member.user_id, @project.id) + end + + end + respond_to do |format| format.html { redirect_to_settings_in_projects } format.js { @members = members;@applied_members = applied_members; } diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a6dd7cf3..1cf14a83 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -716,6 +716,11 @@ class ProjectsController < ApplicationController @document = @project.documents.build # @base_courses_tag = @project.project_type + #判断能否显示真名(当前用户为课程的教师时显示真名) + if @project.project_type == Project::ProjectType_course + @teachers= searchTeacherAndAssistant(@project) + @canShowRealName = isCourseTeacher(User.current.id) + end respond_to do |format| format.html{render :layout => 'base_courses' if @base_courses_tag==1} format.api diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index da9aef30..6452bcc8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -65,13 +65,13 @@ class UsersController < ApplicationController def user_projects if User.current.admin? - @memberships = @user.memberships.all + @memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}") else cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" @memberships = @user.memberships.all(:conditions => cond) end - events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) - @events_by_day = events.group_by(&:event_date) + #events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) + #@events_by_day = events.group_by(&:event_date) @state = 0 @@ -289,7 +289,7 @@ class UsersController < ApplicationController when '0' @offset ||= @user_pages.reverse_offset unless @offset == 0 - @users_statuses = scope.offset(@offset).limit(@limit).all.reverse + @users_statuses = scope.offset(@offset).limit(@limit).all.reverse else limit = @user_count % @limit if limit == 0 @@ -313,7 +313,7 @@ class UsersController < ApplicationController end @s_type = 1 #sort {|x,y| y.user_status.changesets_count <=> x.user_status.changesets_count} - #@users = @users[@offset, @limit] + #@users = @users[@offset, @limit] when '2' @offset ||= @user_pages.reverse_offset unless @offset == 0 @@ -326,9 +326,9 @@ class UsersController < ApplicationController @users_statuses = scope.reorder('watchers_count').offset(@offset).limit(limit).all.reverse end @s_type = 2 - #@users = @users[@offset, @limit] + #@users = @users[@offset, @limit] end - + else @offset ||= @user_pages.reverse_offset unless @offset == 0 @@ -565,7 +565,7 @@ class UsersController < ApplicationController end def watch_projects - @watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and user_id = ?", '1','Project', @user.id) + @watch_projects = Project.joins(:watchers).where("project_type <>? and watchable_type = ? and `watchers`.user_id = ?", '1','Project', @user.id) @state = 1 respond_to do |format| format.html { @@ -689,7 +689,7 @@ class UsersController < ApplicationController end def tag_saveEx - @tags = params[:tag_name][:name] + @tags = params[:tag_name] @obj_id = params[:obj_id] @obj_flag = params[:obj_flag] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ae6ec698..7dc4b555 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,9 +58,14 @@ module ApplicationHelper end # Displays a link to user's account page if active - def link_to_user(user, options={}) + def link_to_user(user, canShowRealName = false, options={}) if user.is_a?(User) - name = h(user.name(options[:format])) + if canShowRealName + name = h(user.realname(options[:format])) + else + name = h(user.name(options[:format])) + end + if user.active? || (User.current.admin? && user.logged?) link_to name, {:controller=> 'users', :action => 'show', id: user.id, host: Setting.user_domain}, :class => user.css_classes else @@ -1342,7 +1347,18 @@ module ApplicationHelper def bootstrap_head tags = stylesheet_link_tag('bootstrap/bootstrap.min', 'bootstrap/bootstrap-theme.min') - tags << javascript_include_tag('bootstrap/bootstrap.min', 'bootstrap/jquery.transition.min') + tags << javascript_include_tag('bootstrap/affix') + tags << javascript_include_tag('bootstrap/alert') + tags << javascript_include_tag('bootstrap/button') + tags << javascript_include_tag('bootstrap/carousel') + tags << javascript_include_tag('bootstrap/collapse') + tags << javascript_include_tag('bootstrap/dropdown') + tags << javascript_include_tag('bootstrap/modal') + tags << javascript_include_tag('bootstrap/popover') + tags << javascript_include_tag('bootstrap/scrollspy') + tags << javascript_include_tag('bootstrap/tab') + tags << javascript_include_tag('bootstrap/tooltip') + tags << javascript_include_tag('bootstrap/transition') tags end diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index ba2470fe..201a582f 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -49,5 +49,9 @@ module TagsHelper end return @result end - + +end + +def tagname_val + ("#tag_name_name").value end \ No newline at end of file diff --git a/app/models/mailer.rb b/app/models/mailer.rb index e5ede628..a303d92b 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -22,7 +22,7 @@ class Mailer < ActionMailer::Base helper :custom_fields include Redmine::I18n - + include CoursesHelper def self.default_url_options { :host => Setting.host_name, :protocol => Setting.protocol } end @@ -44,6 +44,16 @@ class Mailer < ActionMailer::Base when :Bid respond_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Project + if journals_for_message.jour.project_type == 1 + project = journals_for_message.jour + @teachers = searchTeacherAndAssistant journals_for_message.jour + @recipients ||= [] + @teachers.each do |teacher| + @recipients << teacher + end + mail :to => @recipients, + :subject => "您的课程#{journals_for_message.jour.name}中有了新的留言" + end project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") when :Contest show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb new file mode 100644 index 00000000..17d91e78 --- /dev/null +++ b/app/views/admin/search.html.erb @@ -0,0 +1,68 @@ +<% if User.current.admin? %> +
+ | |||||||
---|---|---|---|---|---|---|---|
<%= avatar(user, :size => "14") %><%= link_to h(user.login), edit_user_path(user) %> | +<%= h(user.firstname) %> | +<%= h(user.lastname) %> | +<%= mail_to(h(user.mail)) %> | +<%= checked_image user.admin? %> | +<%= format_time(user.created_on) %> | +<%= format_time(user.last_login_on) unless user.last_login_on.nil? %> | +<%= change_status_link(user) %> + <%= delete_link user_path(user, :back_url => users_path(params)) unless User.current == user %> | +