首页定制,是否显示课程,竞赛
This commit is contained in:
parent
847bb35906
commit
03b212e363
|
@ -154,6 +154,7 @@ class AdminController < ApplicationController
|
|||
@first_page.image_height = params[:image_height]
|
||||
@first_page.sort_type = params[:sort_type]
|
||||
@first_page.show_course = params[:show_course]
|
||||
@first_page.show_contest = params[:show_contest]
|
||||
if @first_page.save
|
||||
respond_to do |format|
|
||||
flash[:notice] = l(:notice_successful_update)
|
||||
|
|
|
@ -41,6 +41,7 @@ class ApplicationController < ActionController::Base
|
|||
cookies.delete(autologin_cookie_name)
|
||||
end
|
||||
|
||||
before_filter :find_first_page
|
||||
before_filter :session_expiration, :user_setup, :check_if_login_required, :set_localization
|
||||
before_filter :user_agent
|
||||
|
||||
|
@ -720,4 +721,11 @@ class ApplicationController < ActionController::Base
|
|||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
|
||||
#查找首页相关信息
|
||||
def find_first_page
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@show_course = @first_page.show_course
|
||||
@show_contest = @first_page.show_contest
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7,6 +7,9 @@ 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
|
||||
|
||||
before_filter :can_show_course,only: []
|
||||
before_filter :can_show_contest,only: []
|
||||
#Ended by young
|
||||
before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
|
||||
:show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
|
||||
|
@ -983,5 +986,21 @@ class BidsController < ApplicationController
|
|||
render_403 unless currentUser.member_of_course?(@bid.courses.first)
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
#验证是否显示竞赛
|
||||
def can_show_contest
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_contest == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ class ContestsController < ApplicationController
|
|||
menu_item :application, :only => :show_softapplication
|
||||
menu_item :attendingcontests, :only => :show_attendingcontest
|
||||
menu_item :contestnotifications, :only => :index
|
||||
|
||||
before_filter :can_show_contest,except: []
|
||||
before_filter :find_contest, :only => [:show_contest, :show_project, :show_softapplication, :show_attendingcontest, :index, :set_reward_project, :set_reward_softapplication, :create,:destroy,:more,:back,:add,:add_softapplication,:new,:show_results, :set_reward,
|
||||
:show_contest_project, :show_contest_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
|
||||
|
||||
|
@ -645,5 +647,13 @@ end
|
|||
render_404
|
||||
end
|
||||
|
||||
#验证是否显示竞赛
|
||||
def can_show_contest
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_contest == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class CoursesController < ApplicationController
|
|||
menu_item l(:label_sort_by_active), :only => :index
|
||||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
||||
before_filter :can_show_course, :except => []
|
||||
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
|
||||
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||
|
@ -711,7 +712,13 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ class HomeworkAttachController < ApplicationController
|
|||
layout "course_base"
|
||||
include CoursesHelper
|
||||
###############################
|
||||
before_filter :can_show_course,except: []
|
||||
#判断当前角色权限时需先找到当前操作的project
|
||||
before_filter :find_course_by_bid_id, :only => [:new]
|
||||
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
||||
|
@ -352,5 +353,13 @@ class HomeworkAttachController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class UsersController < ApplicationController
|
|||
|
||||
#Ended by young
|
||||
|
||||
|
||||
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
|
||||
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_bids, :watch_contests, :info,
|
||||
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index,
|
||||
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
|
||||
|
@ -796,4 +796,12 @@ class UsersController < ApplicationController
|
|||
document_num(@user)
|
||||
|
||||
end
|
||||
|
||||
#验证是否显示课程
|
||||
def can_show_course
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
if @first_page.show_course == 2
|
||||
render_404
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
class WelcomeController < ApplicationController
|
||||
include ApplicationHelper
|
||||
include WelcomeHelper
|
||||
|
||||
caches_action :robots
|
||||
# before_filter :fake, :only => [:index, :course]
|
||||
before_filter :entry_select, :only => [:index]
|
||||
|
||||
def index
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
@show_course = @first_page.show_course
|
||||
#@show_course = @first_page.show_course
|
||||
if @first_page.nil? || @first_page.sort_type.nil?
|
||||
@projects = find_miracle_project(10, 3,"grade desc")
|
||||
else
|
||||
|
@ -147,16 +148,27 @@ class WelcomeController < ApplicationController
|
|||
private
|
||||
# 判断网站的入口,是课程 course 则跳过index去渲染 course 方法
|
||||
def entry_select
|
||||
@first_page = FirstPage.where("page_type = 'project'").first
|
||||
url = request.original_url
|
||||
if url.include?("course.trustie.net")
|
||||
course
|
||||
render :course
|
||||
if url.include?(Setting.host_course)
|
||||
if @first_page.show_course == 1
|
||||
course
|
||||
render :course
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?("contest.trustie.net")
|
||||
contest
|
||||
render :contest
|
||||
elsif url.include?(Setting.host_contest)
|
||||
if @first_page.show_contest == 1
|
||||
contest
|
||||
render :contest
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
||||
return 0
|
||||
elsif url.include?("user.trustie.net")
|
||||
elsif url.include?(Setting.host_user)
|
||||
redirect_to(:controller => "users", :action => "index")
|
||||
end
|
||||
|
||||
|
|
|
@ -1738,18 +1738,18 @@ module ApplicationHelper
|
|||
|
||||
#@nav_dispaly_project_label
|
||||
nav_list = Array.new
|
||||
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label
|
||||
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label
|
||||
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label
|
||||
nav_list.push(school_all_school_link) if @nav_dispaly_course_all_label && @show_course == 1
|
||||
nav_list.push(course_all_course_link) if @nav_dispaly_course_all_label && @show_course == 1
|
||||
nav_list.push(course_teacher_all_link) if @nav_dispaly_teacher_all_label && @show_course == 1
|
||||
|
||||
nav_list.push(main_project_link) if @nav_dispaly_main_project_label
|
||||
nav_list.push(main_course_link) if @nav_dispaly_main_course_label
|
||||
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label
|
||||
nav_list.push(main_course_link) if @nav_dispaly_main_course_label && @show_course == 1
|
||||
nav_list.push(main_contest_link) if @nav_dispaly_main_contest_label && @show_contest == 1
|
||||
|
||||
nav_list.push(courses_link) if @nav_dispaly_course_label
|
||||
nav_list.push(courses_link) if @nav_dispaly_course_label && @show_course == 1
|
||||
nav_list.push(projects_link) if @nav_dispaly_project_label
|
||||
nav_list.push(users_link) if @nav_dispaly_user_label
|
||||
nav_list.push(contest_link) if @nav_dispaly_contest_label
|
||||
nav_list.push(contest_link) if @nav_dispaly_contest_label && @show_contest == 1
|
||||
nav_list.push(bids_link) if @nav_dispaly_bid_label
|
||||
nav_list.push(forum_link) if @nav_dispaly_forum_label
|
||||
nav_list.push(stores_link) if @nav_dispaly_store_all_label
|
||||
|
|
|
@ -34,6 +34,13 @@
|
|||
<option value="2" <%= "selected=selected" if @first_page.show_course == 2 %>><%= l(:general_text_no) %></option>
|
||||
</select>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='title'> <%= l(:label_show_contest) %>:</label>
|
||||
<select name="show_contest" id="show_contest" style="font-size:small;width:497px;margin-left:10px;display: inline">
|
||||
<option value="1" <%= "selected=selected" if @first_page.show_contest == 1 %>><%= l(:general_text_yes) %></option>
|
||||
<option value="2" <%= "selected=selected" if @first_page.show_contest == 2 %>><%= l(:general_text_no) %></option>
|
||||
</select>
|
||||
</p>
|
||||
<p style="margin-left:60px;padding-right: 20px;">
|
||||
<label for='sort_type' style="vertical-align: top"> <%= l(:label_sort_type)%>:</label>
|
||||
<select name="sort_type" id="sort_type" style="font-size:small;width:497px;margin-left:80px;">
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li">
|
||||
<%=link_to_user(User.current)%>
|
||||
<ul class="sub_menu">
|
||||
<% if @show_course.nil? || @show_course != 2 %>
|
||||
<% if @show_course == 1 %>
|
||||
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
|
||||
<% hasCourse=true%>
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
</tr>
|
||||
<% when 'Bid' %>
|
||||
<tr>
|
||||
<% if act.reward_type ==3 %>
|
||||
<% if act.reward_type == 3 && @show_course == 1%>
|
||||
<% if e.user == User.current %>
|
||||
<td colspan="2" valign="top">
|
||||
<strong> <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong><span class="font_lighter"><%= l(:label_i_new_activity) %></span> <%= link_to format_activity_title("#{l(:label_active_homework)}##{act.id}:#{act.name}"), respond_path(e.act_id) %>
|
||||
|
@ -299,7 +299,7 @@
|
|||
</tr>
|
||||
<% when 'Contest' %>
|
||||
<tr>
|
||||
<% if e.user == User.current %>
|
||||
<% if e.user == User.current && @show_contest == 1%>
|
||||
<td colspan="2" valign="top">
|
||||
<strong><%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong> <span class="font_lighter"><%= l(:label_i_new_activity) %></span> <%= link_to format_activity_title("#{l(:label_contest)}: #{act.name}"), {:controller => 'contests', :action => 'show_contest', :id => act.id} %>
|
||||
</td>
|
||||
|
|
|
@ -582,6 +582,7 @@ zh:
|
|||
label_contest_notification_title: 竞赛通知标题
|
||||
label_contest_notification_content: 竞赛通知内容
|
||||
label_show_course: 显示课程
|
||||
label_show_contest: 显示竞赛
|
||||
#by young
|
||||
label_requirement: 需求
|
||||
label_new_course: 课程列表
|
||||
|
|
|
@ -75,6 +75,10 @@ host_course:
|
|||
default: course.trustie.net
|
||||
host_contest:
|
||||
default: contest.trustie.net
|
||||
host_user:
|
||||
default: user.trustie.net
|
||||
host_repository:
|
||||
default: repository.trustie.net
|
||||
protocol:
|
||||
default: http
|
||||
feeds_limit:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class FirstPageAddContestColumn < ActiveRecord::Migration
|
||||
def change
|
||||
add_column("first_pages","show_contest",:integer,default: 1)
|
||||
end
|
||||
end
|
23
db/schema.rb
23
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140728014933) do
|
||||
ActiveRecord::Schema.define(:version => 20140730021521) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -426,6 +426,7 @@ ActiveRecord::Schema.define(:version => 20140728014933) do
|
|||
t.integer "image_width", :default => 107
|
||||
t.integer "image_height", :default => 63
|
||||
t.integer "show_course", :default => 1
|
||||
t.integer "show_contest", :default => 1
|
||||
end
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
|
@ -846,18 +847,18 @@ ActiveRecord::Schema.define(:version => 20140728014933) do
|
|||
create_table "relative_memos", :force => true do |t|
|
||||
t.integer "osp_id"
|
||||
t.integer "parent_id"
|
||||
t.string "subject", :null => false
|
||||
t.text "content", :limit => 16777215, :null => false
|
||||
t.string "subject", :null => false
|
||||
t.text "content", :null => false
|
||||
t.integer "author_id"
|
||||
t.integer "replies_count", :default => 0
|
||||
t.integer "replies_count", :default => 0
|
||||
t.integer "last_reply_id"
|
||||
t.boolean "lock", :default => false
|
||||
t.boolean "sticky", :default => false
|
||||
t.boolean "is_quote", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "viewed_count_crawl", :default => 0
|
||||
t.integer "viewed_count_local", :default => 0
|
||||
t.boolean "lock", :default => false
|
||||
t.boolean "sticky", :default => false
|
||||
t.boolean "is_quote", :default => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "viewed_count_crawl", :default => 0
|
||||
t.integer "viewed_count_local", :default => 0
|
||||
t.string "url"
|
||||
t.string "username"
|
||||
t.string "userhomeurl"
|
||||
|
|
Loading…
Reference in New Issue