diff --git a/app/api/mobile/entities/attachment.rb b/app/api/mobile/entities/attachment.rb index 028ad633d..8200c04b2 100644 --- a/app/api/mobile/entities/attachment.rb +++ b/app/api/mobile/entities/attachment.rb @@ -23,6 +23,8 @@ module Mobile (number_to_human_size(f.filesize)).gsub("ytes", "").to_s when :coursename f.course.nil? ? "" : f.course.name + when :course_id + f.course.nil? ? 0 : f.course.id end end @@ -38,6 +40,7 @@ module Mobile attachment_expose :file_dir attachment_expose :attafile_size attachment_expose :coursename #所属班级名 + attachment_expose :course_id #所属班级名 expose :current_user_is_teacher, if: lambda { |instance, options| options[:user] } do |instance, options| current_user = options[:user] current_user_is_teacher = false diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 8187055be..731a251f2 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -26,7 +26,13 @@ class AccountController < ApplicationController if request.get? @login = params[:login] || true if User.current.logged? - redirect_to user_path(User.current) + # 判断用户基本资料是否完善,不完善讲强制完善基本资料,完善进入主页 + user = UserExtensions.where(:user_id => User.current.id).first + if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? + redirect_to my_account_path(:tip => 1) + else + redirect_to user_path(User.current) + end else render :layout => 'login' end @@ -127,7 +133,7 @@ class AccountController < ApplicationController session[:auth_source_registration] = nil self.logged_user = @user flash[:notice] = l(:notice_account_activated) - redirect_to my_account_path + redirect_to my_account_path(:tip=>1) end else us = UsersService.new @@ -144,7 +150,7 @@ class AccountController < ApplicationController if !@user.new_record? self.logged_user = @user flash[:notice] = l(:notice_account_activated) - redirect_to my_account_url + redirect_to my_account_url(:tip=>1) else redirect_to signin_path end @@ -347,9 +353,15 @@ class AccountController < ApplicationController else #by young #redirect_back_or_default my_page_path - redirect_back_or_default User.current + # 基本资料不完善的用户,将强制用户完善基本资料。 + user = UserExtensions.where(:user_id => User.current.id).first + if user.gender.nil? || user.school_id.nil? || User.current.lastname.nil? + redirect_to my_account_path(:tip => 1) + else + redirect_back_or_default User.current #redirect_to my_account_url #redirect_to User.current + end end end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 3c012fce7..25cc85ae2 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -698,7 +698,7 @@ class AdminController < ApplicationController apply_school_ids = apply_schools.empty? ? "(-1)" : "(" + apply_schools.map{|sc| sc.school_id}.join(',') + ")" if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" - @schools = School.where("id not in #{apply_school_ids} and #{School.table_name}.name like :p",:p=>search) + @schools = School.where("id not in #{apply_school_ids} and #{School.table_name}.name like :p", :p => search) #@schools = School.all else #@course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)} diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 0e48cd962..66cbf27b8 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -10,7 +10,7 @@ class AtController < ApplicationController @users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users #加上all - if @user && @users.size > 0 + if User.current.logged? && @users.size > 0 allUser = Struct.new(:id, :name).new allUser.id = @users.map{|u| u.id}.join(",") allUser.name = "all" diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 05b93d302..3aefdfd1d 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -114,9 +114,15 @@ class MyController < ApplicationController applied_message.update_attribute(:viewed, true) end + # 基本资料不完善 @force为false, 完善 @force为true + @force = false + if params[:tip] + @force = true + end + @user = User.current - lg=@user.login + lg = @user.login @pref = @user.pref diskfile = disk_filename('User', @user.id) diskfile1 = diskfile + 'temp' @@ -178,7 +184,12 @@ class MyController < ApplicationController File.delete(diskfile1) if File.exist?(diskfile1) end - render :layout=>'new_base_user' + # 基本资料不完善,无法使用其他功能,完善着可继续使用 + if @force + render :layout => 'new_base_user_show' + else + render :layout => 'new_base_user' + end end # Destroys user's account diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index da66f249b..0c0e0919e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2169,7 +2169,7 @@ module ApplicationHelper candown= User.current.member_of_course?(course) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2 elsif attachment.container.is_a?(OrgSubfield) org = attachment.container.organization - candown = User.current.member_of_org?(org) || (attachment.is_public == 1) || attachment.get_status_by_attach(User.current.id) == 2 + candown = User.current.member_of_org?(org) || ((attachment.is_public == 1 || attachment.get_status_by_attach(User.current.id) == 2) && org.allow_guest_download == true) elsif attachment.container.is_a?(OrgDocumentComment) org = attachment.container.organization candown = org.allow_guest_download || User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1) @@ -3436,3 +3436,9 @@ def course_syllabus_option user = User.current end type end + +# 获取项目动态更新时间 +def get_forge_act_message(act, type) + forge_act = ForgeActivity.where(:forge_act_id => act.id, :forge_act_type => type).first + format_time(forge_act.nil? ? act.created_on : forge_act.try(:updated_at)) +end diff --git a/app/services/projects_service.rb b/app/services/projects_service.rb index cfd6aeb2c..ca89e252a 100644 --- a/app/services/projects_service.rb +++ b/app/services/projects_service.rb @@ -338,15 +338,15 @@ class ProjectsService remark = "点击详情查看issue" case priority_id - when 1 + when "1" priority = "低" - when 2 + when "2" priority = "正常" - when 3 + when "3" priority = "高" - when 4 + when "4" priority = "紧急" - when 5 + when "5" priority = "立刻" end diff --git a/app/views/at/show.json.erb b/app/views/at/show.json.erb index 6e2a244e4..3e49496f9 100644 --- a/app/views/at/show.json.erb +++ b/app/views/at/show.json.erb @@ -1,11 +1,11 @@ [ - <% @users && @users.each_with_index do |person,index| %> - <% if index == 0 %> - {"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"} - <%= index != @users.size-1 ? ',' : '' %> - <% else %> - {"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} - <%= index != @users.size-1 ? ',' : '' %> - <% end %> - <% end %> + <% @users && @users.each_with_index do |person,index| %> + <% if index == 0 %> + {"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"} + <%= index != @users.size-1 ? ',' : '' %> + <% else %> + {"id":<%=index%>, "userid": "<%=person.id%>", "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} + <%= index != @users.size-1 ? ',' : '' %> + <% end %> + <% end %> ] diff --git a/app/views/attachments/_activity_attach.html.erb b/app/views/attachments/_activity_attach.html.erb index 3cc429185..b37c80dad 100644 --- a/app/views/attachments/_activity_attach.html.erb +++ b/app/views/attachments/_activity_attach.html.erb @@ -3,7 +3,7 @@