From 836be8c75e3db68161e77bd5dbb5d5ff04caf14f Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 31 Jan 2015 17:14:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile.lock | 7 ---- app/api/mobile/api.rb | 2 +- app/controllers/admin_controller.rb | 39 +++++++++++++++++++ app/controllers/welcome_controller.rb | 5 +++ app/views/admin/_tab_partial.html.erb | 1 + app/views/admin/enterprise_page_made.html.erb | 39 +++++++++++++++++++ app/views/welcome/index.html.erb | 4 +- config/locales/en.yml | 3 +- config/locales/zh.yml | 1 + config/routes.rb | 1 + 10 files changed, 91 insertions(+), 11 deletions(-) create mode 100644 app/views/admin/enterprise_page_made.html.erb diff --git a/Gemfile.lock b/Gemfile.lock index 66d3dfb4e..355ca422d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,10 +91,6 @@ GEM descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) diff-lcs (1.2.5) - dnsruby (1.57.0) - email_verifier (0.0.7) - dnsruby (>= 1.5) - rails (>= 3.0.0) equalizer (0.0.9) erubis (2.7.0) execjs (2.2.1) @@ -170,7 +166,6 @@ GEM mysql2 (0.3.11-x86-mingw32) nenv (0.2.0) net-ldap (0.3.1) - newrelic_rpm (3.9.9.275) nokogiri (1.6.3) mini_portile (= 0.6.0) nokogiri (1.6.3-x86-mingw32) @@ -320,7 +315,6 @@ DEPENDENCIES capybara (~> 2.4.1) coderay (~> 1.0.6) coffee-rails (~> 3.2.1) - email_verifier factory_girl (~> 4.4.0) faker fastercsv (~> 1.5.0) @@ -336,7 +330,6 @@ DEPENDENCIES mocha (~> 1.1.0) mysql2 (= 0.3.11) net-ldap (~> 0.3.1) - newrelic_rpm nokogiri (~> 1.6.3) paperclip (~> 3.5.4) rack-mini-profiler! diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index bee78a20e..e2c4aa357 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -39,7 +39,7 @@ module Mobile mount Apis::Homeworks #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 9b1e045e3..aab9d7b69 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -283,4 +283,43 @@ class AdminController < ApplicationController end end + #企业主页定制 + def enterprise_page_made + @enterprise_page = FirstPage.find_by_page_type('enterprise') + if @enterprise_page.nil? + @enterprise_page = FirstPage.new + @enterprise_page.page_type = 'enterprise' + end + if request.get? + @first_page = FirstPage.find_by_page_type('project') + elsif request.post? + @first_page = FirstPage.find_by_page_type('project') + @first_page.web_title = params[:web_title] + @enterprise_page.web_title = params[:web_title] + @enterprise_page.title = params[:course_title] + @enterprise_page.image_width = params[:image_width] + @enterprise_page.image_height = params[:image_height] + @enterprise_page.description = params[:course_description] + if @first_page.save && @enterprise_page.save + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to enterprise_page_made_url + } + format.api { render_api_ok } + end + else + respond_to do |format| + flash.now[:error] = "#{l :label_first_page_create_fail}: #{@first_page.errors.full_messages[0]}\n\t#{@enterprise_page.errors.full_messages[0]}" + #flash.now[:error] = "#{l :label_first_page_create_fail}: #{@course_page.errors.full_messages[0]}" + format.html { + render :action => 'enterprise_page_made' + } + format.api { render_validation_errors(@first_page) } + format.api { render_validation_errors(@enterprise_page) } + end + end + end + end + end diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6704346a5..144199b86 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -30,6 +30,11 @@ class WelcomeController < ApplicationController @organization = @cur_projects.enterprise_name @organization_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @organization]) @e_count = @organization_projects.count + @enterprise_page = FirstPage.find_by_page_type('enterprise') + if @enterprise_page.nil? + @enterprise_page = FirstPage.new + @enterprise_page.page_type = 'enterprise' + end if @e_count < 9 part_count = 9 - @e_count # @part_projects = find_all_hot_project part_count, order diff --git a/app/views/admin/_tab_partial.html.erb b/app/views/admin/_tab_partial.html.erb index 6b8788a90..917d7dd3f 100644 --- a/app/views/admin/_tab_partial.html.erb +++ b/app/views/admin/_tab_partial.html.erb @@ -4,5 +4,6 @@
  • <%= link_to l(:label_course_first_page), {:action => 'course_page_made'}, class: "#{current_page?(course_page_made_path)? 'selected' : nil }" %>
  • <%= link_to l(:label_contest_first_page), {:action => 'contest_page_made'}, class: "#{current_page?(contest_page_made_path)? 'selected' : nil }" %>
  • <%= link_to l(:label_web_footer_page), {:action => 'web_footer_made'}, class: "#{current_page?(web_footer_made_path)? 'selected' : nil }" %>
  • +
  • <%= link_to l(:label_enterprise_page_made), {:action => 'enterprise_page_made'}, class: "#{current_page?(enterprise_page_made_path)? 'selected' : nil }" %>
  • \ No newline at end of file diff --git a/app/views/admin/enterprise_page_made.html.erb b/app/views/admin/enterprise_page_made.html.erb new file mode 100644 index 000000000..566f09bb8 --- /dev/null +++ b/app/views/admin/enterprise_page_made.html.erb @@ -0,0 +1,39 @@ +

    <%=l(:label_first_page_made)%>

    + +<%= form_tag(:controller => 'admin', :action => 'enterprise_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;" %> +

    + <%= render 'tab_partial' %> +

    <%=l(:label_enterprise_page_made)%>

    +

    + +

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

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

    +

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

    +

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

    +

    + + <%= text_area_tag 'course_description',@enterprise_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/index.html.erb b/app/views/welcome/index.html.erb index ff1841bd4..972c3250e 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -38,7 +38,7 @@ <%= image_tag '/images/transparent.png', width:@first_page.image_width,height: @first_page.image_height %> <% end %> <% else %> - <%= image_tag '/images/avatars/Project/0', width:@first_page.image_width,height: @first_page.image_height %> + <%= image_tag(url_to_avatar(@enterprise_page), width:@first_page.image_width,height: @first_page.image_height) %> <% end %>
    @@ -52,7 +52,7 @@
    - <%= @first_page.title %> + <%= @enterprise_page.title %> <% end %>
    diff --git a/config/locales/en.yml b/config/locales/en.yml index cb89070ff..6f272a980 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2088,4 +2088,5 @@ en: label_anonymous_comments: Anonymous comments label_anonymous: Anonymous label_submit_comments: Submit_comments - label_course_empty_select: You have not selected course! \ No newline at end of file + label_course_empty_select: You have not selected course! + label_enterprise_page_made: enterprise_page \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 50c29bd05..171117778 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -536,6 +536,7 @@ zh: label_project_first_page: 项目托管平台首页 label_course_first_page: 课程实践平台首页 label_contest_first_page: 竞赛实战平台首页 + label_enterprise_page_made: 在线协同开发社区首页 label_web_footer_page: 网站页脚配置 label_organizer_name: 主办单位名称 label_web_footer_description: 页脚内容 diff --git a/config/routes.rb b/config/routes.rb index 81dea18ff..a06679fba 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -640,6 +640,7 @@ RedmineApp::Application.routes.draw do match 'admin/course_page_made', as: :course_page_made match 'admin/contest_page_made', as: :contest_page_made match 'admin/web_footer_made', as: :web_footer_made + match 'admin/enterprise_page_made', as: :enterprise_page_made match 'admin/search', :via => [:get, :post] match 'admin/plugins', :via => :get match 'admin/info', :via => :get From 944dc33212fe95d5873ca0ab8b9607d4221ee03a Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 31 Jan 2015 17:14:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89API=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/mobile/api.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index e2c4aa357..bee78a20e 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -39,7 +39,7 @@ module Mobile mount Apis::Homeworks #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) - add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? + #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? end end