diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 0c61c449e..1b0ead141 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -25,6 +25,7 @@ class CoursesController < ApplicationController before_filter :authorize_course, :only => [:show, :settings, :update, :course] before_filter :authorize_course_global, :only => [:new,:create] before_filter :toggleCourse, :only => [:finishcourse, :restartcourse] + before_filter :is_deleted, :only => [:show, :settings] before_filter :require_login, :only => [:join, :unjoin] #before_filter :allow_join, :only => [:join] @@ -55,11 +56,11 @@ class CoursesController < ApplicationController def join if User.current.logged? - cs = CoursesService.new - @user = User.current - join = cs.join_course params,@user - @state = join[:state] - @course = join[:course] + cs = CoursesService.new + @user = User.current + join = cs.join_course params,@user + @state = join[:state] + @course = join[:course] # else # @course = Course.find_by_id params[:object_id] # CourseMessage.create(:user_id => @course.tea_id, :course_id => @course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest') @@ -70,7 +71,7 @@ class CoursesController < ApplicationController end @object_id = params[:object_id] respond_to do |format| - format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } + format.js #{ render :partial => 'set_join', :locals => {:user => @user, :course => @course, :object_id => params[:object_id]} } end end @@ -85,7 +86,7 @@ class CoursesController < ApplicationController end end - + def join_private_courses respond_to do |format| format.js @@ -98,14 +99,14 @@ class CoursesController < ApplicationController c = cs.edit_course params,@course,User.current @course = c[:course] if @course.errors.full_messages.count <= 0 - respond_to do |format| - format.html { - # render :layout => 'base_courses' - flash[:notice] = l(:notice_successful_update) - redirect_to settings_course_url(@course) - } - format.api { render_api_ok } - end + respond_to do |format| + format.html { + # render :layout => 'base_courses' + flash[:notice] = l(:notice_successful_update) + redirect_to settings_course_url(@course) + } + format.api { render_api_ok } + end else respond_to do |format| format.html { @@ -134,8 +135,8 @@ class CoursesController < ApplicationController courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'").order("time desc, created_at desc") @courses = paginateHelper courses,10 end - @name = params[:name] - @type = 'courses' + @name = params[:name] + @type = 'courses' respond_to do |format| format.html { render :layout => 'course_base' @@ -277,7 +278,7 @@ class CoursesController < ApplicationController def member ## 有角色参数的才是课程,没有的就是项目 if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) - + @render_file = 'new_member_list' @score_sort_by = "desc" @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @@ -312,7 +313,7 @@ class CoursesController < ApplicationController def export_course_member_excel @all_members = student_homework_score(0,0,0,"desc") filename="#{@course.teacher.lastname.to_s + @course.teacher.firstname.to_s }_#{@course.name}_#{@course.time.to_s + @course.term}#{l(:excel_member_list)}"; - + respond_to do |format| format.xls { send_data(member_to_xls(@all_members,@course.course_groups), :type => "text/excel;charset=utf-8; header=present", @@ -427,7 +428,7 @@ class CoursesController < ApplicationController end def course - @school_id = params[:school_id] + @school_id = params[:school_id] per_page_option = 10 if @school_id == "0" or @school_id.nil? @courses_all = Course.active.visible. @@ -515,8 +516,8 @@ class CoursesController < ApplicationController def index if !User.current.admin? - render_404 - return + render_404 + return end @course_type = params[:course_type] @school_id = params[:school_id] @@ -565,7 +566,7 @@ class CoursesController < ApplicationController respond_to do |format| format.html { - render :layout => 'base' + render :layout => 'base' } format.atom { courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all @@ -581,6 +582,13 @@ class CoursesController < ApplicationController end end + def is_deleted + if @course.is_delete == 1 and !User.current.admin? + render_404 + return + end + end + def get_courses @user = User.current membership = @user.coursememberships.all @@ -634,6 +642,11 @@ class CoursesController < ApplicationController end def show + # 被删除的课程只有超级管理员才能看到,is_delete为1的时候,标记课程被删除 + # if @course.is_delete == 1 && !User.current.admin? + # render_403 + # return + # end #更新创建课程消息状态 create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) @@ -684,10 +697,10 @@ class CoursesController < ApplicationController end def feedback - @course.journals_for_messages.each do |messages| - query = messages.course_messages.where("user_id = ?", User.current.id) - query.update_all(:viewed => true); - end + @course.journals_for_messages.each do |messages| + query = messages.course_messages.where("user_id = ?", User.current.id) + query.update_all(:viewed => true); + end if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) page = params[:page] @@ -738,20 +751,20 @@ class CoursesController < ApplicationController #从课程创建的老师那里选择课程大纲 def course_outline - @teacher = User.find(@course.tea_id) - @blog_articles = @teacher.blog.articles - @is_in_show_outline_page = params[:is_in_show_outline_page] - respond_to do |format| - format.js - end + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles + @is_in_show_outline_page = params[:is_in_show_outline_page] + respond_to do |format| + format.js + end end #根据关键字搜索,查找方法一样的,但返回内容不一样 def search_course_outline - @article_title = params[:title] - @teacher = User.find(@course.tea_id) - @blog_articles = @teacher.blog.articles.like(@article_title) - render :json=>@blog_articles.to_json + @article_title = params[:title] + @teacher = User.find(@course.tea_id) + @blog_articles = @teacher.blog.articles.like(@article_title) + render :json=>@blog_articles.to_json end #设置或者更改课程的大纲 @@ -771,10 +784,23 @@ class CoursesController < ApplicationController format.html {render :layout => 'base_courses'} end end - #删除课程 - #删除课程只是将课程的is_delete状态改为false,is_delete为false状态的课程只有管理员可以看到 - def destroy + #删除课程 + #删除课程只是将课程的is_deleted状态改为false,is_deleted为false状态的课程只有管理员可以看到 + def destroy + @course.update_attributes(:is_delete => true) + @course = nil + redirect_to user_url(User.current) + end + + # 恢复已删除的课程 + def renew + if User.current.admin? + @course.update_attributes(:is_delete => false) + redirect_to course_path(@course) + else + return 404 + end end private @@ -797,7 +823,7 @@ class CoursesController < ApplicationController def can_show_course @first_page = FirstPage.find_by_page_type('project') if @first_page.try(:show_course) == 2 - render_404 + render_404 end end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index b15be4896..c894680a6 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -186,7 +186,7 @@ class FilesController < ApplicationController @order = "" @is_remote = false if params[:project_id] - @isproject = true + @container_type = 0 if params[:sort] params[:sort].split(",").each do |sort_type| @@ -246,7 +246,7 @@ class FilesController < ApplicationController format.js end elsif params[:course_id] - @isproject = false + @container_type = 1 if params[:sort] params[:sort].split(",").each do |sort_type| @@ -297,6 +297,9 @@ class FilesController < ApplicationController @tag_list = attachment_tag_list @all_attachments render :layout => 'base_courses' + elsif params[:org_subfield_id] + @container_type = 2 + # @subfield = params[:org_subfield_id] end end diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index f462a64e7..794347591 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -109,12 +109,23 @@ class MyController < ApplicationController # Edit user's account def account @user = User.current + lg=@user.login @pref = @user.pref diskfile = disk_filename('User', @user.id) diskfile1 = diskfile + 'temp' begin if request.post? + # 修改邮箱的时候同步修改到gitlab + if @user.mail != params[:user][:mail] + g = Gitlab.client + begin + g.edit_user(@user.gid, :email => params[:user][:mail]) + rescue + logger.error "sync user's email of gitlab failed!" + end + end + @user.safe_attributes = params[:user] @user.pref.attributes = params[:pref] @user.pref[:no_self_notified] = (params[:no_self_notified] == '1') diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 29b728268..b8584fea3 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -11,10 +11,17 @@ class OrgDocumentCommentsController < ApplicationController @org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id) @org_document_comment.title = params[:org_document_comment][:title] @org_document_comment.content = params[:org_document_comment][:content] + if params[:field_id] + @org_document_comment.org_subfield_id = params[:field_id].to_i + end if @org_document_comment.save flash.keep[:notice] = l(:notice_successful_create) EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) - redirect_to organization_org_document_comments_path(@organization) + if params[:field_id] + redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) + else + redirect_to organization_org_document_comments_path(@organization) + end else redirect_to new_org_document_comment_path(:organization_id => @organization.id) end @@ -46,7 +53,7 @@ class OrgDocumentCommentsController < ApplicationController if params[:flag].to_i == 1 redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) else - redirect_to organization_path(@org_document.organization.id) + redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id]) end end } diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 6fdf0ae40..00b88fdaa 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -3,7 +3,7 @@ class OrgSubfieldsController < ApplicationController @subfield = OrgSubfield.create(:name => params[:name]) @organization = Organization.find(params[:organization_id]) @organization.org_subfields << @subfield - @subfield.update_attributes(:priority => @subfield.id) + @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) end def destroy diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index d182640ed..38402f68e 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -68,29 +68,35 @@ class OrganizationsController < ApplicationController def show if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) - project_ids = @organization.projects.map(&:id) << 0 - course_ids = @organization.courses.map(&:id) << 0 - course_types = "('Message','News','HomeworkCommon','Poll','Course')" - case params[:type] - when nil - @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + - "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ - "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", - @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_issue' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'project_message' - @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'org' - @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_homework' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_news' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_message' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) - when 'course_poll' - @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + if params[:org_subfield_id] + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @org_activities = OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})").order('updated_at desc').page(params[:page] || 1).per(10) + else + project_ids = @organization.projects.map(&:id) << 0 + course_ids = @organization.courses.map(&:id) << 0 + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + case params[:type] + when nil + @org_activities = OrgActivity.where("(container_id =? and container_type =?) " + + "or (container_type ='Project' and org_act_type in ('Issue','Message','ProjectCreateInfo') and container_id in (#{project_ids.join(',')})) "+ + "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", + @organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_issue' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Issue' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'project_message' + @org_activities = OrgActivity.where("container_type = 'Project' and org_act_type = 'Message' and container_id in (#{project_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'org' + @org_activities = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_homework' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'HomeworkCommon' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_news' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'News' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_message' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Message' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + when 'course_poll' + @org_activities = OrgActivity.where("container_type = 'Course' and org_act_type = 'Poll' and container_id in (#{course_ids.join(',')})").order('updated_at desc').page(params[:page] || 1).per(10) + end end @page = params[:page] respond_to do |format| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 200bd4d69..88aae0f8b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -697,7 +697,11 @@ class ProjectsController < ApplicationController flash[:error] = l(:error_can_not_archive_project) end end - redirect_to admin_projects_url(:status => params[:status]) + if params[:type] == "project" + redirect_to user_path(User.current) + else + redirect_to admin_projects_url(:status => params[:status]) + end end def unarchive diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index a804f6ac7..f0b15e8f8 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -75,6 +75,9 @@ class RepositoriesController < ApplicationController redirect_to repository_url(@repository) else g = Gitlab.client + if User.current.gid.nil? + g.sync_user(User.current) + end gproject = g.fork(@project.gpid, User.current.gid) if gproject copy_project(@project, gproject) @@ -349,7 +352,7 @@ update - @changesets = g.commits(@project.gpid) + @changesets = g.commits(@project.gpid, :ref_name => @rev) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count @changesets_all_count = 0 diff --git a/app/models/course.rb b/app/models/course.rb index d7ca1387c..0194a2a9d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -20,7 +20,7 @@ class Course < ActiveRecord::Base end end - attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student, :enterprise_name, :is_delete #belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表 belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表 @@ -86,7 +86,8 @@ class Course < ActiveRecord::Base 'is_public', 'description', 'class_period', - 'open_student' + 'open_student', + 'is_delete' acts_as_customizable @@ -94,7 +95,7 @@ class Course < ActiveRecord::Base scope :active, lambda { where(:status => STATUS_ACTIVE) } scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } scope :all_public, lambda { where(:is_public => true) } - scope :visible, lambda {|*args| where(Course.visible_condition(args.shift || User.current, *args)) } + scope :visible, lambda {|*args| where(Course.where("is_delete =?", 0).visible_condition(args.shift || User.current, *args)) } scope :allowed_to, lambda {|*args| user = User.current permission = nil @@ -114,7 +115,7 @@ class Course < ActiveRecord::Base where(" LOWER(name) LIKE :p ", :p => pattern) end } - scope :indexable,lambda { where('is_public = 1') } + scope :indexable,lambda { where('is_public = 1 and is_delete = 0') } def self.search(query) __elasticsearch__.search( { @@ -399,12 +400,12 @@ class Course < ActiveRecord::Base # __elasticsearch__.delete_document # end def create_course_ealasticsearch_index - if self.is_public == 1 + if self.is_public == 1 and self.is_delete == 0 #公开 和 没有被删除的课程才被索引 self.__elasticsearch__.index_document end end def update_course_ealasticsearch_index - if self.is_public == 1 #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 + if self.is_public == 1 and self.is_delete == 0 #如果是初次更新成为公开或者恢复被删除的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 begin self.__elasticsearch__.update_document rescue => e diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index 1660310f8..efe9699c3 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -1,3 +1,4 @@ class OrgSubfield < ActiveRecord::Base belongs_to :organization, :foreign_key => :organization_id + has_many :org_document_comments, :dependent => :destroy end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 8e2c096de..6e6d58f86 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -227,7 +227,7 @@ class User < Principal validates_uniqueness_of :login, :if => Proc.new { |user| user.login_changed? && user.login.present? }, :case_sensitive => false validates_uniqueness_of :mail, :if => Proc.new { |user| user.mail_changed? && user.mail.present? }, :case_sensitive => false # Login must contain letters, numbers, underscores only - validates_format_of :login, :with => /\A[a-z0-9_\-@\.]*\z/i + validates_format_of :login, :with => /\A[a-z0-9_\-\.]*\z/i validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT validates_length_of :firstname, :maximum => 30 validates_length_of :lastname, :maximum => 30 diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 236dbc731..8b39c39ab 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -235,6 +235,15 @@ class UsersService if @current_user.check_password?(params[:password]) @current_user.password, @current_user.password_confirmation = params[:new_password], params[:new_password_confirmation] @current_user.save + # 修改密码同步gitlab密码修改 + unless @current_user.gid.nil? + begin + g = Gitlab.client + g.edit_user(@current_user.gid, :password => params[:new_password]) + rescue Exception => e + logger.error "change users password failed! ===> #{e}" + end + end #raise @current_user.errors.full_message #return @current_user else diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index 12dd67c91..0eaab219d 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -27,14 +27,14 @@ <% else %>
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_course_message'},:method => "post") do |f|%> + <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_course_message'}, :html=>{:id => "course_feedback_new"},:method => "post") do |f|%> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>

取消 - 留言 - <% end%> + 留言 + <% end %>
<% end %> @@ -50,7 +50,11 @@
diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb index 40049f104..1bfe3cbd7 100644 --- a/app/views/courses/_member.html.erb +++ b/app/views/courses/_member.html.erb @@ -1,6 +1,7 @@ <% @members.each do |member| %>
  • - <%= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %> + <%#= link_to_user_header member.principal,true,:class => "w150 c_orange fl" %> + <%= link_to "#{member.principal}(#{member.principal.show_name})", user_path(member.principal), :class => "w150 linkBlue fl" %> <%= zh_course_role(h member.roles.sort.collect(&:to_s).join(', ')) %> <%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member), diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb index 3aa7d4b57..2fe18c4eb 100644 --- a/app/views/courses/member.html.erb +++ b/app/views/courses/member.html.erb @@ -12,3 +12,4 @@ <%= render :partial => 'course_teacher', :locals => {:members => @members} %> <% end%> + diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb index 3456634d5..650127aef 100644 --- a/app/views/courses/settings.html.erb +++ b/app/views/courses/settings.html.erb @@ -88,6 +88,15 @@
  • <% end %> + <% if @course.is_delete == 1 %> +
    <%=link_to "恢复该课程", renew_course_path(@course) %>
    + <% else %> +
    + <%=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %> + (友情提示:删除该课程后如果您想恢复该课程,请联系系统管理员!) +
    + <% end %> +
    diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 9e9bd688f..4719b7427 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -103,17 +103,17 @@ - <% courses = @user.courses.visible.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%> + <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5)%>
    -<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag),:method => 'put', :id => 'new_org_document_form' do |f| %> +<%= form_tag url_for(:controller => 'org_document_comments',:action => 'update', :id => @org_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id]),:method => 'put', :id => 'new_org_document_form' do |f| %>
    diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 11a7e9359..af938b498 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -1,24 +1,37 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg'%> -<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id), :id => 'new_org_document_form' do |f| %> +<%= form_tag organization_org_document_comments_path(:organization_id => @organization.id, :field_id => params[:field_id]), :id => 'new_org_document_form' do |f| %>
    - +
    - <% organization.org_subfields.each do |field| %>
    - <%= field.name %> - <%=link_to "", :title => "关联#{field.name}"%> + <% if field.field_type == "Post" %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> + <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> + <% else %> + <%#= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> + <% end %>
    diff --git a/app/views/organizations/_org_member_list.html.erb b/app/views/organizations/_org_member_list.html.erb index f67b25811..f5a277634 100644 --- a/app/views/organizations/_org_member_list.html.erb +++ b/app/views/organizations/_org_member_list.html.erb @@ -11,14 +11,10 @@
      <%= radio_button_tag 'org_member[role_ids][]', role.id, member.roles.include?(role) %> - <% if User.current.language == "zh" %> - <% if role.id == 11 %> - - <% elsif role.id == 12 %> - - <% end %> - <% else %> - + <% if role.id == 11 %> + + <% elsif role.id == 12 %> + <% end %>
    diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 7588c7f6f..2b0f11cdd 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -8,7 +8,7 @@ <%= link_to User.find(document.creator_id), user_path(document.creator.id), :class => "newsBlue mr15" %> TO  <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %> | - 组织文章 + <%= document.org_subfield_id.nil? ? "组织文章" :"#{OrgSubfield.find(document.org_subfield_id).name}" %>
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
    @@ -27,12 +27,12 @@
    • - <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %> + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'set_homepage', :id => document.organization_id, :home_id => document.id, :show_homepage => 1}, :method => "put", :remote => true) do |f| %> 设为首页 <% end %>
    • - <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag), :class => "postOptionLink" %> + <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag, :org_subfield_id => params[:org_subfield_id] ), :class => "postOptionLink" %>
    • <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index 6ba60245a..642a5ffd0 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -1,22 +1,26 @@
      • 已有栏目
      • -
      • 状态
      • +
      • 状态
      • +
      • 类型
      • 动态
      • 默认
      • +
      • 默认
      • 项目
      • 默认
      • +
      • 默认
      • 课程
      • 默认
      • +
      • 默认
      <% subfields.each do |field| %> @@ -24,6 +28,7 @@
    • <%= field.name %>
    • 新增
    • +
    • <%= field.field_type == "Post" ? "帖子":"资源" %>
    • <%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> 编辑
      diff --git a/app/views/organizations/set_homepage.js.erb b/app/views/organizations/set_homepage.js.erb index b25c4c4d4..5b56d57b3 100644 --- a/app/views/organizations/set_homepage.js.erb +++ b/app/views/organizations/set_homepage.js.erb @@ -1,2 +1,2 @@ //location.reload(); -window.location.href ='<%= organization_path(@org)%>' \ No newline at end of file +window.location.href ='<%= organization_path(@org, :show_homepage => params[:show_homepage])%>'; \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index e0f262b99..4fc20653a 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -114,7 +114,18 @@

      新增栏目

      <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> -
      +
        +
      • 栏目类型
      • +
      • + + +
      • +
      • + + +
      • +
      +
      确定 <% end %>
  • diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 9ee9d11c0..3fb45376f 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -14,45 +14,47 @@ <% if params[:show_homepage].nil? %>
    -
    最新动态
    -
      -
    • -
        -
      • -
          -
        • 课程动态
        • -
        • <%= link_to "作业动态", {:controller => "organizations", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> -
        • -
        • <%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> - -
        • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> -
        • <%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> - - -
        -
      • -
      • -
          -
        • 项目动态
        • -
        • <%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> -
        • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> - -
        -
      • -
      • -
          -
        • 更多
        • -
        • <%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%> -
        • <%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%> +
          <%= @org_subfield.nil? ? "最新动态":"#{@org_subfield.name}" %>
          + <% if params[:org_subfield_id].nil? %> +
            +
          • +
              +
            • +
                +
              • 课程动态
              • +
              • <%= link_to "作业动态", {:controller => "organizations", :action => "show", :type => "course_homework"}, :class => "homepagePostTypeAssignment postTypeGrey"%> +
              • +
              • <%= link_to "通知动态", {:controller => "organizations", :action => "show", :type => "course_news"}, :class => "homepagePostTypeNotice postTypeGrey"%> + +
              • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "course_message"}, :class => "homepagePostTypeForum postTypeGrey"%> +
              • <%= link_to "问卷动态", {:controller => "organizations", :action => "show", :type => "course_poll"}, :class => "homepagePostTypeQuiz postTypeGrey"%> + + +
              +
            • +
            • +
                +
              • 项目动态
              • +
              • <%= link_to "问题动态", {:controller => "organizations", :action => "show", :type => "project_issue"}, :class => "homepagePostTypeQuestion postTypeGrey"%> +
              • <%= link_to "论坛动态", {:controller => "organizations", :action => "show", :type => "project_message"}, :class => "homepagePostTypeForum postTypeGrey"%> + +
              +
            • +
            • +
                +
              • 更多
              • +
              • <%= link_to "组织动态", {:controller => "organizations", :action => "show", :type => "org"}, :class =>"homepagePostTypeMessage postTypeGrey"%> +
              • <%= link_to "全部动态", {:controller => "organizations", :action => "show", :type => nil}, :class =>"homepagePostTypeAll postTypeGrey"%> +
              +
          -
        • -
        + <% end %>
    <% end %> -<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> +<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 and params[:org_subfield_id].nil? %> \ No newline at end of file diff --git a/config/locales/account/zh.yml b/config/locales/account/zh.yml index c7c76707d..c6a23b964 100644 --- a/config/locales/account/zh.yml +++ b/config/locales/account/zh.yml @@ -52,7 +52,7 @@ zh: label_mail_attention: "qq邮箱可能收不到此邮件,其他邮箱如果没有收到可能在垃圾邮件中," label_mail_attention1: "其中gmail与教育网邮箱的激活邮件有时比较慢,请耐心等待。" # register中js判断密码设置是否合法提示信息 - setting_password_min_length_limit: "密码长度至少大于 %{count} 个字符。" + setting_password_min_length_limit: "密码长度至少大于等于 %{count} 个字符。" setting_password_error: "密码长度不够或密码不一致" setting_password_success: "密码设置成功" # account_controller中register方法判断注册成功的提示信息 diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 7ccbb8410..81b20a67e 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -921,6 +921,7 @@ zh: button_rollback: 恢复到这个版本 button_reply: 回复 button_archive: 存档 + button_delete_project: 删除项目 button_unarchive: 取消存档 button_reset: 重置 button_rename: 重命名/重定向 diff --git a/config/routes.rb b/config/routes.rb index d20bd8851..f3a953ee8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -895,6 +895,7 @@ RedmineApp::Application.routes.draw do get 'member_score', :to => 'courses#member_score' post 'finishcourse' post 'restartcourse' + match "renew", :to => 'courses#renew', :via => [:post, :get], :as =>'renew' match "searchmembers", :controller => 'courses', :action => 'searchmembers', :via => [:post,:get] match "searchgroupmembers", :via => [:post, :get] match 'member_score_sort', :via => [:get] diff --git a/db/migrate/20151208015409_add_is_delete_to_courses.rb b/db/migrate/20151208015409_add_is_delete_to_courses.rb new file mode 100644 index 000000000..cf037e010 --- /dev/null +++ b/db/migrate/20151208015409_add_is_delete_to_courses.rb @@ -0,0 +1,5 @@ +class AddIsDeleteToCourses < ActiveRecord::Migration + def change + add_column :courses, :is_delete, :integer, :default => 0 + end +end diff --git a/db/migrate/20151208073241_add_subfield_to_document.rb b/db/migrate/20151208073241_add_subfield_to_document.rb new file mode 100644 index 000000000..b070a9cec --- /dev/null +++ b/db/migrate/20151208073241_add_subfield_to_document.rb @@ -0,0 +1,5 @@ +class AddSubfieldToDocument < ActiveRecord::Migration + def change + add_column :org_document_comments, :org_subfield_id, :integer + end +end diff --git a/db/migrate/20151209085900_add_type_to_org_subfields.rb b/db/migrate/20151209085900_add_type_to_org_subfields.rb new file mode 100644 index 000000000..3616a1eb4 --- /dev/null +++ b/db/migrate/20151209085900_add_type_to_org_subfields.rb @@ -0,0 +1,5 @@ +class AddTypeToOrgSubfields < ActiveRecord::Migration + def change + add_column :org_subfields, :field_type, :string + end +end diff --git a/db/migrate/20151209085942_set_type_for_org_subfields.rb b/db/migrate/20151209085942_set_type_for_org_subfields.rb new file mode 100644 index 000000000..0ce313234 --- /dev/null +++ b/db/migrate/20151209085942_set_type_for_org_subfields.rb @@ -0,0 +1,10 @@ +class SetTypeForOrgSubfields < ActiveRecord::Migration + def up + OrgSubfield.all.each do |field| + field.update_attribute(:field_type, "Post") + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 9c23eb951..17e613acb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20151208032013) do +ActiveRecord::Schema.define(:version => 20151209085942) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -459,6 +459,7 @@ ActiveRecord::Schema.define(:version => 20151208032013) do t.integer "open_student", :default => 0 t.integer "outline", :default => 0 t.integer "publish_resource", :default => 0 + t.integer "is_delete", :default => 0 end create_table "custom_fields", :force => true do |t| @@ -1160,6 +1161,7 @@ ActiveRecord::Schema.define(:version => 20151208032013) do t.datetime "updated_at", :null => false t.boolean "locked", :default => false t.integer "sticky", :default => 0 + t.integer "org_subfield_id" end create_table "org_member_roles", :force => true do |t| @@ -1186,6 +1188,7 @@ ActiveRecord::Schema.define(:version => 20151208032013) do t.string "name" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "field_type" end create_table "organizations", :force => true do |t| @@ -1551,7 +1554,6 @@ ActiveRecord::Schema.define(:version => 20151208032013) do end add_index "student_works", ["homework_common_id", "user_id"], :name => "index_student_works_on_homework_common_id_and_user_id" - add_index "student_works", ["homework_common_id"], :name => "index" create_table "student_works_evaluation_distributions", :force => true do |t| t.integer "student_work_id" diff --git a/lib/tasks/sync_check_members.rake b/lib/tasks/sync_check_members.rake new file mode 100644 index 000000000..8c942c88c --- /dev/null +++ b/lib/tasks/sync_check_members.rake @@ -0,0 +1,25 @@ +require 'trustie/gitlab/sync' + +namespace :gitlab do + namespace :check_members do + desc "check up projects' members " + task :projects => :environment do + s = Trustie::Gitlab::Sync.new + g = Gitlab.client + Project.all.each do |project| + unless project.gpid.nil? + begin + gmembers = g.team_members(project.gpid) + if gmembers.count != project.members.count + puts "gitlab' projects count #{gmembers.count}" + puts "project ID is #{project.id}" + s.only_members(project) + end + rescue + p "This project is wrong #{project.id}" + end + end + end + end + end +end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index a6506bbf3..bf9cb26d8 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -4186,6 +4186,7 @@ _extend(KUploadButton, { (options.form ? '
    ' : ''), '
    '].join(''); var div = K(html, button.doc); + $(div).hide()// 如果 以后要用根据 http://kindeditor.net/docs/uploadbutton.html#k-uploadbutton-options来使用uploadButton,那么这里的button会 是隐藏的 button.hide(); button.before(div); self.div = div; diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 655847fa1..b3618cda4 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1380,4 +1380,11 @@ $(function(){ }); personalized_init(); -}); \ No newline at end of file +}); +function submit_course_feedback() { + var flag = false; + if(flag == false){ + $("#course_feedback_new").submit(); + var flag = true + } +} diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 220120346..c46cfc6e2 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -68,4 +68,6 @@ a.linkGrey8:hover {color:#585858;} .orgMenuArrow {background:url(../images/nav_icon.png) -10px -165px no-repeat; position:relative; display:inline-block; width:20px; height:30px;} .orgMenuArrow2 {background:url(../images/nav_icon.png) -10px -132px no-repeat; position:relative; display:inline-block; width:20px; height:30px;} .org_login_list{ border:1px solid #eaeaea; background:#fff; padding-left:10px; padding-bottom:10px; padding-top:8px; width:60px; left:-53px; position:absolute; z-index:9999; line-height:2; box-shadow: 0px 2px 8px rgba(146, 153, 169, 0.5); margin-top: 30px;} -#orgUserName {max-width:50px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block;} \ No newline at end of file +#orgUserName {max-width:50px; overflow:hidden; white-space: nowrap; text-overflow: ellipsis; display:inline-block;} + +.orgListStatus {width:55px; float:left;} \ No newline at end of file diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index 32ee5a7c6..b1367b882 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1063,4 +1063,6 @@ a.homepagePostTypeMessage { a.homepagePostTypeQuiz { background: transparent url("../images/homepage_icon.png") no-repeat scroll -90px -124px; padding-left: 23px; - } \ No newline at end of file + } + +.loadMore {font-size:14px;width:748px; text-align:center; display:block; border:1px solid #dddddd; background-color:#ffffff; float:right;padding:5px 0; letter-spacing: 1px;} \ No newline at end of file