parent
fb36a0d5ba
commit
0d99644fa7
|
@ -6,7 +6,7 @@ class CoursesController < ApplicationController
|
|||
menu_item l(:label_sort_by_influence), :only => :index
|
||||
|
||||
before_filter :authorize, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||
before_filter :authorize_global, :only => [:view_homework_attaches] #:new,:create]
|
||||
#before_filter :authorize_global, :only => [:view_homework_attaches, :new,:create]
|
||||
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||
|
||||
before_filter :require_login, :only => [:join, :unjoin]
|
||||
|
@ -66,6 +66,13 @@ class CoursesController < ApplicationController
|
|||
return courses
|
||||
end
|
||||
|
||||
def settings
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
@issue_category ||= IssueCategory.new
|
||||
@member ||= @courses.members.new
|
||||
@trackers = Tracker.sorted.all
|
||||
end
|
||||
|
||||
def create
|
||||
if User.current.user_extensions.identity
|
||||
@course = Course.new
|
||||
|
@ -80,6 +87,7 @@ class CoursesController < ApplicationController
|
|||
@course.setup_time = params[:setup_time]
|
||||
@course.endup_time = params[:endup_time]
|
||||
@course.class_period = params[:class_period]
|
||||
@course.description = params[:description]
|
||||
end
|
||||
|
||||
@issue_custom_fields = IssueCustomField.sorted.all
|
||||
|
@ -91,7 +99,7 @@ class CoursesController < ApplicationController
|
|||
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||
m = Member.new(:user => User.current, :roles => [r])
|
||||
#course = ProjectInfo.new(:user_id => User.current.id, :course_id => @course.id)
|
||||
user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||
if params[:course][:is_public] == '1'
|
||||
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||
end
|
||||
|
|
|
@ -200,19 +200,19 @@ class UsersController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
membership = @user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||
@memberships = []
|
||||
membership.collect { |e|
|
||||
@memberships.push(e) if(e.project.project_type == 1)
|
||||
@memberships.push(e)
|
||||
}
|
||||
## 判断课程是否过期 [需封装]
|
||||
@memberships_doing = []
|
||||
@memberships_done = []
|
||||
now_time = Time.now.year
|
||||
@memberships.map { |e|
|
||||
end_time = e.project.course_extra.get_time.year
|
||||
isDone = course_endTime_timeout?(e.project)
|
||||
end_time = e.course.get_time.year
|
||||
isDone = course_endTime_timeout?(e.course)
|
||||
if isDone
|
||||
@memberships_done.push e
|
||||
else
|
||||
|
|
|
@ -182,7 +182,7 @@ module CoursesHelper
|
|||
end
|
||||
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
||||
def course_endTime_timeout? project
|
||||
end_time_str = Course.find_by_extra(project.try(:identifier)).try(:endup_time)
|
||||
end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time)
|
||||
begin
|
||||
cTime = Time.parse(end_time_str.to_s)
|
||||
rescue TypeError,ArgumentError
|
||||
|
|
|
@ -10,6 +10,14 @@ class Course < ActiveRecord::Base
|
|||
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
||||
has_many :bid
|
||||
|
||||
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||
has_many :memberships, :class_name => 'Member'
|
||||
has_many :member_principals, :class_name => 'Member',
|
||||
:include => :principal,
|
||||
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||
has_many :users, :through => :members
|
||||
|
||||
validates_presence_of :password, :term
|
||||
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
||||
safe_attributes 'extra',
|
||||
|
@ -21,7 +29,8 @@ class Course < ActiveRecord::Base
|
|||
'tea_id',
|
||||
'password',
|
||||
'term',
|
||||
'password'
|
||||
'password',
|
||||
'description'
|
||||
|
||||
acts_as_customizable
|
||||
|
||||
|
@ -49,8 +58,11 @@ class Course < ActiveRecord::Base
|
|||
errors[:extra].blank? && !(new_record? || extra.blank?)
|
||||
end
|
||||
|
||||
def archived?
|
||||
self.status == STATUS_ARCHIVED
|
||||
end
|
||||
|
||||
def self.visible_condition(user, options={})
|
||||
def self.visible_condition(user, options={})
|
||||
allowed_to_condition(user, :view_course, options)
|
||||
end
|
||||
|
||||
|
|
|
@ -54,14 +54,16 @@ class MemberRole < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def add_role_to_subprojects
|
||||
member.project.children.each do |subproject|
|
||||
if subproject.inherit_members?
|
||||
child_member = Member.find_or_new(subproject.id, member.user_id)
|
||||
child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id)
|
||||
child_member.save!
|
||||
if member.project
|
||||
member.project.children.each do |subproject|
|
||||
if subproject.inherit_members?
|
||||
child_member = Member.find_or_new(subproject.id, member.user_id)
|
||||
child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id)
|
||||
child_member.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def remove_inherited_roles
|
||||
MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
|
||||
|
|
|
@ -26,6 +26,7 @@ class Principal < ActiveRecord::Base
|
|||
|
||||
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
||||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
||||
has_many :coursememberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :course, :roles ], :conditions => "#{Course.table_name}.status<>#{Course::STATUS_ARCHIVED}", :order => "#{Course.table_name}.name"
|
||||
has_many :projects, :through => :memberships
|
||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||
|
||||
|
|
|
@ -292,14 +292,12 @@
|
|||
|
||||
|
||||
|
||||
<!-- added by huang -->
|
||||
<!-- <p style="margin-left:-10px;"><%= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
|
||||
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||
<% end %>
|
||||
|
||||
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
||||
<!--new added -->
|
||||
<p style="margin-left:-20px;padding-right: 20px;"><label for="course_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" ><%=@course.description%></textarea></span></p>
|
||||
|
||||
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
<div class="content_frame">
|
||||
<ul class="user_project_sort">
|
||||
<ul class="user_course_sort">
|
||||
<% for membership in memberships %>
|
||||
<li>
|
||||
<table width="660" border="0" align="center" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px;font-size:14px;">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50"><%= image_tag(url_to_avatar(membership.project), :class => 'avatar') %></td>
|
||||
<td colspan="2" valign="top" width="50"><%= image_tag(url_to_avatar(membership.course), :class => 'avatar') %></td>
|
||||
<td>
|
||||
<table width="580" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top">
|
||||
<span><%= link_to_project(membership.project) %></span>
|
||||
<span><%= link_to_course(membership.course) %></span>
|
||||
<span style="float: right">
|
||||
<%= render :partial => 'courses/set_course_time', :locals => {:project => membership.project} %>
|
||||
<%= render :partial => 'courses/set_course_time', :locals => {:course => membership.course} %>
|
||||
<% if User.current == @user %>
|
||||
<% (membership.roles).each do |role| %>
|
||||
<% unless (role == Role.find(9) || role == Role.find(3)) %>
|
||||
<%= join_in_course(membership.project, User.current) %>
|
||||
<%= join_in_course(membership.course, User.current) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% end %>
|
||||
<%= l(:label_x_base_courses_member, :count => membership.project.members.count) %>
|
||||
(<%= "#{membership.project.members.count}" %>)
|
||||
<%= l(:label_x_base_courses_member, :count => membership.course.members.count) %>
|
||||
(<%= "#{membership.course.members.count}" %>)
|
||||
<%= l(:label_homework) %>
|
||||
(<span class=""><%= link_to (membership.project.homeworks.count), {:controller => 'projects', :action => 'homework', :id => membership.project.identifier} %></span>)
|
||||
(<span class=""><%= link_to (membership.course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => membership.course.identifier} %></span>)
|
||||
|
||||
<%= l(:label_course_news) %>
|
||||
(<span style="color: #ed8924"><%= link_to (membership.project.news.count), {:controller => 'news', :action => 'index', :project_id => membership.project.identifier} %></span>)
|
||||
(<span style="color: #ed8924"><%= link_to (membership.course.news.count), {:controller => 'news', :action => 'index', :course_id => membership.course.identifier} %></span>)
|
||||
</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580">
|
||||
<p class="font_description">
|
||||
<%= membership.project.description %>
|
||||
<%= membership.course.description %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<% @course = Course.find_by_extra(membership.project.identifier) %>
|
||||
<% @course = Course.find_by_extra(membership.course.extra) %>
|
||||
<% unless (@course.nil? || @course.teacher.nil? || @course.teacher.name.nil?) %>
|
||||
<span class="font-lighter" style="float: left"><%= l(:label_main_teacher) %>
|
||||
: <%= link_to(@course.teacher.realname, user_path(@course.teacher)) %></span>
|
||||
|
|
|
@ -547,7 +547,7 @@ RedmineApp::Application.routes.draw do
|
|||
# 课程路由设置
|
||||
resources :courses do
|
||||
member do
|
||||
# 之前在项目
|
||||
get 'settings(/:tab)', :action => 'settings', :as => 'settings'
|
||||
post 'finishcourse'
|
||||
post 'restartcourse'
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue