From 671b81035cf00aaa275efc2d0fd36f9dec9829d7 Mon Sep 17 00:00:00 2001 From: fanqiang <316257774@qq.com> Date: Sun, 15 Sep 2013 16:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B=E9=83=A8?= =?UTF-8?q?=E5=88=86=E7=9A=84=E6=9D=83=E9=99=90=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=9A=84=E4=BE=A7=E8=BE=B9=E6=A0=8F=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 ++ app/controllers/projects_controller.rb | 5 +++ app/views/courses/_set_join.js.erb | 9 +++-- app/views/layouts/base_courses.html.erb | 2 ++ app/views/layouts/base_homework.html.erb | 10 ++++++ app/views/projects/_new_join.html.erb | 46 +++++++++++++++++++++--- app/views/projects/homework.html.erb | 2 +- 7 files changed, 69 insertions(+), 7 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index f84e1d137..137079233 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -12,7 +12,9 @@ class CoursesController < ApplicationController course.members << members StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) + @state = 0 else + @state = 1 end end respond_to do |format| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 81e9f5e3c..c23be398c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -270,9 +270,14 @@ class ProjectsController < ApplicationController end def new_homework + if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0)) @homework = Bid.new @homework.safe_attributes = params[:bid] render :layout => 'base_courses' + else + render_404 + end + end #Ended by young diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index cd6ca1b59..50bb692d4 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -1,3 +1,8 @@ - - $('#join').html('<%= escape_javascript join_in_course(course, user) %>'); +<% if @state %> + <% if @state == 0 %> + alert("加入成功") + <% else %> + alert("密码错误") + <% end %> +<% end %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 76ac17079..076eb1812 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -145,7 +145,9 @@
  • <%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files)%>
  • <%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news)%>
  • + <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%>
  • <%= link_to l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%>
  • + <% end %> <%= 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 index 818e16b7c..a93780a3b 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -85,6 +85,15 @@
    + <% if @bid.homework_type == 1%> + <% if @bid.homeworks.size>0 %> + <% for homework in @bid.homeworks %> + <%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> + <% end %> + <% else %> +

    <%= l(:label_no_course_project) %>

    + <% end %> + <% else%> <% if @bid.projects.size>0 %> <% for project in @bid.projects%> <%= link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar" %> @@ -92,6 +101,7 @@ <% else %>

    <%= l(:label_no_course_project) %>

    <% end %> + <% end %>
    diff --git a/app/views/projects/_new_join.html.erb b/app/views/projects/_new_join.html.erb index 918c65b96..ca06715f3 100644 --- a/app/views/projects/_new_join.html.erb +++ b/app/views/projects/_new_join.html.erb @@ -1,3 +1,41 @@ + + +

    请输入课程密码

    <%= form_tag({:controller => 'courses', @@ -7,10 +45,10 @@ :method => :post, :id => 'new-watcher-form') do %> - <%= text_field_tag 'course_password', nil%> + <%= text_field_tag 'course_password', nil, :size => 48%> -

    - <%= submit_tag '加入', :name => nil, :onclick => "hideModal(this);" %> - <%= submit_tag l(:button_cancel), :name => nil, :onclick => "hideModal(this);", :type => 'button' %> +

    + <%= submit_tag '加入', :name => nil, :class => "bid_btn", :onclick => "hideModal(this);" %> + <%= submit_tag l(:button_cancel), :name => nil, :class => "bid_btn", :onclick => "hideModal(this);", :type => 'button' %>

    <% end %> diff --git a/app/views/projects/homework.html.erb b/app/views/projects/homework.html.erb index a65063b18..c16aa465a 100644 --- a/app/views/projects/homework.html.erb +++ b/app/views/projects/homework.html.erb @@ -4,7 +4,7 @@ -
    <%= l(:label_course_homework_list)%><% if User.current.logged? %> + <% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%> <%= link_to(l(:label_course_homework_new), {:controller => 'projects', :action => 'new_homework'}, :class => 'icon icon-add') %>