From f9e9404471bb9abeaee5b434a4f348fd8f95bdf6 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 19 Mar 2014 15:50:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=99=A8=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E7=9A=84=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=BF=9B=E8=A1=8Cn?= =?UTF-8?q?=E5=A4=9A=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 9e829782..215dd3a5 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -7,20 +7,16 @@ class CoursesController < ApplicationController def join if User.current.logged? course = Project.find(params[:object_id]) - if ( !course_endTime_timeout?(course) ) - course_prefs = Course.find_by_extra(course.identifier) - if params[:course_password] == course_prefs.password + course_prefs = Course.find_by_extra(course.identifier) + if params[:course_password] == course_prefs.password members = [] members << Member.new(:role_ids => [10], :user_id => User.current.id) course.members << members - + StudentsForCourse.create(:student_id => User.current.id, :course_id => params[:object_id]) @state = 0 - else - @state = 1 - end else - @state = 2 + @state = 1 end end respond_to do |format| @@ -49,7 +45,18 @@ class CoursesController < ApplicationController private def allow_join - course_endTime_timeout? Project.find(params[:object_id]) + if course_endTime_timeout? Project.find(params[:object_id]) + respond_to do |format| + format.js{ + @state = 2 + render :partial => 'set_join', + :locals => {:user => User.current, + :course => Project.find(params[:object_id]), + :object_id => params[:object_id] + } + } + end + end end end \ No newline at end of file From d9bc17c1ea65c278067e8bb65819e35131a71783 Mon Sep 17 00:00:00 2001 From: yanxd Date: Wed, 19 Mar 2014 17:32:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=95=99=E8=A8=80=E6=9D=83=E9=99=90?= =?UTF-8?q?=EF=BC=8C=20basecourse=E5=85=B3=E9=97=AD=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 ++++-- app/models/journals_for_message.rb | 14 ++++++++------ app/views/courses/_set_course_time.html.erb | 6 +++--- app/views/layouts/base_courses.html.erb | 2 +- app/views/projects/finishcourse.js.erb | 2 +- app/views/projects/show.html.erb | 2 +- config/locales/zh.yml | 1 + lib/redmine.rb | 6 ++++++ 8 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 16a320e3..9a9518eb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -374,7 +374,7 @@ class ProjectsController < ApplicationController @course_tag = params[:project][:project_type] if(@course_tag=="1") - if User.current.user_extensions.identity == 0 + if User.current.user_extensions.identity#.include?(UserExtensions::TEACHER,UserExtensions::DEVELOPER) @course = Course.new @course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s @course.safe_attributes = params[:project][:course] @@ -534,7 +534,7 @@ class ProjectsController < ApplicationController @subprojects = @project.children.visible.all @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").all @trackers = @project.rolled_up_trackers - if(User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id)) + if(User.find_by_id(ProjectInfo.find_by_project_id(@project.id).try(:user_id))) @user = User.find_by_id(ProjectInfo.find_by_project_id(@project.id).user_id) end cond = @project.project_condition(Setting.display_subprojects_issues?) @@ -805,6 +805,8 @@ class ProjectsController < ApplicationController end # end + # TODO:#finishcourse and #restartcourse 没有设置权限,也就是说,任何人的调用都会关闭or重启课程。 + # 最好通过用户与项目的权限解决这种事情。还没写 def finishcourse course_prefs = Course.find_by_extra(@project.identifier) # setup_time = Time.parse(course_prefs.setup_time) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 7a870f6b..426d1b56 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -15,21 +15,23 @@ class JournalsForMessage < ActiveRecord::Base "m_reply_id" # 回复某留言的留言id(a留言回复了b留言,这是b留言的id) acts_as_tree :foreign_key => 'm_parent_id', :counter_cache => :m_reply_count, :order => "#{JournalsForMessage.table_name}.created_on ASC" - belongs_to :project, :foreign_type => 'jour_type', :foreign_key => 'jour_id', :polymorphic => true + belongs_to :project, + :foreign_key => 'jour_id', + :conditions => "#{self.table_name}.jour_type = 'Project' " + belongs_to :jour, :polymorphic => true belongs_to :user belongs_to :at_user, :class_name => "User", :foreign_key => 'reply_id' acts_as_event :title => Proc.new {|o| "#{l(:label_my_message)}"}, - :datetime => :updated_on, + :datetime => Proc.new {|o| o.updated_on }, :author => Proc.new {|o| o.user }, :description => Proc.new{|o| o.notes }, :type => Proc.new {|o| o.jour_type }#, #:url => Proc.new {|o| ''}#{:controller => 'documents', :action => 'show', :id => o.id}} - acts_as_activity_provider :author_key => :author_id, - :func => 'memos', - :timestamp => 'updated_on', - :find_options => {}#:include => :project} + acts_as_activity_provider :author_key => :user_id, + :timestamp => "#{self.table_name}.updated_on", + :find_options => {:include => :project } has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy diff --git a/app/views/courses/_set_course_time.html.erb b/app/views/courses/_set_course_time.html.erb index 7d256903..ab9fa6f2 100644 --- a/app/views/courses/_set_course_time.html.erb +++ b/app/views/courses/_set_course_time.html.erb @@ -2,8 +2,8 @@ id = "finish_course_tag" %> -<% if course_endTime_timeout?(@project) #如果课程已结束%> - <%= link_to '重启课程', restartcourse_project_path, :remote => true, :method => :post, :id => id, :confirm => ('确定要重启课程?') %> +<% if course_endTime_timeout?(project) #如果课程已结束%> + <%= link_to '重启课程', restartcourse_project_path(project), :remote => true, :method => :post, :id => id, :confirm => ('确定要重启课程?') %> <% else %> - <%= link_to '关闭课程', finishcourse_project_path, :remote => true, :method => :post, :id => id, :confirm => ('确定要关闭课程?') %> + <%= link_to '关闭课程', finishcourse_project_path(project), :remote => true, :method => :post, :id => id, :confirm => ('确定要关闭课程?') %> <% end %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index e0661ccf..956c608b 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -75,7 +75,7 @@ <%if User.current.logged? %> <% if @course.teacher.id == User.current.id %> <%= link_to l(:label_course_modify_settings), {:controller => 'projects', :action => 'settings', :id => @project} %> - <%= render :partial => 'courses/set_course_time'%> + <%= render :partial => 'courses/set_course_time', :locals => {:project => @project}%> <% else %> <%= join_in_course(@project, User.current) %> diff --git a/app/views/projects/finishcourse.js.erb b/app/views/projects/finishcourse.js.erb index a9bcfdd4..04f6617d 100644 --- a/app/views/projects/finishcourse.js.erb +++ b/app/views/projects/finishcourse.js.erb @@ -2,7 +2,7 @@ <% if Rails.env.development? %> console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@project.identifier).try(:endup_time)%>'); <% end %> - $('#finish_course_tag').replaceWith("<%= j(render partial: 'courses/set_course_time' )%>") + $('#finish_course_tag').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:project => @project} )%>") <% else %> alert('设置失败,请在论坛提交问题,等待管理员处理。'); <% end %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 096db321..a5f15505 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -57,7 +57,7 @@ - +
<%= link_to (h @user.lastname+@user.firstname), user_path(@user) %> <%= l(:label_user_create_project) %> <%= link_to @project.name %> ! <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @project.name %> !
<%= l :label_update_time %>: <%= format_time(@project.created_on) %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 34d159cb..4aac82bf 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -442,6 +442,7 @@ zh: permission_delete_own_messages: 删除自己的帖子 permission_export_wiki_pages: 导出 wiki 页面 permission_manage_subtasks: 管理子任务 + permission_view_journals_for_messages: 查看留言 project_module_issue_tracking: 问题跟踪 project_module_time_tracking: 时间跟踪 diff --git a/lib/redmine.rb b/lib/redmine.rb index 9e42f1b3..da4c436e 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -96,6 +96,7 @@ Redmine::AccessControl.map do |map| map.permission :manage_members, {:projects => :settings, :members => [:index, :show, :create, :update, :destroy, :autocomplete]}, :require => :member map.permission :manage_versions, {:projects => :settings, :versions => [:new, :create, :edit, :update, :close_completed, :destroy]}, :require => :member map.permission :add_subprojects, {:projects => [:new, :create]}, :require => :member + map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true map.project_module :issue_tracking do |map| # Issue categories @@ -194,6 +195,11 @@ Redmine::AccessControl.map do |map| map.project_module :gantt do |map| map.permission :view_gantt, {:gantts => [:show, :update]}, :read => true end + + # map.project_module :journals do |map| + # map.permission :view_journals_for_messages, {:gantts => [:show, :update]}, :read => true + # end + end #by young Redmine::MenuManager.map :top_menu do |menu|