添加首页定制,设置是否显示"我的课程"功能

This commit is contained in:
z9hang 2014-07-28 10:37:22 +08:00
parent a1e06991d5
commit 8871652e01
7 changed files with 40 additions and 23 deletions

View File

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

View File

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

View File

@ -27,24 +27,28 @@
<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;" %>
</p>
<!-- <p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<#%= l(:label_site_title) %>:</label>
<#%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p> -->
<p style="margin-left:60px;padding-right: 20px;">
<label for='title'>&nbsp;&nbsp;&nbsp;<%= l(:label_show_course) %>:</label>
<select name="show_course" id="show_course" style="font-size:small;width:497px;margin-left:10px;display: inline">
<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;">
<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 'first_page', 'description', :value => @first_page.description,:cols => 80, :rows => 15, :class => 'wiki-edit' %>
<%= wikitoolbar_for 'first_page_description' %>
</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 %>
<% end %>

View File

@ -40,8 +40,10 @@
<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 User.current.user_extensions && [UserExtensions::TEACHER, UserExtensions::STUDENT].include?(User.current.user_extensions.identity) -%>
<% 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} %>
<ul class="course_sub_menu">
<% User.current.courses.each do |course| %>
@ -51,7 +53,9 @@
<% end %>
</ul>
</li>
<% 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} %>
<% if hasCourse %>

View File

@ -579,6 +579,7 @@ zh:
label_sort_type: 热门项目排序方式
label_contest_notification_title: 竞赛通知标题
label_contest_notification_content: 竞赛通知内容
label_show_course: 显示课程
#by young
label_requirement: 需求
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.
ActiveRecord::Schema.define(:version => 20140725062302) do
ActiveRecord::Schema.define(:version => 20140728014933) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -425,6 +425,7 @@ ActiveRecord::Schema.define(:version => 20140725062302) do
t.integer "sort_type"
t.integer "image_width", :default => 107
t.integer "image_height", :default => 63
t.integer "show_course", :default => 1
end
create_table "forums", :force => true do |t|
@ -845,18 +846,18 @@ ActiveRecord::Schema.define(:version => 20140725062302) 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"