diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 74c988781..2c4929019 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -103,7 +103,7 @@ class AccountController < ApplicationController def register # @root_path="/home/pdl/redmine-2.3.2-0/apache2/" # - @cache_identityy = params[:identity]||"" #身份 + #@cache_identityy = params[:identity]||"" #身份 @cache_no = params[:no]||"" #学号 @cache_technical_title = params[:technical_title]||"" #教师职称 @cache_province = params[:province]||"" #省份 @@ -136,7 +136,7 @@ class AccountController < ApplicationController session[:auth_source_registration] = nil self.logged_user = @user flash[:notice] = l(:notice_account_activated) - redirect_to my_account_url + redirect_to my_account_path end else @user.login = params[:user][:login] @@ -144,22 +144,7 @@ class AccountController < ApplicationController @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] end - if(@cache_identityy == "") - if params[:identity] == "2" - @user.firstname = firstname_code - @user.lastname = lastname_code - end - flash.now[:error]= l(:label_identity)+l(:'activerecord.errors.messages.empty') - return - end - if(@cache_city == "") - if params[:identity] == "2" - @user.firstname = firstname_code - @user.lastname = lastname_code - end - flash.now[:error]= l(:label_location)+l(:'activerecord.errors.messages.empty') - return - end + case Setting.self_registration when '1' @@ -234,6 +219,10 @@ class AccountController < ApplicationController render :json => req end + def email_valid + + end + private def authenticate_user @@ -363,7 +352,7 @@ class AccountController < ApplicationController UserStatus.create(:user_id => user.id, :changsets_count => 0, :watchers_count => 0) Mailer.register(token).deliver flash[:notice] = l(:notice_account_register_done) - redirect_to signin_url + render action: 'email_valid', locals: {:mail => user.mail} else yield if block_given? end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3326d0b1a..9b1e045e3 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -126,7 +126,7 @@ class AdminController < ApplicationController @status = params[:status] || 1 scope = User.logged.status(@status) - scope = scope.like(params[:name]) if params[:name].present? + scope = scope.like(params[:name],params[:search_by][:id]) 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' diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 3c815c7d8..a57b5f8a5 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -141,6 +141,23 @@ class AttachmentsController < ApplicationController end end + def update_file_dense + @attachment = Attachment.find(params[:attachmentid]) + if @attachment != nil + filedense = params[:newtype].to_s + if filedense == "1" + @attachment.is_public = 1 + else + @attachment.is_public = 0 + end + @attachment.save + @newfiledense = filedense + end + respond_to do |format| + format.js + end + end + def thumbnail if @attachment.thumbnailable? && thumbnail = @attachment.thumbnail(:size => params[:size]) if stale?(:etag => thumbnail) @@ -326,6 +343,35 @@ class AttachmentsController < ApplicationController end end + def add_exist_file_to_courses + file = Attachment.find(params[:file_id]) + courses = params[:courses][:course] + courses.each do |course| + c = Course.find(course); + attach_copied_obj = file.copy + attach_copied_obj.tag_list.add(file.tag_list) # tag关联 + attach_copied_obj.container = c + attach_copied_obj.created_on = Time.now + attach_copied_obj.author_id = User.current.id + attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from + if attach_copied_obj.attachtype == nil + attach_copied_obj.attachtype = 4 + end + @obj = c + @save_flag = attach_copied_obj.save + @save_message = attach_copied_obj.errors.full_messages + end + respond_to do |format| + format.js + end + rescue NoMethodError + @save_flag = false + @save_message = [] << l(:error_attachment_empty) + respond_to do |format| + format.js + end + end + private def find_project @attachment = Attachment.find(params[:id]) diff --git a/app/controllers/auto_completes_controller.rb b/app/controllers/auto_completes_controller.rb index 9e7467bfc..205d4aa01 100644 --- a/app/controllers/auto_completes_controller.rb +++ b/app/controllers/auto_completes_controller.rb @@ -29,7 +29,11 @@ class AutoCompletesController < ApplicationController @issues += scope.where("LOWER(#{Issue.table_name}.subject) LIKE LOWER(?)", "%#{q}%").order("#{Issue.table_name}.id DESC").limit(10).all @issues.compact! end - render :layout => false + #render :layout => false + render :json => @issues.map {|issue| { + 'value' => issue[:subject] + + }} end diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index a8a351eb1..c8ce6ec31 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -7,6 +7,7 @@ class BidsController < ApplicationController menu_item :project, :only => [:show_project,:show_results, :new_submit_homework] menu_item :homework_respond, :only => :homework_respond menu_item :homework_statistics, :only => :homework_statistics + menu_item :edit, :only => :edit before_filter :can_show_course,only: [] before_filter :can_show_contest,only: [] @@ -806,6 +807,7 @@ class BidsController < ApplicationController @bid.is_evaluation = params[:bid][:is_evaluation] @bid.proportion = params[:bid][:proportion] @bid.evaluation_num = params[:bid][:evaluation_num] + @bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation] @bid.reward_type = 3 # @bid.budget = params[:bid][:budget] @bid.deadline = params[:bid][:deadline] @@ -862,6 +864,7 @@ class BidsController < ApplicationController @bid.is_evaluation = params[:bid][:is_evaluation] @bid.proportion = params[:bid][:proportion] @bid.evaluation_num = params[:bid][:evaluation_num] + @bid.open_anonymous_evaluation = params[:bid][:open_anonymous_evaluation] @bid.reward_type = 3 @bid.deadline = params[:bid][:deadline] @bid.budget = 0 diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index ee1ca0230..edfc893d8 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -8,7 +8,7 @@ class CoursesController < ApplicationController menu_item :overview menu_item :feedback, :only => :feedback menu_item :homework, :only => :homework - menu_item :new_homework + menu_item :new_homework, :only => :new_homework menu_item l(:label_sort_by_time), :only => :index menu_item l(:label_sort_by_active), :only => :index @@ -271,8 +271,7 @@ class CoursesController < ApplicationController @issue_custom_fields = IssueCustomField.sorted.all @trackers = Tracker.sorted.all - if User.current.user_extensions.identity == 0 - if @course.save + if @course.save #unless User.current.admin? r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first m = Member.new(:user => User.current, :roles => [r]) @@ -298,15 +297,13 @@ class CoursesController < ApplicationController } format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) } end - else + else #@course.destroy respond_to do |format| format.html { render :action => 'new', :layout => 'base' } #Added by young format.api { render_validation_errors(@course) } end - end - end - + end end def course @@ -514,6 +511,7 @@ class CoursesController < ApplicationController def new_homework @homework = Bid.new @homework.safe_attributes = params[:bid] + @homework.open_anonymous_evaluation = 1 if (User.current.logged? && User.current.member_of_course?(Course.find params[:id] )) render :layout => 'base_courses' else diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 8dd8ba93f..ca7f8e040 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -22,22 +22,55 @@ class FilesController < ApplicationController menu_item :files before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:getattachtype] + before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search] helper :sort include SortHelper helper :project_score def show_attachments obj - all_attachments = [] + @all_attachments = [] obj.each do |container| - all_attachments += container.attachments + @all_attachments += container.attachments end @limit = 10 - @feedback_count = all_attachments.count + @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @offset ||= @feedback_pages.offset - @curse_attachments = all_attachments[@offset, @limit] + @curse_attachments_all = @all_attachments[@offset, @limit] + @curse_attachments = paginateHelper @all_attachments,10 + end + + def search + begin + @is_remote = true + q = "%#{params[:name].strip}%" + #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? + if params[:insite] + @result = find_public_attache q + @searched_attach = paginateHelper @result,10 + else + @result = find_course_attache q,@course + @searched_attach = paginateHelper @result,10 + end + + rescue Exception => e + #render 'stores' + redirect_to stores_url + end + end + + def find_course_attache keywords,course + resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). + reorder("created_on DESC") + end + + def find_public_attache keywords + # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map + # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 + # 现在还木有思路 药丸 + resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). + reorder("created_on DESC") end def index @@ -48,7 +81,9 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" sort = "" - + @sort = "" + @order = "" + @is_remote = false if params[:project_id] @isproject = true @@ -113,7 +148,8 @@ class FilesController < ApplicationController when "created_on" attribute = "created_on" end - + @sort = order_by[0] + @order = order_by[1] if order_by.count == 1 sort += "#{Attachment.table_name}.#{attribute} asc " elsif order_by.count == 2 @@ -134,6 +170,10 @@ class FilesController < ApplicationController end + def quote_resource_show + @file = Attachment.find(params[:id]) + end + def new @versions = @project.versions.sort @course_tag = @project.project_type @@ -265,6 +305,7 @@ class FilesController < ApplicationController 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" sort='' + if params[:sort] params[:sort].split(",").each do |sort_type| order_by = sort_type.split(":") diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index d5fc1770c..cd51d2e58 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -52,7 +52,7 @@ class ForumsController < ApplicationController def index @offset, @limit = api_offset_and_limit({:limit => 10}) - @forums_all = Forum.where('1=1') + @forums_all = Forum.reorder("sticky DESC") @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] @@ -208,6 +208,8 @@ class ForumsController < ApplicationController end end + + private diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 2cf2e7895..61760f462 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -106,7 +106,7 @@ class HomeworkAttachController < ApplicationController (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id}) AS m_score FROM homework_attaches INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id - WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") + WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY m_score DESC") @cur_page = params[:page] || 1 @cur_type = 4 @homework_list = paginateHelper all_homework_list,10 diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 97c0ce4f6..f3c2b199c 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -17,7 +17,6 @@ class IssuesController < ApplicationController layout 'base_projects'#Added by young - menu_item :new_issue, :only => [:new, :create] default_search_scope :issues before_filter :find_issue, :only => [:show, :edit, :update] @@ -59,8 +58,8 @@ class IssuesController < ApplicationController sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) sort_update(@query.sortable_columns) @query.sort_criteria = sort_criteria.to_a - - @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young + + @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base' if @query.valid? case params[:format] diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 9257888dd..aaa99e417 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -19,7 +19,7 @@ class MemosController < ApplicationController @content = "#{ll(Setting.default_language, :text_user_wrote, @memo.author)}
  " @content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n") + "\n\n
" - @content = "
" << @content + @content = "
" << @content #@content = "> #{ll(Setting.default_language, :text_user_wrote, @memo.author)}\n> " #@content << @memo.content.to_s.strip.gsub(%r{
((.|\s)*?)
}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" #@content_html = textilizable(@content) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index fa2784f22..308cb62ca 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -91,7 +91,11 @@ class MyController < ApplicationController end @se = @user.extensions - @se.school_id = params[:occupation] if params[:occupation] + if params[:occupation].to_i.to_s == params[:occupation] + @se.school_id = params[:occupation] + else + @se.occupation = params[:occupation] + end @se.gender = params[:gender] @se.location = params[:province] if params[:province] @se.location_city = params[:city] if params[:city] diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 1318e40a5..5bd5fb0e3 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -14,13 +14,14 @@ class TagsController < ApplicationController include AttachmentsHelper include ContestsHelper include ActsAsTaggableOn::TagsHelper + include TagsHelper helper :projects helper :courses - include TagsHelper helper :tags include OpenSourceProjectsHelper before_filter :require_admin,:only => [:delete,:show_all] + before_filter :require_login,:only => [:tag_save] # $selected_tags = Array.new # $related_tags = Array.new @@ -188,6 +189,83 @@ class TagsController < ApplicationController # end end end + + # 只删除某个对象的该tag + def remove_tag_new + @obj = nil + @object_flag = nil + + if request.get? + # 获取传过来的tag_id taggable_id 和 taggable_type,通过2者确定要删除tag的对象 + @tag_name = params[:tag_name] + @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id + @taggable_id = params[:taggable_id] # 当做参数传时对象会变成字符串 + @taggable_type = numbers_to_object_type(params[:taggable_type]) + + @obj = get_object(@taggable_id,params[:taggable_type]) + @object_flag = params[:taggable_type] + + # if can_remove_tag?(User.current,@taggable_id,@taggable_type) + + @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) + + unless @taggings.nil? + @taggings.delete + end + + # 是否还有其他记录 引用了 tag_id + @tagging = ActsAsTaggableOn::Tagging.find_by_tag_id(@tag_id) + # 如果taggings表中记录已经不存在 ,那么检查tags表 作删除动作 + if @tagging.nil? + @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id) + @tag.delete unless @tag.nil? + end + # end + end + end + + def tag_save + @tags = params[:tag_for_save][:name] + @obj_id = params[:tag_for_save][:object_id] + @obj_flag = params[:tag_for_save][:object_flag] + + case @obj_flag + when '1' then + @obj = User.find_by_id(@obj_id) + when '2' then + @obj = Project.find_by_id(@obj_id) + when '3' then + @obj = Issue.find_by_id(@obj_id) + when '4' then + @obj = Bid.find_by_id(@obj_id) + when '5' then + @obj = Forum.find_by_id(@obj_id) + when '6' + @obj = Attachment.find_by_id(@obj_id) + when '7' then + @obj = Contest.find_by_id(@obj_id) + when '8' + @obj = OpenSourceProject.find_by_id(@obj_id) + when '9' + @obj = Course.find_by_id(@obj_id) + else + @obj = nil + end + unless @obj.nil? + @obj.tag_list.add(@tags.split(",")) + else + return + end + if @obj.save + logger.debug "#{__FILE__}:#{__LINE__} ===> #{@obj.to_json}" + else + logger.error "#{__FILE__}:#{__LINE__} ===> #{@obj.errors.try(:full_messages)}" + end + respond_to do |format| + format.js + format.html + end + end private # 这里用来刷新搜索结果的区域 @@ -308,5 +386,7 @@ class TagsController < ApplicationController return end end + + end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9b2e5990a..b466e4721 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -374,7 +374,7 @@ class UsersController < ApplicationController "show_changesets" => true } scope = User.logged.status(@status) - scope = scope.like(params[:name]) if params[:name].present? + scope = scope.like(params[:name],params[:search_by][:id]) if params[:name].present? @user_count = scope.count @user_pages = Paginator.new @user_count, @limit, params['page'] @user_base_tag = params[:id] ? 'base_users':'users_base' @@ -812,7 +812,7 @@ class UsersController < ApplicationController # 必填自己的工作单位,其实就是学校 def auth_user_extension - if @user == User.current && (@user.user_extensions.nil? || @user.user_extensions.school.nil?) + if @user == User.current && @user.user_extensions.nil? flash[:error] = l(:error_complete_occupation) redirect_to my_account_url end diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index efa171d52..d7f9fa0ac 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -72,7 +72,7 @@ class ZipdownController < ApplicationController homeattach.attachments.each do |attach| homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping("#{Time.now.to_i.to_s}_#{homeattach.user.name}_#{homeattach.user.user_extensions.student_id}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) + zipping("#{homeattach.user.lastname}#{homeattach.user.firstname}_#{homeattach.user.user_extensions.student_id}_#{Time.now.to_i.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true) end diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7ea49dad2..3c882d393 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -177,6 +177,8 @@ module AttachmentsHelper s.html_safe end + + # Modified by Longjun # 有参数的方法要加() def private_filter(resultSet) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ac22ed412..178782da3 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -328,7 +328,7 @@ module CoursesHelper #当前用户是不是指定课程的学生 def is_cur_course_student course #course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and members.user_id = #{User.current.id}", {:role_id => StudentRoles}).count != 0 - !(User.current.allowed_to?(:as_teacher,course)) + User.current.logged? && User.current.member_of_course?(course) && !(User.current.allowed_to?(:as_teacher,course)) #修改:能新建占位且不能新建任务的角色判定为学生 #is_student = false #@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 052aae468..9a0a1127f 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -44,6 +44,16 @@ module FilesHelper File.new(zipfile_name,'w+') end + def courses_check_box_tags(name,courses,current_course) + s = '' + courses.each do |course| + if course.id != current_course.id && is_course_teacher(User.current,course) + s << "
" + end + end + s.html_safe + end + # 判断指定的资源时候符合类型 def isTypeOk(attachment, type, contentType) result = false diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 637c92db3..dfa485a70 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -227,6 +227,7 @@ module IssuesHelper strings = [] values_by_field = {} details.each do |detail| + unless detail.property == 'attachment' if detail.property == 'cf' field_id = detail.prop_key field = CustomField.find_by_id(field_id) @@ -242,6 +243,7 @@ module IssuesHelper end end strings << show_detail(detail, no_html, options) + end end values_by_field.each do |field_id, changes| detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb index 298331c69..6d916f43e 100644 --- a/app/helpers/watchers_helper.rb +++ b/app/helpers/watchers_helper.rb @@ -97,7 +97,7 @@ module WatchersHelper return '' unless user && user.logged? # modify by nwb # 主讲教师不允许退出课程 - return '' if user.id == course.tea_id || course.is_public == 0 + return '' if user.id == course.tea_id joined = user.member_of_course?(course) text = joined ? l(:label_exit_course) : l(:label_new_join) url_t = join_path(:object_id => course.id) diff --git a/app/models/course.rb b/app/models/course.rb index 1f0cb0979..6bb7a75d4 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -1,3 +1,4 @@ + class Course < ActiveRecord::Base include Redmine::SafeAttributes @@ -5,7 +6,7 @@ class Course < ActiveRecord::Base STATUS_CLOSED = 5 STATUS_ARCHIVED = 9 - attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period + attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, :open_student 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表 @@ -33,10 +34,10 @@ class Course < ActiveRecord::Base acts_as_attachable :view_permission => :view_files, :delete_permission => :manage_files - validates :password, presence: true - validates :term, presence: true - validates :name, presence: true - validates :class_period, presence: true,format: {:with =>/^\d*$/} + validates_presence_of :password, :term,:name,:description + validates_format_of :class_period, :with =>/^[1-9]\d*$/ + validates_format_of :name,:with =>/^[a-zA-Z0-9_\u4e00-\u9fa5]+$/ + validates_length_of :description, :maximum => 10000 before_save :self_validate after_create :create_board_sync before_destroy :delete_all_members @@ -52,7 +53,8 @@ class Course < ActiveRecord::Base 'term', 'is_public', 'description', - 'class_period' + 'class_period', + 'open_student' acts_as_customizable @@ -308,3 +310,5 @@ class Course < ActiveRecord::Base # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) #end end + + diff --git a/app/models/forum.rb b/app/models/forum.rb index 24b5b15e0..61ba528a0 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -8,7 +8,9 @@ class Forum < ActiveRecord::Base 'topic_count', 'memo_count', 'last_memo_id', - 'creator_id' + 'creator_id', + 'sticky', + 'locked' validates_presence_of :name, :creator_id, :description validates_length_of :name, maximum: 50 #validates_length_of :description, maximum: 255 @@ -28,7 +30,7 @@ class Forum < ActiveRecord::Base def destroyable_by? user # user && user.logged? && Forum.find(self.forum_id).creator_id == user.id || user.admin? - user.admin? + self.creator == user || user.admin? end # Updates topic_count, memo_count and last_memo_id attributes for +board_id+ diff --git a/app/models/issue.rb b/app/models/issue.rb index 6bbcd727f..09e093177 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1359,7 +1359,7 @@ class Issue < ActiveRecord::Base # Callback on file attachment def attachment_added(obj) - if @current_journal && !obj.new_record? + if @current_journal && !obj.new_record? && @current_journal.journalized_id == obj.author_id @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) end end diff --git a/app/models/memo.rb b/app/models/memo.rb index b02564834..cfc509923 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -88,11 +88,11 @@ class Memo < ActiveRecord::Base def editable_by? user # user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)) - user.admin? + user.admin? || self.author == user end def destroyable_by? user - (user && user.logged? && (Forum.find(self.forum_id).creator_id == user.id) ) || user.admin? + (user && self.author == user) || user.admin? #self.author == user || user.admin? end diff --git a/app/models/message.rb b/app/models/message.rb index 0fdfc5b15..8af3265cc 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -78,9 +78,13 @@ class Message < ActiveRecord::Base safe_attributes 'subject', 'content' - safe_attributes 'locked', 'sticky', 'board_id', + safe_attributes 'board_id','locked', 'sticky', :if => lambda {|message, user| - user.allowed_to?(:edit_messages, message.project) + if message.project + user.allowed_to?(:edit_messages, message.project) + else + user.allowed_to?(:edit_messages, message.course) + end } def visible?(user=User.current) @@ -158,6 +162,7 @@ class Message < ActiveRecord::Base #更新用户分数 -by zjc def be_user_score #新建message且无parent的为发帖 + if self.parent_id.nil? && !self.board.project.nil? UserScore.joint(:post_message, self.author,nil,self, { message_id: self.id }) update_memo_number(self.author,1) diff --git a/app/models/news.rb b/app/models/news.rb index 4f8601796..4d153e81f 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -29,6 +29,7 @@ class News < ActiveRecord::Base validates_presence_of :title, :description validates_length_of :title, :maximum => 60 validates_length_of :summary, :maximum => 255 + validates_length_of :description, :maximum => 10000 acts_as_attachable :delete_permission => :manage_news acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :include => :project diff --git a/app/models/project.rb b/app/models/project.rb index ddb92a587..14763347f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -41,7 +41,7 @@ class Project < ActiveRecord::Base has_many :principals, :through => :member_principals, :source => :principal has_many :enabled_modules, :dependent => :delete_all has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position" - has_many :issues, :dependent => :destroy, :include => [:status, :tracker] + has_many :issues, :dependent => :destroy, :include => [:status, :tracker],:order => "id ASC" has_many :issue_changes, :through => :issues, :source => :journals has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC" has_many :time_entries, :dependent => :delete_all @@ -1151,3 +1151,4 @@ class Project < ActiveRecord::Base end + diff --git a/app/models/user.rb b/app/models/user.rb index bbee7f763..ff627763a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -199,13 +199,19 @@ class User < Principal } scope :sorted, lambda { order(*User.fields_for_order_statement)} - scope :like, lambda {|arg| + scope :like, lambda {|arg, type| if arg.blank? where(nil) else pattern = "%#{arg.to_s.strip.downcase}%" #where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern) - where(" LOWER(login) LIKE :p ", :p => pattern) + if type == "0" + where(" LOWER(login) LIKE :p ", :p => pattern) + elsif type == "1" + where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern) + else + where(" LOWER(mail) LIKE :p ", :p => pattern) + end end } diff --git a/app/models/web_footer_company.rb b/app/models/web_footer_company.rb index 0743b6a9c..fa51a3a66 100644 --- a/app/models/web_footer_company.rb +++ b/app/models/web_footer_company.rb @@ -3,6 +3,6 @@ class WebFooterCompany < ActiveRecord::Base validates :name, presence: true, length: { maximum: 500 } validates :url, length: { maximum: 500 }, format: { with: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/, - message: l(:is_not_url_error) + message: :invalid } end diff --git a/app/views/account/email_valid.html.erb b/app/views/account/email_valid.html.erb new file mode 100644 index 000000000..6f4de1197 --- /dev/null +++ b/app/views/account/email_valid.html.erb @@ -0,0 +1,53 @@ + + + + 注册帐号 + + + +<% email = @user.mail.split("@")[1] %> + +
+ +

+ 邮箱激活

+ +
+
+
+

请在24小时内点击邮件中的链接继续完成注册

+
+ 邮件已发送到邮箱 + <%= @user.mail %> +
+

+ 立即查收邮件

+ + + 没收到邮件? + +
+ + 请先检查是否在垃圾邮件中 + + +
+ +
+
+
+ +
+ + + \ No newline at end of file diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index cbdbd108b..21bdd8fa7 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -3,287 +3,9 @@ @nav_dispaly_main_project_label = 1 @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> - - - @@ -292,145 +14,30 @@ <%= labelled_form_for @user, :url => register_path do |f| %> <%= error_messages_for 'user' %>
-

- - - - - - -
- <%= l(:label_identity) %> * - - - - -
-

+ <% if @user.auth_source_id.nil? %>

<%= f.text_field :login, :size => 25, :required => true %> - <%= l(:label_max_number) %> + <%= l(:label_max_number) %>

<%= f.password_field :password, :size => 25, :required => true %> - <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %> + <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

-

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

+

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

<% end %> - - -

- <%= f.text_field :mail, :required => true %> - -

-

- <%= "#{l(:label_mail_attention)} " %> -

-

<%= f.select :language, lang_options_for_select, :required => true %>

- -

- - - - - - -
- <%= l(:label_location) %> * - - - - -
+ <%= f.text_field :mail,:size => 25, :required => true %> +

+

+ +

<%= "#{l(:label_mail_attention)} " %>

+

<%= "#{l(:label_mail_attention1)} " %>

+
+

+ + +
@@ -453,7 +60,7 @@ jQuery(document).ready(function () { var $login = $('#user_login') var $mail = $('#user_mail') - + var $password_confirmation = $('#user_password_confirmation') $login.blur(function (event) { if ($(this).is('#user_login')) { $.get( @@ -485,6 +92,19 @@ }); } ; + }); + $password_confirmation.blur(function () { + var pas1 = document.getElementById("user_password").value; + var pas2 = document.getElementById("user_password_confirmation").value; + if (pas1 == pas2) { + $('#valid_password').html('' + "<%= l(:setting_password_success) %>"+ ""); + } + else { + $('#valid_password').html('' + "<%= l(:setting_password_error) %>" + ""); + } + + + }); }); \ No newline at end of file diff --git a/app/views/admin/search.html.erb b/app/views/admin/search.html.erb index 5d49d84fa..320fce125 100644 --- a/app/views/admin/search.html.erb +++ b/app/views/admin/search.html.erb @@ -17,7 +17,10 @@ <%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %> <% end %> - + + <%= select "search_by", "id", + { l(:label_search_by_login) => "0", l(:label_search_by_name) => "1", l(:label_search_by_email) => "2" }, + :size => 20 %> <%= text_field_tag 'name', params[:name], :size => 30 %> <%= submit_tag l(:label_search), :class => "small", :name => nil %> @@ -51,7 +54,7 @@ <%= 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 => admin_users_path(params)) unless User.current == user %> + <%= delete_link user_path(user, :back_url => admin_search_path(params)) unless User.current == user %> <% end -%> diff --git a/app/views/admin/users.html.erb b/app/views/admin/users.html.erb index 7bbdf1c3e..12aa95a16 100644 --- a/app/views/admin/users.html.erb +++ b/app/views/admin/users.html.erb @@ -17,7 +17,10 @@ <%= select_tag 'group_id', content_tag('option') + options_from_collection_for_select(@groups, :id, :name, params[:group_id].to_i), :onchange => "this.form.submit(); return false;" %> <% end %> - + + <%= select "search_by", "id", + { l(:label_search_by_login) => "0", l(:label_search_by_name) => "1", l(:label_search_by_email) => "2" }, + :size => 20 %> <%= text_field_tag 'name', params[:name], :size => 30 %> <%= submit_tag l(:label_search), :class => "small", :name => nil %> diff --git a/app/views/attachments/add_exist_file_to_courses.js.erb b/app/views/attachments/add_exist_file_to_courses.js.erb new file mode 100644 index 000000000..23761647f --- /dev/null +++ b/app/views/attachments/add_exist_file_to_courses.js.erb @@ -0,0 +1,5 @@ +<% if !@save_flag%> + $("#error_show").html("<%= @save_message.join(', ') %>"); +<% else %> + closeModal(); +<% end %> diff --git a/app/views/attachments/update_file_dense.js.erb b/app/views/attachments/update_file_dense.js.erb new file mode 100644 index 000000000..d99481d08 --- /dev/null +++ b/app/views/attachments/update_file_dense.js.erb @@ -0,0 +1,2 @@ +$("#is_public_<%= @attachment.id %>").html("<%= escape_javascript(link_to (@attachment.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>@attachment.id,:newtype=>(@attachment.is_public? ? 0:1)), + :remote=>true,:class=>"f_l re_open",:method => :post) %>"); diff --git a/app/views/bids/_alert_anonyoms.html.erb b/app/views/bids/_alert_anonyoms.html.erb index e533048f5..6205b2b6c 100644 --- a/app/views/bids/_alert_anonyoms.html.erb +++ b/app/views/bids/_alert_anonyoms.html.erb @@ -14,7 +14,7 @@ /* 匿名评分弹框 */ - .anonymos{width:480px;height:180px;position:absolute;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} + .anonymos{width:480px;height:180px;position:fixed;z-index:100;left:50%;top:50%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;} .ni_con { width:425px; margin:25px 30px;} .ni_con h2{ display:block; height:40px; width:425px; text-align:center; color:#3a3a3a;} .ni_con p{ color:#808181; } diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 73a9bc6bd..aadc93fa4 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -1,4 +1,38 @@ + + + <% if bids.blank? %> <%#= l(:label_uncommit_homework) %> 暂无作业! @@ -26,7 +60,15 @@ <% if User.current.logged? && is_cur_course_student(@course) %> <% cur_user_homework = cur_user_homework_for_bid(bid) %> <% if cur_user_homework!= nil && cur_user_homework.empty? %> - <%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %> + <% if bid.comment_status == 0 || bid.comment_status == 2%> + + <%= link_to l(:label_commit_homework),new_exercise_book_path(bid) %> + + <% else %> + + 提交作业 + + <% end %> <% else %> <%= l(:lable_has_commit_homework)%> @@ -34,7 +76,8 @@ <% end %> <% end %> <% if (User.current.admin?||User.current.id==bid.author_id) %> - + <% if bid.open_anonymous_evaluation == 1%> + <% case bid.comment_status %> <% when 0 %> <%= link_to '启动匿评', alert_anonymous_comment_bid_path(bid), id: "#{bid.id}_start_anonymous_comment", remote: true, disable_with: '加载中...' %> @@ -44,11 +87,13 @@ 匿评结束 <% end %> - <%= link_to( + <%end%> + + <%= link_to( l(:button_edit), - {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id}, - :class => 'icon icon-edit' + {:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id} ) %> + <%#= link_to( l(:button_delete), {:action => 'homework_destroy', :controller=>'bids', :course_id => bid.id}, @@ -94,19 +139,6 @@ ) - - <% if betweentime(bid.deadline) < 0 %> - - <%= l(:label_commit_limit)%> - - <% else %> - <% if betweentime(bid.deadline) < 3 %> - - <%= l(:label_commit_ar) %> - - <% end %> - <% end %> - @@ -146,10 +178,18 @@ <%=format_time bid.created_on %> - <%= l(:field_deadline) %> - :  - <%=bid.deadline %> - + <% if betweentime(bid.deadline) < 0 %> + + <%= l(:label_commit_limit)%> + + <% else %> + + + + <% end %> + diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 078ca8000..7cde4f31d 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -43,9 +43,9 @@ <% end %> <% unless @is_teacher%> - <% if @bid.comment_status == 0%> + <% if @bid.comment_status == 0 && @bid.open_anonymous_evaluation == 1%> $("#my_homework").click(); - <% elsif @bid.comment_status == 2%> + <% elsif @bid.comment_status == 2 || @bid.open_anonymous_evaluation == 0%> $("#all_homeworks").click(); <% end %> <% end %> diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index 448e4144a..cd682deb0 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -44,6 +44,10 @@ <%= f.select :proportion, proportion_option %>

+ <%= f.check_box :open_anonymous_evaluation, :style => "margin-left:10px;" %> + 未开启匿评作业将直接进入众评点赞阶段 +

+

<%= f.text_field :evaluation_num, :required => true, :size => 60, :style => "width:150px;", :onblur => "regexEvaluationNum();" , :maxlength => 4%> 匿评分配数量不宜太大,否则会影响开启匿评速度

diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index acbcbc2fa..036289b0a 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -28,14 +28,17 @@ <% else %> <% end%> diff --git a/app/views/courses/homework.html.erb b/app/views/courses/homework.html.erb index 95e26abd0..68ec0dc2e 100644 --- a/app/views/courses/homework.html.erb +++ b/app/views/courses/homework.html.erb @@ -5,11 +5,12 @@ <%= javascript_include_tag 'attachments' %> -
- <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%> - <%= link_to(l(:label_course_homework_new), {:controller => 'courses', :action => 'new_homework'}, :class => 'icon icon-add') %> - <% end %> + <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%> + <%= link_to(l(:label_course_homework_new), {:controller => 'courses', :action => 'new_homework'}, :class => 'icon icon-add') %> + <% else %> + <%= l(:label_coursejoin_tip) %> + <% end %>
<%= render :partial => 'bids/bid_homework_show', :locals => {:bids => @bids, :bid_pages => @bid_pages} %> diff --git a/app/views/courses/new_homework.html.erb b/app/views/courses/new_homework.html.erb index 753aa20c8..7b6784243 100644 --- a/app/views/courses/new_homework.html.erb +++ b/app/views/courses/new_homework.html.erb @@ -43,35 +43,55 @@ { var evaluation_num = $.trim($("#bid_evaluation_num").val()); var regex = /^\d+$/; - if(evaluation_num=="") + if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") { - $("#bid_evaluation_num_span").text("匿评分配数量不能为空"); - $("#bid_evaluation_num_span").css('color','#ff0000'); - return false; - } - else if(regex.test(evaluation_num)) - { - if(evaluation_num > 0) + if(evaluation_num=="") { - $("#bid_evaluation_num_span").text("填写正确"); - $("#bid_evaluation_num_span").css('color','#008000'); - return true; + $("#bid_evaluation_num_span").text("匿评分配数量不能为空"); + $("#bid_evaluation_num_span").css('color','#ff0000'); + return false; + } + else if(regex.test(evaluation_num)) + { + if(evaluation_num > 0) + { + $("#bid_evaluation_num_span").text("填写正确"); + $("#bid_evaluation_num_span").css('color','#008000'); + return true; + } + else + { + $("#bid_evaluation_num_span").text("匿评分配数量必须为大于0"); + $("#bid_evaluation_num_span").css('color','#ff0000'); + return false; + } } else { - $("#bid_evaluation_num_span").text("匿评分配数量必须为大于0"); + $("#bid_evaluation_num_span").text("匿评分配数量只能为数字"); $("#bid_evaluation_num_span").css('color','#ff0000'); return false; } } else { - $("#bid_evaluation_num_span").text("匿评分配数量只能为数字"); - $("#bid_evaluation_num_span").css('color','#ff0000'); - return false; + return true; } } + $(function(){ + $("#bid_open_anonymous_evaluation").click(function(){ + if($("#bid_open_anonymous_evaluation").attr("checked") == "checked") + { + $("#evaluation_num_p").slideDown(); + } + else + { + $("#evaluation_num_p").slideUp(); + } + }); + }); + function submitHomework() { if(regexDeadLine()&®exName()&®exEvaluationNum()) diff --git a/app/views/courses/settings/_members.html.erb b/app/views/courses/settings/_members.html.erb index ab0f20257..e73e9cf7b 100644 --- a/app/views/courses/settings/_members.html.erb +++ b/app/views/courses/settings/_members.html.erb @@ -20,8 +20,8 @@ <% members.each do |member| %> <% next if member.new_record? %> - <%= link_to_user member.principal %> - + <%= link_to_user member.principal %> + <%= h member.roles.sort.collect(&:to_s).join(', ') %> diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index ee7d995e7..629cac072 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,3 +1,4 @@ + <% if @events_by_day != nil && @events_by_day.size >0 %>

@@ -98,8 +99,6 @@

<% end %> - -
<%else%>
diff --git a/app/views/files/_arrow_show.erb b/app/views/files/_arrow_show.erb new file mode 100644 index 000000000..d8f094719 --- /dev/null +++ b/app/views/files/_arrow_show.erb @@ -0,0 +1,10 @@ + +<% if sort == current %> + <% if order =="asc" %> + ↑ + <% elsif order == "desc" %> + ↓ + <% else %> + + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/files/_attachement_list.html.erb b/app/views/files/_attachement_list.html.erb new file mode 100644 index 000000000..f65ba8d41 --- /dev/null +++ b/app/views/files/_attachement_list.html.erb @@ -0,0 +1,46 @@ +
+ +<% if defined?(container) && container && container.saved_attachments %> + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %> + <%= l(:field_is_public)%>: + <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'is_public')%> + <%= if attachment.id.nil? + #待补充代码 + else + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') + end + %> + <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> + + <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> + + <% end %> +<% end %> + +
+ + +<%= file_field_tag 'attachments[dummy][file]', + :id => '_file', + :class => 'file_selector', + :multiple => true, + :onchange => 'addInputFiles(this);', + :style => 'display:none', + :data => { + :max_file_size => Setting.attachment_max_size.to_i.kilobytes, + :max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)), + :max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i, + :upload_path => uploads_path(:format => 'js'), + :description_placeholder => l(:label_optional_description) + } %> + + \ No newline at end of file diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb index a1dae9a33..49747ae11 100644 --- a/app/views/files/_course_file.html.erb +++ b/app/views/files/_course_file.html.erb @@ -1,82 +1,44 @@ - <% attachmenttypes = @course.attachmenttypes %> <% sufixtypes = @course.contenttypes %> -<%= t(:label_user_course) %>资源共享区 -
+<%= stylesheet_link_tag 'resource', :media => 'all' %> + + +
+
+
+ <%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> + <%= submit_tag "课内搜索", :class => "re_schbtn b_dblue",:name => "incourse"%> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite" %> + <% end %> + <% if is_course_teacher(User.current,@course) %> + 上传资源 + <% end %> +
+
+ +
+<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@curse_attachments} %> +
-<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:course_id => @course.id, :format => 'js') }')" %> - -<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %> - -
- <%#= render :partial => 'course_show_all_attachment' %> - <% if (@attachtype==0 && @contenttype=='0') || (@attachtype.nil? && @contenttype.nil?) %> - - <%= render partial: "course_show_all_attachment"%> - - <%else%> - - <%= render partial: "course_sort_by_attachtypel"%> - - <%end%>
- <% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb new file mode 100644 index 000000000..554a3aea5 --- /dev/null +++ b/app/views/files/_course_list.html.erb @@ -0,0 +1,51 @@ +<% delete_allowed = User.current.allowed_to?(:manage_files, course) %> +
+

共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源

+ +
+
+<% curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> +
+
+ <%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <% if is_course_teacher(User.current,@course) %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> + <% end %> +
+
+
+

文件大小:<%= number_to_human_size(file.filesize) %>

+ <%= link_to( l(:button_delete), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed %> +

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

+
+
+
+ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> +
+
+
+<% end %> +
    + <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%> +
+
\ No newline at end of file diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb index 315314828..f52b7d353 100644 --- a/app/views/files/_project_file.html.erb +++ b/app/views/files/_project_file.html.erb @@ -52,7 +52,7 @@ <% if attachmenttypes.any? %>       - <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"), + <%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName",params[:type]), :onchange => "attachmenttypes_searchex(this.value)" %> <% end %> <% if sufixtypes.any? %> diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb new file mode 100644 index 000000000..8041802a5 --- /dev/null +++ b/app/views/files/_show_quote_resource.html.erb @@ -0,0 +1,24 @@ +
+
+
+

将此课件引入我的课程资源库

+
+ <%= form_tag course_attach_relations_path, + method: :post, + remote: true, + id: "relation_file_form" do %> + <%= hidden_field_tag(:file_id, file.id) %> + <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course), :id => 'courses')%> + 引  用取  消 + <% end -%> +
+ +
+
+ + \ No newline at end of file diff --git a/app/views/files/_upload_show.html.erb b/app/views/files/_upload_show.html.erb new file mode 100644 index 000000000..a979715de --- /dev/null +++ b/app/views/files/_upload_show.html.erb @@ -0,0 +1,26 @@ +
+
+

上传资源

+
+ <%= error_messages_for 'attachment' %> + + <%= form_tag(course_files_path(course), :multipart => true,:remote => true,:method => :post,:name=>"upload_form") do %> + + <%= render :partial => 'attachement_list',:locals => {:course => course} %> +
+ 上传资源取  消 + <% end %> +
+ +
+ <% content_for :header_tags do %> + <%= javascript_include_tag 'attachments' %> + <% end %> +
+ + \ No newline at end of file diff --git a/app/views/files/create.js.erb b/app/views/files/create.js.erb index 0eca9c1ed..90215c16c 100644 --- a/app/views/files/create.js.erb +++ b/app/views/files/create.js.erb @@ -27,6 +27,8 @@ $('#upload_file_div').slideToggle('slow'); $("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>'); <%elsif @course%> $("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>'); +closeModal(); +$("#resource_list").html('<%= j(render partial: "course_file" ,locals: {course: @course}) %>'); <%end%> <% end %> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index 69b41fc28..fe04c4e3f 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,10 +1,11 @@ +
<% if @isproject %> <%= render :partial => 'project_file', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %> - +
@@ -24,7 +36,9 @@

-

(<%= l(:label_forums_max_length) %>)

+

+ (<%= l(:label_forums_max_length) %>) +

<%= submit_tag l(:button_submit) %> diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 9d0eba923..fe2f757c3 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -4,18 +4,54 @@ <% forums.each do |forum| %>
- <%= forum.creator.nil? ? (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar")) : (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator)) %> -
+ <%= forum.creator.nil? ? (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar")) : (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator)) %> +
-

<%= link_to h(forum.name), forum_path(forum) %>

-

<%= textAreailizable forum.description%>

-

<%= authoring forum.created_at, forum.creator %>

+ + + + + + + + + + +
+

+ <%= link_to h(forum.name), forum_path(forum) %> +

+
+

+ <%= textAreailizable forum.description%> +

+
+

+ <%= authoring forum.created_at, forum.creator %> +

+
+
- -
<%= link_to (forum.memo_count), forum_path(forum) %><%= link_to (forum.topic_count), forum_path(forum) %>
回答帖子
+ + + + + + + + + +
+ <%= link_to (forum.memo_count), forum_path(forum) %> + + <%= link_to (forum.topic_count), forum_path(forum) %> +
回答帖子
+
<% end %> - + <% else %> <% end %> \ No newline at end of file diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index fa6e74ccd..18ac7f752 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -7,11 +7,15 @@ - + - - + +
公共贴吧 <%= l(:label_user_location) %> : + + <%= l(:label_user_location) %> : + + - <% if User.current.logged? %> - <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> - <% end %> + <% if User.current.logged? %> + <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> + <% end %>
<%= link_to request.host()+"/forums", forums_path %> <%= link_to l(:field_homepage), home_path %> > <%= link_to "公共贴吧", forums_path %> + + <%= link_to request.host()+"/forums", forums_path %> + + + <%= link_to l(:field_homepage), home_path %> > + <%= link_to "公共贴吧", forums_path %> +
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 642cf5b15..85fa8093a 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,16 +1,25 @@
-

<%=l(:label_memo_new)%>

+

+ <%=l(:label_memo_new)%> +

<% if User.current.logged? %> <%= labelled_form_for(@memo, :url => create_memo_forum_path(@forum), :html => {:multipart => true} ) do |f| %>
-

<%= f.text_field :subject, :required => true%>

-

<%= f.text_area :content, :required => true, :id => 'editor02' %>

- -

(<%= l(:label_memos_max_length) %>)

- <%= l(:label_attachment_plural) %>
- <%= render :partial => 'attachments/form', :locals => {:container => @memo} %> + <%= f.text_field :subject, :required => true, :maxlength => 50%> +

+

+ <%= f.text_area :content, :required => true, :id => 'editor02' %> +

+ +

+ (<%= l(:label_memos_max_length) %>) +

+

+ <%= l(:label_attachment_plural) %> +
+ <%= render :partial => 'attachments/form', :locals => {:container => @memo} %>

<%= f.submit :value => l(:label_memo_create) %> <%= link_to l(:button_cancel), "#", :onclick => '$("#add-memo").hide(); return false;' %> diff --git a/app/views/homework_attach/_addjour.html.erb b/app/views/homework_attach/_addjour.html.erb index cbc189ef5..5b2889b57 100644 --- a/app/views/homework_attach/_addjour.html.erb +++ b/app/views/homework_attach/_addjour.html.erb @@ -69,7 +69,9 @@ <% if User.current.logged? %> <%= f.text_area 'user_message', :rows => 3, :cols => 65, - :style => "resize: none;", :class => 'noline', :placeholder => l(:text_caracters_maximum,:count=>250)%> + :style => "resize: none;", :class => 'noline', :placeholder => l(:text_caracters_maximum,:count=>250), + :maxlength => 250 + %> <%= f.text_field :reference_user_id, :style=>"display:none"%>
<%= l(:label_submit_comments) %> diff --git a/app/views/homework_attach/_homeworks_list.html.erb b/app/views/homework_attach/_homeworks_list.html.erb index c778588f7..c40004d02 100644 --- a/app/views/homework_attach/_homeworks_list.html.erb +++ b/app/views/homework_attach/_homeworks_list.html.erb @@ -35,13 +35,13 @@
  • 您还没交作业,请创建作业!
  • - <% if @bid.comment_status == 0 %> + <% if @bid.comment_status == 0 || @bid.comment_status == 1%>
  • <%= link_to "提交作业", new_exercise_book_path(@bid), :style => "width:80px; margin:20px 0 0 350px;" %>
  • <% else %> -
  • +
  • 提交作业
  • <% end %> diff --git a/app/views/homework_attach/_show.html.erb b/app/views/homework_attach/_show.html.erb index c0b397483..bce3e4d03 100644 --- a/app/views/homework_attach/_show.html.erb +++ b/app/views/homework_attach/_show.html.erb @@ -1,6 +1,42 @@ <% reply_allow = JournalsForMessage.create_by_user? User.current %> + - +
    @@ -176,7 +223,7 @@ <% unless @user.user_extensions.nil? %> - <% unless @user.user_extensions.identity == 2 %> + <% if @user.user_extensions.identity == 0 || @user.user_extensions.identity == 1 %> <%= l(:field_occupation) %>: <% unless @user.user_extensions.school.nil? %> @@ -184,38 +231,66 @@ <% end %> - <% end %> + <% elsif @user.user_extensions.identity == 3 %> + + <%= l(:field_occupation) %>: + + <%= @user.user_extensions.occupation %> + + + <% elsif @user.user_extensions.identity == 2 %> + + <%= l(:label_company_name) %>: + + <%= @user.firstname %> + + + <% end %> - <%= l(:label_location) %>:<%= @user.user_extensions.location %><%= @user.user_extensions.location_city %> + <%= l(:label_location) %>:<%= @user.user_extensions.location %><%= @user.user_extensions.location_city %> <% if @user.user_extensions.identity == 0 %> - - <%= l(:label_technical_title) %>: + + <%= l(:label_technical_title) %>: - - <%= @user.user_extensions.technical_title %> + + <% end %> - <% if( (@user.user_extensions.identity == 1) && (is_watching?(@user) ) )%> + <% if @user.user_extensions.identity == 1 %> + <% if(is_watching?(@user) ) %> - - <%= l(:label_bidding_user_studentcode)%>: + + <%= l(:label_bidding_user_studentcode)%>: <%= @user.user_extensions.student_id %> - <% end %> - <% else%> + <% else %> + + + <%= l(:label_identity)%>: + + + <%= l(:label_account_student) %> + + + + <% end %> + <% elsif @user.user_extensions.identity == 3 %> - <%= l(:field_occupation) %>: + + <%= l(:label_identity)%>: + + + <%= l(:label_account_developer) %> + - - <%= l(:label_location) %>: - - <% end %> + <% end %> + <% end %>
    diff --git a/app/views/memos/_form.html.erb b/app/views/memos/_form.html.erb index 41ea73fcd..961e54ded 100644 --- a/app/views/memos/_form.html.erb +++ b/app/views/memos/_form.html.erb @@ -1,3 +1,3 @@ <%= error_messages_for 'bid' %>

    <%= f.text_field :content, :required => true, :size => 60, :style => "width:150px;" %>

    -

    <%= hidden_field_tag 'subject', ||=@memo.subject %> \ No newline at end of file +

    <%= hidden_field_tag 'subject'||=@memo.subject %> \ No newline at end of file diff --git a/app/views/memos/_reply_box.html.erb b/app/views/memos/_reply_box.html.erb index e3346ee32..938952c32 100644 --- a/app/views/memos/_reply_box.html.erb +++ b/app/views/memos/_reply_box.html.erb @@ -1,5 +1,5 @@ <%= form_for(@memo_new, url: forum_memos_path, :html => {:multipart => true}) do |f| %> - <%= f.hidden_field :subject, :required => true, value: "RE: "+@memo.subject %> + <%= f.hidden_field :subject, :required => true, value: @memo.subject %> <%= f.hidden_field :forum_id, :required => true, value: @memo.forum_id %> <%= f.hidden_field :parent_id, :required => true, value: @memo.id %>

    @@ -7,11 +7,12 @@ <%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %> <%= label_tag(l(:label_reply_plural)) %>: - <%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'editor01', :value => @content %>

    - + <%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'editor01', :value => @content %> -

    <%= l(:label_attachment_plural) %>
    - <%= render :partial => 'attachments/form' %> +

    + <%= l(:label_attachment_plural) %> +
    + <%= render :partial => 'attachments/form' %>

    <%= f.submit value: l(:label_reply_plural), class: "replies" %> <% end %> \ No newline at end of file diff --git a/app/views/memos/edit.html.erb b/app/views/memos/edit.html.erb index ded3a1b12..09e4262fe 100644 --- a/app/views/memos/edit.html.erb +++ b/app/views/memos/edit.html.erb @@ -4,30 +4,43 @@ <%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo)) do |f| %> <% if @memo.errors.any? %>
    -

    <%= pluralize(@memo.errors.count, "error") %> prohibited this memo from being saved:

    +

    + <%= pluralize(@memo.errors.count, "error") %> + prohibited this memo from being saved: +

      <% @memo.errors.full_messages.each do |msg| %> -
    • <%= msg %>
    • +
    • + <%= msg %> +
    • <% end %>
    <% end %>
    -

    <%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying%>

    - <% unless @replying %> - <% if @memo.safe_attribute? 'sticky' %> - <%= f.check_box :sticky %> <%= label_tag 'memo_sticky', l(:label_board_sticky) %> - <% end %> - <% if @memo.safe_attribute? 'lock' %> - <%= f.check_box :lock %> <%= label_tag 'memo_locked', l(:label_board_locked) %> - <% end %> - <% end %> + <%= f.text_field :subject, :required => true, :size => 96 ,:readonly => @replying, :maxlength => 50%> +

    + <% if User.current.admin?%> +

    + <% unless @replying %> + <% if @memo.safe_attribute? 'sticky' %> + <%= f.check_box :sticky %> + <%= label_tag 'memo_sticky', l(:label_board_sticky) %> + <% end %> + <% if @memo.safe_attribute? 'lock' %> + <%= f.check_box :lock %> <%= label_tag 'memo_locked', l(:label_board_locked) %> + <% end %> + <% end %> +

    + <% end %> +

    + <%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>

    -

    <%= f.text_area :content, :required => true, :size => 80, id: 'editor01' %>

    - <%= l(:label_attachment_plural) %>
    + <%= l(:label_attachment_plural) %> +
    <%= render :partial => 'attachments/form', :locals => {:container => @memo} %>


    diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 017a9a03c..5222b466f 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -1,3 +1,9 @@ +
    <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> @@ -111,28 +117,34 @@

    - +
    - - +
    <%= link_to image_tag(url_to_avatar(reply.author), :class => "avatar"), user_path(reply.author) %> -
    <%=h sanitize(reply.content.html_safe) %>
    +
    +
    + <%=h sanitize(reply.content.html_safe) %> +

    <% if reply.attachments.any?%> - <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> - <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> + <% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %> + <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %> <% end %>

    <%= authoring reply.created_at, reply.author %> + <%= authoring reply.created_at, reply.author %> +
    <% end %> - +
    <% if User.current.login? %> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 40094b162..f5c2a4211 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -106,7 +106,11 @@ <%= authoring @topic.created_on, @topic.author %>
    - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% else %> + <%= link_to l(:button_reply), signin_path %> + <% end %>
    diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index 98a1a5767..b0a593180 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -111,7 +111,11 @@ <%= authoring @topic.created_on, @topic.author %>
    - <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% if User.current.logged? %> + <%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %> + <% else %> + <%= link_to l(:button_reply), signin_path %> + <% end %>
    diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 38f1e3b9f..04793a02e 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -3,11 +3,53 @@ @nav_dispaly_main_project_label = 1 @nav_dispaly_main_contest_label = 1 %> <% @nav_dispaly_forum_label = 1%> + @@ -43,6 +85,7 @@ <%= labelled_form_for :user, @user, :url => {:action => "account"}, :html => {:id => 'my_account_form', + :method => :post} do |f| %>