This commit is contained in:
nwb 2014-07-28 10:46:15 +08:00
commit f8328727cd
7 changed files with 43 additions and 33 deletions

View File

@ -153,6 +153,7 @@ class AdminController < ApplicationController
@first_page.image_width = params[:image_width] @first_page.image_width = params[:image_width]
@first_page.image_height = params[:image_height] @first_page.image_height = params[:image_height]
@first_page.sort_type = params[:sort_type] @first_page.sort_type = params[:sort_type]
@first_page.show_course = params[:show_course]
if @first_page.save if @first_page.save
respond_to do |format| respond_to do |format|
flash[:notice] = l(:notice_successful_update) flash[:notice] = l(:notice_successful_update)

View File

@ -24,6 +24,7 @@ class WelcomeController < ApplicationController
def index def index
@first_page = FirstPage.where("page_type = 'project'").first @first_page = FirstPage.where("page_type = 'project'").first
@show_course = @first_page.show_course
if @first_page.nil? || @first_page.sort_type.nil? if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"grade desc") @projects = find_miracle_project(10, 3,"grade desc")
else else

View File

@ -27,24 +27,28 @@
<label for='image_height' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_imgae_height)%>:</label> <label for='image_height' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_imgae_height)%>:</label>
<%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> <%= text_field_tag 'image_height', params[:label_imgae_height], :value => @first_page.image_height,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p> </p>
<!-- <p style="margin-left:60px;padding-right: 20px;"> <p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<#%= l(:label_site_title) %>:</label> <label for='title'>&nbsp;&nbsp;&nbsp;<%= l(:label_show_course) %>:</label>
<#%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> <select name="show_course" id="show_course" style="font-size:small;width:497px;margin-left:10px;display: inline">
</p> --> <option value="1" <%= "selected=selected" if @first_page.show_course == 1 %>><%= l(:general_text_yes) %></option>
<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='sort_type' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_sort_type)%>:</label>
<select name="sort_type" id="sort_type" style="font-size:small;width:497px;margin-left:80px;">
<option value="1" <%= "selected=selected" if @first_page.sort_type == 1 %>><%= l(:label_sort_by_active) %></option>
<option value="2" <%= "selected=selected" if @first_page.sort_type == 2 %>><%= l(:label_sort_by_influence) %></option>
<option value="0" <%= "selected=selected" if @first_page.sort_type == 0 %>><%= l(:label_sort_by_time) %></option>
</select>
</p>
<p style="margin-left:60px;padding-right: 20px;"> <p style="margin-left:60px;padding-right: 20px;">
<label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label> <label for='description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<!-- <#%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> --> <!-- <#%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> -->
<%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %> <%= text_area 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'first_page_description' %> <%= wikitoolbar_for 'first_page_description' %>
</p> </p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='sort_type' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_sort_type)%>:</label>
<select name="sort_type" id="sort_type" style="font-size:small;width:496px;margin-left:80px;">
<option value="1" <%= "selected=selected" if @first_page.sort_type == 1 %>><%= l(:label_sort_by_active) %></option>
<option value="2" <%= "selected=selected" if @first_page.sort_type == 2 %>><%= l(:label_sort_by_influence) %></option>
<option value="0" <%= "selected=selected" if @first_page.sort_type == 0 %>><%= l(:label_sort_by_time) %></option>
</select>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %> <%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %> <% end %>

View File

@ -40,8 +40,10 @@
<li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li"> <li style="padding:0 0; margin:0 0;display:inline;border-bottom: 0;" class="loggedas_li">
<%=link_to_user(User.current)%> <%=link_to_user(User.current)%>
<ul class="sub_menu"> <ul class="sub_menu">
<% if @show_course.nil? || @show_course != 2 %>
<% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%> <% if User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% hasCourse=true%> <% hasCourse=true%>
<li id="course_loggedas_li"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %> <li id="course_loggedas_li"><%=link_to l(:label_my_course), {:controller => 'users', :action => 'user_courses', id: User.current.id, host: Setting.course_domain} %>
<ul class="course_sub_menu"> <ul class="course_sub_menu">
<% User.current.courses.each do |course| %> <% User.current.courses.each do |course| %>
@ -51,7 +53,9 @@
<% end %> <% end %>
</ul> </ul>
</li> </li>
<% end -%> <% end -%>
<% end %>
<li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %> <li id="project_loggedas_li"><%= link_to l(:label_my_projects), {:controller => 'users', :action => 'user_projects', id: User.current.id, host: Setting.project_domain} %>
<% if hasCourse %> <% if hasCourse %>

View File

@ -579,6 +579,7 @@ zh:
label_sort_type: 热门项目排序方式 label_sort_type: 热门项目排序方式
label_contest_notification_title: 竞赛通知标题 label_contest_notification_title: 竞赛通知标题
label_contest_notification_content: 竞赛通知内容 label_contest_notification_content: 竞赛通知内容
label_show_course: 显示课程
#by young #by young
label_requirement: 需求 label_requirement: 需求
label_new_course: 课程列表 label_new_course: 课程列表

View File

@ -0,0 +1,5 @@
class FirstPageAddColumn < ActiveRecord::Migration
def change
add_column("first_pages","show_course",:integer,default: 1)
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140725073357) do ActiveRecord::Schema.define(:version => 20140728014933) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -425,6 +425,7 @@ ActiveRecord::Schema.define(:version => 20140725073357) do
t.integer "sort_type" t.integer "sort_type"
t.integer "image_width", :default => 107 t.integer "image_width", :default => 107
t.integer "image_height", :default => 63 t.integer "image_height", :default => 63
t.integer "show_course", :default => 1
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|
@ -438,26 +439,6 @@ ActiveRecord::Schema.define(:version => 20140725073357) do
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
end end
create_table "gitlab_projects", :force => true do |t|
t.integer "gitlab_project_id"
t.integer "project_id"
t.string "repository_url"
t.string "web_url"
t.string "localfile_url"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "gitlab_users", :force => true do |t|
t.integer "gitlab_user_id"
t.integer "user_id"
t.string "email"
t.string "password"
t.string "login", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "groups_users", :id => false, :force => true do |t| create_table "groups_users", :id => false, :force => true do |t|
t.integer "group_id", :null => false t.integer "group_id", :null => false
t.integer "user_id", :null => false t.integer "user_id", :null => false
@ -900,6 +881,19 @@ ActiveRecord::Schema.define(:version => 20140725073357) do
add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id" add_index "repositories", ["project_id"], :name => "index_repositories_on_project_id"
create_table "rich_rich_files", :force => true do |t|
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "rich_file_file_name"
t.string "rich_file_content_type"
t.integer "rich_file_file_size"
t.datetime "rich_file_updated_at"
t.string "owner_type"
t.integer "owner_id"
t.text "uri_cache"
t.string "simplified_type", :default => "file"
end
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.string "name", :limit => 30, :default => "", :null => false t.string "name", :limit => 30, :default => "", :null => false
t.integer "position", :default => 1 t.integer "position", :default => 1