diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index e9ec192f0..934f79cf7 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -28,25 +28,25 @@
mysql
com.mysql.jdbc.Driver
- jdbc:mysql://127.0.0.1/trustie2
+ jdbc:mysql://127.0.0.1/0604new
root
- df9bdf98df99df9edf9fdf9c
+ df9bdf98df99df9e
mysql
com.mysql.jdbc.Driver
- jdbc:mysql://127.0.0.1/trustie2
+ jdbc:mysql://127.0.0.1/20161227data
root
- df9bdf98df99df9edf9fdf9c
+ df9bdf98df99df9e
mysql
com.mysql.jdbc.Driver
- jdbc:mysql://127.0.0.1/trustie2
+ jdbc:mysql://127.0.0.1/0623newblank
root
- df9bdf98df99df9edf9fdf9c
+ df9bdf98df99df9e
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 468f3f8f4..e0cbc2524 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -45,8 +45,8 @@ class ApplicationController < ActionController::Base
before_filter :find_first_page
before_filter :find_web_footer
- before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization, :check_authentication
- before_filter :user_agent
+ before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
+ before_filter :user_agent
rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
rescue_from ::Unauthorized, :with => :deny_access
@@ -61,18 +61,18 @@ class ApplicationController < ActionController::Base
end
# 判断用户是否认证
- def check_authentication
- # return true
- if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载
- return true
- end
- authentication = ApplyAction.where(:user_id => User.current.id, :status => 1).first
- user_identity = User.current.try(:user_extensions).try(:identity)
- if user_identity.blank? || authentication.blank?
- redirect_to my_account_path
- return
- end
- end
+ # def check_authentication
+ # # return true
+ # if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载
+ # return true
+ # end
+ # authentication = ApplyAction.where(:user_id => User.current.id, :status => 1).first
+ # user_identity = User.current.try(:user_extensions).try(:identity)
+ # if user_identity.blank? || authentication.blank?
+ # redirect_to my_account_path
+ # return
+ # end
+ # end
def session_expiration
if session[:user_id]
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index d01774024..222138049 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -14,6 +14,7 @@ class CoursesController < ApplicationController
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
skip_before_filter :verify_authenticity_token, :only => [:update_position]
+ before_filter :check_authentication, :except => [:update_position]
menu_item :overview
menu_item :feedback, :only => :feedback
menu_item :homework, :only => :homework
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 24223c25d..ed646354c 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -8,6 +8,7 @@ class ForumsController < ApplicationController
before_filter :authenticate_user_edit, :only => [:edit, :update]
before_filter :authenticate_user_destroy, :only => [:destroy]
before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit]
+ before_filter :check_authentication
helper :sort
include SortHelper
diff --git a/app/controllers/myshixuns_controller.rb b/app/controllers/myshixuns_controller.rb
index d76494716..42d0416c1 100644
--- a/app/controllers/myshixuns_controller.rb
+++ b/app/controllers/myshixuns_controller.rb
@@ -3,6 +3,7 @@ class MyshixunsController < ApplicationController
layout 'base_myshixun'
skip_before_filter :verify_authenticity_token, :only => [:training_task_status]
before_filter :require_login, :except => [:training_task_status]
+ before_filter :check_authentication, :except => [:training_task_status]
before_filter :find_myshixun, :only => [:show, :myshixun_reset]
include ApplicationHelper
diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb
index 505e73699..8fc561502 100644
--- a/app/controllers/shixuns_controller.rb
+++ b/app/controllers/shixuns_controller.rb
@@ -3,6 +3,7 @@
class ShixunsController < ApplicationController
layout 'base_shixun'
before_filter :require_login
+ before_filter :check_authentication
before_filter :find_shixun, :except => [ :index, :new, :create, :index, :search ]
before_filter :shixun_view_allow, :only => [:show]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators]
diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb
index 7451a893c..23ad61f92 100644
--- a/app/controllers/syllabuses_controller.rb
+++ b/app/controllers/syllabuses_controller.rb
@@ -7,6 +7,7 @@ class SyllabusesController < ApplicationController
include SyllabusesHelper
include UsersHelper
before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus, :syllabus_resources, :syllabus_homeworks]
+ before_filter :check_authentication
before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :edit_syllabus_title, :update_base_info, :delete_syllabus,
:delete_des, :members, :update_des, :edit_ref, :update_ref, :add_sy_member_alert, :search_not_sy_member, :syllabus_resources, :syllabus_homeworks,
:send_homeworks_to_course, :choose_user_course, :send_resources_to_course, :send_r_and_h_to_course]
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 33487ddde..d7e4af7ab 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -35,6 +35,8 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
+ before_filter :check_authentication
+
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :unsolved_issues_list, :unfinished_homework_list, :user_manage_homeworks,
:unfinished_poll_list, :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :update_message_viewed,
:anonymous_evaluation_list,:unfinished_test_list, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :user_receive_homeworks,
@@ -665,14 +667,13 @@ class UsersController < ApplicationController
@shixuns = paginateHelper @shixuns, @limit
# 我参入的
- id = []
ids = Shixun.find_by_sql("select id from shixun_members where role=2 and user_id=#{@user.id}")
ids2 = Shixun.find_by_sql("select id from shixuns where id in (select shixun_id from myshixuns where user_id = #{@user.id})")
ids = ids.map{|shixun| shixun.id} unless ids.blank?
ids2 = ids2.map{|shixun| shixun.id} unless ids2.blank?
id = ids + ids2
id = id.uniq
- @join_shixuns = Shixun.where(:shixun_id => id)
+ @join_shixuns = Shixun.where(:id => id)
# @join_shixuns_count = @join_shixuns.count
# @join_shixuns_pages = Paginator.new @join_shixuns_count, @limit, params['page'] || 1
# @join_shixuns_offset ||= @join_shixuns_pages.offset
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 02ed45619..4b1f10bb9 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -33,6 +33,21 @@ module ApplicationHelper
extend Forwardable
def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter
+ # 判断用户是否认证
+ def check_authentication
+ # return true
+ # if params[:action] == "on_search" || params[:action] == "apply_trail" # 之所以这样处理是为了避开account页面ajax加载
+ # return true
+ # end
+ authentication = ApplyAction.where(:user_id => User.current.id, :status => 1).first
+ user_identity = User.current.try(:user_extensions).try(:identity)
+ if user_identity.blank? || authentication.blank?
+ redirect_to my_account_path
+ return
+ end
+ end
+
+
# 积分表中建立记录行为,有过奖励则不重复奖励
def reward_grade(user, container_id, container_type, score)
grade = Grade.where(:user_id => user.id, :container_id => container_id, :container_type => container_type).first
diff --git a/app/views/shixuns/_shixun_top.html.erb b/app/views/shixuns/_shixun_top.html.erb
index f0cbde564..01f23f459 100644
--- a/app/views/shixuns/_shixun_top.html.erb
+++ b/app/views/shixuns/_shixun_top.html.erb
@@ -6,8 +6,8 @@
/
<% if allow_shixun_exec(@shixun) %>
- <% if @shixun %>
- <% if User.current.manager_of_shixun?(@shixun) %>
+ <% if User.current.manager_of_shixun?(@shixun) %>
+ <% if @shixun.status == 1 %>
<%= link_to "重新发布", publish_shixun_path(@shixun, :type => "retry"), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :remote => true %>
<% else %>
<%= link_to "发布实训", publish_shixun_path(@shixun), :class => "fr shixun-task-btn task-btn-orange mr15", :id => "challenge_begin", :remote => true %>
diff --git a/app/views/welcome/_one_btn_mask_pop.html.erb b/app/views/welcome/_one_btn_mask_pop.html.erb
index 7532e416f..af9ccf6a6 100644
--- a/app/views/welcome/_one_btn_mask_pop.html.erb
+++ b/app/views/welcome/_one_btn_mask_pop.html.erb
@@ -21,7 +21,7 @@
<%#= tip2 %>
-->