From 4a9967674a5ffd761195d7fafb948cc2a69d7495 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sat, 13 Aug 2016 14:29:33 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=BC=BA=E5=88=B6=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E8=B5=84=E6=96=99=EF=BC=8C=E5=9C=A8=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8D=95=E4=BD=8D=E6=97=B6=E7=BB=99=E5=87=BA=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=80=9A=E7=9F=A5=202.=20=E5=8D=95=E4=BD=8D=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E7=94=B3=E8=AF=B7=E6=8F=90=E7=A4=BA=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=203.=20=E7=94=B3=E8=AF=B7=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E7=9A=84=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E4=BA=BA=E5=A4=B4=E5=83=8F=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E5=88=B0=E7=94=B3=E8=AF=B7=E4=BA=BA=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 20 +- app/controllers/admin_controller.rb | 2 +- app/controllers/my_controller.rb | 15 +- app/views/layouts/_footer_show.html.erb | 43 +++ .../layouts/_logined_header_show.html.erb | 111 ++++++ app/views/layouts/new_base_user.html.erb | 2 +- app/views/layouts/new_base_user_show.html.erb | 335 ++++++++++++++++++ app/views/my/account.html.erb | 37 +- .../users/_user_message_applied.html.erb | 6 +- 9 files changed, 549 insertions(+), 22 deletions(-) create mode 100644 app/views/layouts/_footer_show.html.erb create mode 100644 app/views/layouts/_logined_header_show.html.erb create mode 100644 app/views/layouts/new_base_user_show.html.erb 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 82c827b48..62d55b01d 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/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/views/layouts/_footer_show.html.erb b/app/views/layouts/_footer_show.html.erb new file mode 100644 index 000000000..bb29956d3 --- /dev/null +++ b/app/views/layouts/_footer_show.html.erb @@ -0,0 +1,43 @@ + \ No newline at end of file diff --git a/app/views/layouts/_logined_header_show.html.erb b/app/views/layouts/_logined_header_show.html.erb new file mode 100644 index 000000000..a6721501e --- /dev/null +++ b/app/views/layouts/_logined_header_show.html.erb @@ -0,0 +1,111 @@ + + diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb index 50e788e2f..b9d4652ad 100644 --- a/app/views/layouts/new_base_user.html.erb +++ b/app/views/layouts/new_base_user.html.erb @@ -103,7 +103,7 @@
<% if User.current.logged?%> - <%=link_to image_tag(url_to_avatar(@user),width:"74", height: "74", :id=>'nh_user_tx'), my_clear_user_avatar_temp_path, :class => "user_leftinfo_img", :remote => true%> + <%=link_to image_tag(url_to_avatar(@user),width:"74", height: "74", :id => 'nh_user_tx'), my_clear_user_avatar_temp_path, :class => "user_leftinfo_img", :remote => true%> <% else %> <% end %> diff --git a/app/views/layouts/new_base_user_show.html.erb b/app/views/layouts/new_base_user_show.html.erb new file mode 100644 index 000000000..37354d8d8 --- /dev/null +++ b/app/views/layouts/new_base_user_show.html.erb @@ -0,0 +1,335 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common', 'css/structure','css/public', 'prettify','css/project','css/courses','css/popup','syllabus',:media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= javascript_include_tag "bootstrap","avatars","new_user",'attachments','prettify'%> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + <%= yield :header_tags -%> + + + + + + + + + +
+
+ +
+
+
+
+ <% if User.current.logged?%> + <%= image_tag(url_to_avatar(@user),width:"74", height: "74", :id=>'nh_user_tx')%> + <% else %> + + <% end %> + <% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %> + + <% end %> + + +
+ +
+ <% hidden_courses = Setting.find_by_name("hidden_courses") %> + <% unvisiable = hidden_courses && hidden_courses.value == "1"%> + <% if !unvisiable %> +
    +
  • + 课程 + <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(10) %> + <% all_count = @user.courses.visible.where("is_delete =?", 0).count%> +
    +
    +
      +
    +
    + <% if !courses.empty? %> + + + + <% end %> +
    +
  • + <% if is_current_user %> +
  • + 新建课程 +
  • +
  • + 新建班级 +
  • +
  • + 加入班级 +
  • + <% if @user == User.current %> +
  • + 我的作业 +
  • + <% end %> + <% end %> +
+ <% end %> + +
    +
  • + 项目 + <% all_count = @user.projects.visible.count%> + <% projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(10)%> +
    +
    +
      +
    +
    + <% if !projects.empty? %> + + + + <% end %> +
    +
  • + <% if is_current_user %> +
  • + 新建项目 +
  • +
  • + 加入项目 +
  • + + + + <% end %> +
+ +
+ +
访问计数 <%= @user.visits.to_i %> (自2016年5月)
+
+
+ <%= yield %> +
+
+ <%= render :partial => 'layouts/new_feedback' %> +
+
+<%= render :partial => 'layouts/footer_show' %> +
+ + + + + + + diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb index 5c8e13e3f..71694da60 100644 --- a/app/views/my/account.html.erb +++ b/app/views/my/account.html.erb @@ -1,4 +1,15 @@ - + <% if @force %> + <% message = AppliedMessage.where(:status => 3, :user_id => User.current.id, :viewed => 0).first %> + <% unless message.nil? %> +
+
  消息:  您添加新的单位“<%= message.name %>”的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!
+ <% message.update_attribute(:viewed, true)%> +
+ <% end %> +
+
  提示:  您尚未完善您的基本资料,完善后可使用更多功能
+
+ <% end %>
    @@ -29,9 +40,12 @@
  •