From ffa412d2908867cff979b0283520dd4af2c29f7e Mon Sep 17 00:00:00 2001 From: huangjingquan Date: Fri, 13 Sep 2013 10:11:36 +0800 Subject: [PATCH] x --- app/controllers/bids_controller.rb | 14 ++- app/controllers/courses_controller.rb | 1 + app/controllers/news_controller.rb | 18 +++- app/controllers/projects_controller.rb | 18 +++- app/views/layouts/base_courses.html.erb | 4 +- app/views/layouts/base_homework.html.erb | 132 +++++++++++++++++++++++ config/locales/zh.yml | 14 ++- lib/redmine.rb | 6 ++ 8 files changed, 197 insertions(+), 10 deletions(-) create mode 100644 app/views/layouts/base_homework.html.erb diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index b4127f151..9b8cbd26e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -92,11 +92,17 @@ class BidsController < ApplicationController # @journals = @bid.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all # @journals.each_with_index {|j,i| j.indice = i+1} respond_to do |format| + if @bid.reward_type == 3 format.html { + render :layout => 'base_homework' + } + else + format.html { render :layout => 'base_bids' } + end format.api - + end end @@ -112,9 +118,15 @@ class BidsController < ApplicationController @user = @bid.author @bidding_project = @bid.biding_projects respond_to do |format| + if @bid.reward_type == 3 format.html { + render :layout => 'base_homework' + } + else + format.html { render :layout => 'base_bids' } + end format.api end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 8d5ef1a67..49a129842 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1,4 +1,5 @@ class CoursesController < ApplicationController + before_filter :require_login, :only => [:join, :unjoin] diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 91da55dda..dffa3f5f8 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -46,12 +46,18 @@ class NewsController < ApplicationController @newss = scope.all(:include => [:author, :project], :order => "#{News.table_name}.created_on DESC", :offset => @offset, - :limit => @limit) - + :limit => @limit) + respond_to do |format| format.html { @news = News.new # for adding news inline + # huang + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + else render :layout => false if request.xhr? + end } format.api format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") } @@ -61,10 +67,18 @@ class NewsController < ApplicationController def show @comments = @news.comments @comments.reverse! if User.current.wants_comments_in_reverse_order? + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + end end def new @news = News.new(:project => @project, :author => User.current) + @course_tag = @project.project_type + if @course_tag + render :layout => 'base_courses' + end end def create diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6ec741b3e..6ac0ebd1f 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -23,15 +23,17 @@ class ProjectsController < ApplicationController menu_item l(:label_sort_by_active), :only => :index menu_item l(:label_sort_by_influence), :only => :index #by huang - # menu_item :files, :only => :files - # menu_tiem :news, :only => :news + # layout 'base_course' + # menu_item l(:label_homework), :only => homework + # menu_item l(:label_course_file), :only => files + # menu_item l(:label_settings), :only => settings before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join] before_filter :authorize, :except => [:new_join, :new_homework, :homework, :statistics, :search, :watcherlist, :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy, :member, :focus, :file, :statistics, :feedback] before_filter :authorize_global, :only => [:new, :create] before_filter :require_admin, :only => [ :copy, :archive, :unarchive, :destroy ] #by young - before_filter :member, :file, :statistics, :watcherlist + before_filter :file, :statistics, :watcherlist # accept_rss_auth :index accept_api_auth :index, :show, :create, :update, :destroy @@ -249,6 +251,7 @@ class ProjectsController < ApplicationController @bids = @bids.offset(@offset).limit(limit).all.reverse end render :layout => 'base_courses' + end def new_homework @@ -497,7 +500,16 @@ class ProjectsController < ApplicationController #by young def member + if @project.project_type == 1 + render :layout => 'base_courses' + end end + + # def news + # if @project.project_type == 1 + # render :layout => 'base_courses' + # end + # end def file # @course_tag = params[:course] diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index cbe8c7b55..bd117feee 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -133,10 +133,10 @@ +
  • <%= link_to(l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project}) %>
  • <%= yield %> <%= call_hook :view_layouts_base_content %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb new file mode 100644 index 000000000..ecfc17b7b --- /dev/null +++ b/app/views/layouts/base_homework.html.erb @@ -0,0 +1,132 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> + <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= call_hook :view_layouts_base_html_head %> + + <%= yield :header_tags -%> + + +
    +
    +
    + + <%=render :partial => 'layouts/base_header'%> + +
    + +
    + <% if display_main_menu?(@bid) %> +
    + <%= render_menu :bid_menu %> +
    + <% end %> + + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
    +
    + <%=render :partial => 'layouts/base_footer'%> +
    +
    +
    + + + + +
    + <%= call_hook :view_layouts_base_body_bottom %> + + diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 6ee17ac0b..a6833c728 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -519,6 +519,16 @@ zh: label_activities_settings: 显示设置 label_user_login_new: 登录 label_user_login_tips: 您还没有登录,请登录后留言 + #end + #by huang + label_followers: 关注 + label_teacher: 教师 + label_limit_time: 截止日期 + label_commit_homework: 提交作业 + label_course_homework: 对应课程 + label_homework_response: 作业咨询 + label_bidding_homework: 提交作业 + #end label_my_page: 我的工作台 label_my_account: 我的帐号 @@ -574,7 +584,7 @@ zh: label_news_added: 新闻已添加 label_settings: 配置 label_overview: 课程动态 - label_course_file: 课件下载 + label_course_file: 资料下载 label_course_news: 课程通知 label_version: 版本 label_version_new: 新建版本 @@ -1443,7 +1453,7 @@ zh: label_public_info: 若不公开,仅项目成员可见该项目 label_course_student: 学生 label_homework: 课程作业 - label_course_file: 课件下载 + label_course_file: 资料下载 label_course_new_homework: 新建作业 label_course_homework_list: 作业列表 label_course_homework_new: 发布作业 diff --git a/lib/redmine.rb b/lib/redmine.rb index 1f6cacd2d..27290e052 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -223,6 +223,12 @@ Redmine::MenuManager.map :application_menu do |menu| # Empty end +###### +Redmine::MenuManager.map :homework_menu do |menu| + menu.push :respond, { :controller => 'bids', :action => 'show' }, :caption => :label_homework_response + menu.push :project, { :controller => 'bids', :action => 'show_project' }, :caption => :label_bidding_homework +end +########end Redmine::MenuManager.map :admin_menu do |menu| menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural menu.push :users, {:controller => 'users'}, :caption => :label_user_plural