课程、竞赛首页定制

超级管理员账户中首页定制界面优化
GitlabVersion
z9hang 11 years ago
parent b4dd8409eb
commit 3dfcc90574

@ -238,9 +238,9 @@ class AdminController < ApplicationController
#首页定制 #首页定制
def first_page_made def first_page_made
if request.get? if request.get?
@first_page = FirstPage.all.first @first_page = FirstPage.where("page_type = 'project'").first
elsif request.post? elsif request.post?
@first_page = FirstPage.all.first @first_page = FirstPage.where("page_type = 'project'").first
@first_page.web_title = params[:web_title] @first_page.web_title = params[:web_title]
@first_page.description = params[:description] @first_page.description = params[:description]
@first_page.title = params[:title] @first_page.title = params[:title]
@ -262,6 +262,68 @@ class AdminController < ApplicationController
end end
end end
end end
end
def course_page_made
if request.get?
@course_page = FirstPage.where("page_type = 'course'").first
@first_page = FirstPage.where("page_type = 'project'").first
elsif request.post?
@first_page = FirstPage.where("page_type = 'project'").first
@course_page = FirstPage.where("page_type = 'course'").first
@first_page.web_title = params[:web_title]
@course_page.title = params[:course_title]
@course_page.description = params[:course_description]
if @first_page.save && @course_page.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to admin_course_page_made_path
}
format.api { render_api_ok }
end
else
respond_to do |format|
format.html {
course_page_made
render :action => 'course_page_made'
}
format.api { render_validation_errors(@first_page) }
format.api { render_validation_errors(@course_page) }
end
end
end
end
def contest_page_made
if request.get?
@contest_page = FirstPage.where("page_type = 'contest'").first
@first_page = FirstPage.where("page_type = 'project'").first
elsif request.post?
@first_page = FirstPage.where("page_type = 'project'").first
@contest_page = FirstPage.where("page_type = 'contest'").first
@first_page.web_title = params[:web_title]
@contest_page.title = params[:contest_title]
@contest_page.description = params[:contest_description]
if @first_page.save && @contest_page.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to admin_contest_page_made_path
}
format.api { render_api_ok }
end end
else
respond_to do |format|
format.html {
contest_page_made
render :action => 'contest_page_made'
}
format.api { render_validation_errors(@first_page) }
format.api { render_validation_errors(@contest_page) }
end
end
end
end
end end

@ -16,12 +16,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WelcomeController < ApplicationController class WelcomeController < ApplicationController
include ApplicationHelper
caches_action :robots caches_action :robots
# before_filter :fake, :only => [:index, :course] # before_filter :fake, :only => [:index, :course]
before_filter :entry_select, :only => [:index] before_filter :entry_select, :only => [:index]
def index def index
@first_page = FirstPage.all.first @first_page = FirstPage.where("page_type = 'project'").first
end end
def robots def robots
@ -30,6 +31,7 @@ class WelcomeController < ApplicationController
end end
def course def course
@course_page = FirstPage.where("page_type = 'course'").first
if params[:school_id] if params[:school_id]
@school_id = params[:school_id] @school_id = params[:school_id]
elsif User.current.logged? && User.current.user_extensions.school elsif User.current.logged? && User.current.user_extensions.school
@ -41,13 +43,24 @@ class WelcomeController < ApplicationController
def logolink() def logolink()
@course_page = FirstPage.where("page_type = 'course'").first
logo = get_avatar?(@course_page)
id = params[:school_id] id = params[:school_id]
logo_link = "" logo_link = ""
if id.nil? and User.current.user_extensions.school.nil? if id.nil? && User.current.user_extensions.school.nil?
if logo
logo_link = url_to_avatar(@course_page)
else
logo_link = '/images/transparent.png' logo_link = '/images/transparent.png'
end
else else
if id == "0" if id == "0"
if logo
logo_link = url_to_avatar(@course_page)
else
logo_link = '/images/transparent.png' logo_link = '/images/transparent.png'
end
else else
if id.nil? if id.nil?
if School.find(User.current.user_extensions.school.id).logo_link.nil? if School.find(User.current.user_extensions.school.id).logo_link.nil?
@ -66,7 +79,7 @@ class WelcomeController < ApplicationController
def contest def contest
@contest_page = FirstPage.where("page_type = 'contest'").first
end end
def search def search

@ -625,7 +625,7 @@ module ApplicationHelper
end end
def html_title(*args) def html_title(*args)
first_page = FirstPage.all.first first_page = FirstPage.where("page_type = 'project'").first
if args.empty? if args.empty?
title = @html_title || [] title = @html_title || []
title << @project.name if @project title << @project.name if @project

@ -0,0 +1,39 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} , :class => 'selected'%></li>
</ul>
</div>
<h4><%=l(:label_contest_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='contest_title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='contest_description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

@ -0,0 +1,37 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'} %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, :class => 'selected' %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
</ul>
</div>
<h4><%=l(:label_course_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %>
</div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='course_title'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_title) %>:</label>
<%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<p style="margin-left:60px;padding-right: 20px;">
<label for='course_description' style="vertical-align: top">&nbsp;&nbsp;&nbsp;<%= l(:label_site_description)%>:</label>
<%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

@ -1,16 +1,25 @@
<h3><%=l(:label_first_page_made)%></h3> <h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> <%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<div class="tabs">
<ul>
<li><%= link_to l(:label_project_first_page), {:action => 'first_page_made'}, :class => 'selected' %></li>
<li><%= link_to l(:label_course_first_page), {:action => 'course_page_made'} %></li>
<li><%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'} %></li>
</ul>
</div>
<h4><%=l(:label_project_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;"> <p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label> <label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p> </p>
<div style="margin-left: 82px;"> <div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
</div> </div>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</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_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;" %> <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
@ -19,6 +28,7 @@
<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;" %>
</p> </p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %> <%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %> <% end %>
<div> <div>

@ -0,0 +1,31 @@
<h3><%=l(:label_first_page_made)%></h3>
<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %>
<p style="margin-left:60px;padding-right: 20px;">
<label for='web_title'><%= l(:label_web_title) %>:</label>
<%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>
</p>
<h4><%=l(:label_project_first_page)%></h4>
<p style="margin-left:60px;padding-right: 20px;">
<label for='attachments_fields'>&nbsp;&nbsp;&nbsp;<%= l(:label_site_image) %>:</label>
</p>
<div style="margin-left: 82px;">
<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
</div>
<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='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;" %>
</p>
<%= submit_tag l(:button_save), :class => "small", :name => nil %>
<% end %>
<div>
</div>

@ -114,11 +114,16 @@
<div class="main-content-bar" id="main-content-bar"> <div class="main-content-bar" id="main-content-bar">
<!--文字--> <!--文字-->
<div style="float: left"> <div style="float: left">
<% if get_avatar?(@contest_page) %>
<%= image_tag(url_to_avatar(@contest_page), size: "75x75") %>
<% else %>
<%= image_tag '/images/transparent.png', size: "75x75" %> <%= image_tag '/images/transparent.png', size: "75x75" %>
<% end %>
</div> </div>
<div class="welcome_left" id="welcome_left"> <div class="welcome_left" id="welcome_left">
<% unless @contest_page.nil? %>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %>&nbsp;<%= l(:label_welcome_trustie_contest) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_contest_description) %></span> <span class="font_welcome_trustie"><%= @contest_page.title %></span> <span class="font_welcome_tdescription">, <%= @contest_page.description %></span>
<% end %>
</div> </div>
<!--搜索框--> <!--搜索框-->

@ -51,12 +51,15 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> </span> <% end %> </span>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span> <% unless @course_page.nil? %>
<span class="font_welcome_trustie"><%= @course_page.title %> </span>
<% if @school_id.nil? and User.current.user_extensions.school.nil? %> <% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= @course_page.description %></span>
<% else %> <% else %>
<% if @school_id == "0" %> <% if @school_id == "0" %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= @course_page.description %></span>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

@ -42,7 +42,9 @@
</div> </div>
<div class="welcome_left" id="welcome_left"> <div class="welcome_left" id="welcome_left">
<% unless @first_page.nil? %>
<span class="font_welcome_trustie"><%= @first_page.title %></span> <span class="font_welcome_tdescription">, <%= @first_page.description %></span> <span class="font_welcome_trustie"><%= @first_page.title %></span> <span class="font_welcome_tdescription">, <%= @first_page.description %></span>
<% end %>
</div> </div>
<div class="search-bar" id="search-bar"> <div class="search-bar" id="search-bar">
<%= render :partial => "search_project", :locals => {:project_type => 0}%> <%= render :partial => "search_project", :locals => {:project_type => 0}%>

@ -516,6 +516,9 @@ zh:
label_project_plural: 项目列表 label_project_plural: 项目列表
label_project_score: 项目评分 label_project_score: 项目评分
label_first_page_made: 首页定制 label_first_page_made: 首页定制
label_project_first_page: 项目托管平台首页
label_course_first_page: 课程实践平台首页
label_contest_first_page: 竞赛实战平台首页
label_x_projects: label_x_projects:
zero: 无项目 zero: 无项目
one: 1 个项目 one: 1 个项目

@ -559,6 +559,8 @@ RedmineApp::Application.routes.draw do
match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
match 'admin/users', :controller => 'admin', :action => 'users', :via => :get match 'admin/users', :controller => 'admin', :action => 'users', :via => :get
match 'admin/first_page_made',:controller => 'admin',:action => 'first_page_made',:via => [:get,:post] match 'admin/first_page_made',:controller => 'admin',:action => 'first_page_made',:via => [:get,:post]
match 'admin/course_page_made',:controller => 'admin',:action => 'course_page_made',:via => [:get,:post]
match 'admin/contest_page_made',:controller => 'admin',:action => 'contest_page_made',:via => [:get,:post]
match 'admin/search', :controller => 'admin', :action => 'search', :via => [:get, :post] match 'admin/search', :controller => 'admin', :action => 'search', :via => [:get, :post]
match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
match 'admin/info', :controller => 'admin', :action => 'info', :via => :get match 'admin/info', :controller => 'admin', :action => 'info', :via => :get

@ -0,0 +1,9 @@
class AddCloumnToFirstPage < ActiveRecord::Migration
def change
add_column :first_pages,:type,:string
fr = FirstPage.all.first
fr.type = "project"
fr.save
end
end

@ -0,0 +1,5 @@
class AltColumnName < ActiveRecord::Migration
def change
rename_column :first_pages,:type,:page_type
end
end

@ -0,0 +1,17 @@
# -*coding:utf-8 -*-
class AddContestAndCourseFirstPage < ActiveRecord::Migration
def change
fp = FirstPage.new
fp.web_title = ""
fp.title = "Trustie在线课程实践平台"
fp.description = "面向中国高校教师与大学生,提供社交化的课程管理、资源共享、合作实验、协同研究。"
fp.page_type = "course"
fp.save
fp1 = FirstPage.new
fp1.web_title = ""
fp1.title = "Trustie在线竞赛实战平台"
fp1.description = "面向中国大学生与编程爱好者,提供社交化的竞赛管理、应用管理、代码托管、合作交流。"
fp1.page_type = "contest"
fp1.save
end
end

@ -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 => 20140710071720) do ActiveRecord::Schema.define(:version => 20140711012924) 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
@ -412,6 +412,7 @@ ActiveRecord::Schema.define(:version => 20140710071720) do
t.string "description" t.string "description"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "page_type"
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|

Loading…
Cancel
Save