diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 152fb059e..d87644e43 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -238,9 +238,9 @@ class AdminController < ApplicationController #首页定制 def first_page_made if request.get? - @first_page = FirstPage.all.first + @first_page = FirstPage.where("page_type = 'project'").first 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.description = params[:description] @first_page.title = params[:title] @@ -262,6 +262,68 @@ class AdminController < ApplicationController 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 + 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 diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 0920d2e42..03bca6162 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -16,12 +16,13 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class WelcomeController < ApplicationController + include ApplicationHelper caches_action :robots # before_filter :fake, :only => [:index, :course] before_filter :entry_select, :only => [:index] def index - @first_page = FirstPage.all.first + @first_page = FirstPage.where("page_type = 'project'").first end def robots @@ -30,6 +31,7 @@ class WelcomeController < ApplicationController end def course + @course_page = FirstPage.where("page_type = 'course'").first if params[:school_id] @school_id = params[:school_id] elsif User.current.logged? && User.current.user_extensions.school @@ -41,13 +43,24 @@ class WelcomeController < ApplicationController def logolink() + @course_page = FirstPage.where("page_type = 'course'").first + logo = get_avatar?(@course_page) id = params[:school_id] logo_link = "" - if id.nil? and User.current.user_extensions.school.nil? - logo_link = '/images/transparent.png' + if id.nil? && User.current.user_extensions.school.nil? + if logo + logo_link = url_to_avatar(@course_page) + else + logo_link = '/images/transparent.png' + end + else if id == "0" - logo_link = '/images/transparent.png' + if logo + logo_link = url_to_avatar(@course_page) + else + logo_link = '/images/transparent.png' + end else if id.nil? if School.find(User.current.user_extensions.school.id).logo_link.nil? @@ -66,7 +79,7 @@ class WelcomeController < ApplicationController def contest - + @contest_page = FirstPage.where("page_type = 'contest'").first end def search diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3f873a64d..b63381903 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -625,7 +625,7 @@ module ApplicationHelper end def html_title(*args) - first_page = FirstPage.all.first + first_page = FirstPage.where("page_type = 'project'").first if args.empty? title = @html_title || [] title << @project.name if @project diff --git a/app/views/admin/contest_page_made.html.erb b/app/views/admin/contest_page_made.html.erb new file mode 100644 index 000000000..b8a86fa4d --- /dev/null +++ b/app/views/admin/contest_page_made.html.erb @@ -0,0 +1,39 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'contest_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+ +

<%=l(:label_contest_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@contest_page} %> +
+

+ + <%= text_field_tag 'contest_title', params[:label_site_title], :value => @contest_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ +

+ + <%= text_area_tag 'contest_description',@contest_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/admin/course_page_made.html.erb b/app/views/admin/course_page_made.html.erb new file mode 100644 index 000000000..4554fb8e0 --- /dev/null +++ b/app/views/admin/course_page_made.html.erb @@ -0,0 +1,37 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'course_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+

<%=l(:label_course_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@course_page} %> +
+

+ + <%= text_field_tag 'course_title', params[:label_site_title], :value => @course_page.title,:size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

+ + <%= text_area_tag 'course_description',@course_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/admin/first_page_made.html.erb b/app/views/admin/first_page_made.html.erb index 9e863d813..a64bbb443 100644 --- a/app/views/admin/first_page_made.html.erb +++ b/app/views/admin/first_page_made.html.erb @@ -1,16 +1,25 @@

<%=l(:label_first_page_made)%>

<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+
+ +
+

<%=l(:label_project_first_page)%>

<%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %>
-

- - <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_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 @@ <%= text_area_tag 'description',@first_page.description,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %>

+ <%= submit_tag l(:button_save), :class => "small", :name => nil %> <% end %>
diff --git a/app/views/admin/project_page_made.html.erb b/app/views/admin/project_page_made.html.erb new file mode 100644 index 000000000..e338c21a9 --- /dev/null +++ b/app/views/admin/project_page_made.html.erb @@ -0,0 +1,31 @@ +

<%=l(:label_first_page_made)%>

+ +<%= form_tag(:controller => 'admin', :action => 'first_page_made') do %> +

+ + <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> +

+

<%=l(:label_project_first_page)%>

+

+ +

+
+ <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source:@first_page} %> +
+ +

+ + <%= text_field_tag 'title', params[:label_site_title], :value => @first_page.title,: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;" %> +

+ + <%= submit_tag l(:button_save), :class => "small", :name => nil %> +<% end %> +
+ + + +
\ No newline at end of file diff --git a/app/views/welcome/contest.html.erb b/app/views/welcome/contest.html.erb index c87cc13e1..c3bd120da 100644 --- a/app/views/welcome/contest.html.erb +++ b/app/views/welcome/contest.html.erb @@ -114,12 +114,17 @@
- <%= image_tag '/images/transparent.png', size: "75x75" %> + <% if get_avatar?(@contest_page) %> + <%= image_tag(url_to_avatar(@contest_page), size: "75x75") %> + <% else %> + <%= image_tag '/images/transparent.png', size: "75x75" %> + <% end %>
- - <%= l(:label_welcome_trustie) %> <%= l(:label_welcome_trustie_contest) %> , <%= l(:label_welcome_trustie_contest_description) %> -
+ <% unless @contest_page.nil? %> + <%= @contest_page.title %> , <%= @contest_page.description %> + <% end %> +
diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index cfde8fca4..f6bffe51c 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -51,14 +51,17 @@ <% end %> <% end %> <% end %> - <%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> + <% unless @course_page.nil? %> + <%= @course_page.title %> + <% if @school_id.nil? and User.current.user_extensions.school.nil? %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= @course_page.description %> <% else %> <% if @school_id == "0" %> - , <%= l(:label_welcome_trustie_course_description) %> + , <%= @course_page.description %> <% end %> <% end %> + <% end %>
+ <% unless @first_page.nil? %> <%= @first_page.title %> , <%= @first_page.description %> + <% end %>