diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 071ea646..48098e9d 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -157,8 +157,7 @@ class UsersController < ApplicationController @bid += membership.project.homeworks end @bid = @bid.group_by {|bid| bid.courses.first.id} - #add by huang - unless User.current.admin? + unless User.current.admin? if !@user.active? render_404 return @@ -166,67 +165,39 @@ class UsersController < ApplicationController end end - # added by fq, modify by nyan def user_courses - @membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - @membership.sort! {|older, newer| newer.created_on <=> older.created_on } - case params[:type] - when "2" - #@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - @memberships = [] - @membership.each do |membership| - if membership.project.project_type == 1 - @membership << membership - end - end - @state = 2 - - when "1" - #@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - @memberships = [] - @membership.each do |membership| - if membership.project.project_type == 1 - @memberships << membership - end - end - @bid = [] - @memberships.each do |membership| - @bid += membership.project.homeworks - end - @bid = @bid.group_by {|bid| bid.courses.first.id} - @state = 1 - - else - #@membership = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - @memberships = [] - @membership.each do |membership| - if membership.project.project_type == 1 - @memberships << membership - end - end - @state = 0 - end + membership = @user.memberships.all(:conditions => Project.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) + } - # events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) - # @events_by_day = events.group_by(&:event_date) - - # @state = 0 + @memberships_doing = [] + @memberships_done = [] + now_time = Time.now + @memberships.map { |e| + end_time_str = e.project.course_extra.endup_time + end_time = Time.parse(end_time_str) + if end_time > now_time + @memberships_doing.push e + else + @memberships_done.push e + end + } - #add by huang unless User.current.admin? if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) render_404 return end end - #end # respond_to do |format| # format.html # format.api # end end - # end # modified by fq def user_newfeedback diff --git a/app/models/project.rb b/app/models/project.rb index 06a3118b..3205db8f 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -61,7 +61,7 @@ class Project < ActiveRecord::Base has_many :shares, :dependent => :destroy # has_many :students_for_courses, :dependent => :destroy has_many :student, :through => :students_for_courses, :source => :user - # has_one :cour, :class_name => 'Course', :foreign_key => :extra, :dependent => :destroy + has_one :course_extra, :class_name => 'Course', :foreign_key => :extra,:primary_key => :identifier, :dependent => :destroy # end #ADDED BY NIE @@ -85,7 +85,7 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' - has_many :journals + # has_many :journals acts_as_nested_set :order => 'name', :dependent => :destroy acts_as_attachable :view_permission => :view_files, diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index b57c6df1..a4105062 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -8,7 +8,7 @@ <%= csrf_meta_tag %> <%= favicon %> - <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', :media => 'all' %> + <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan', :media => 'all' %> <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> <%= javascript_heads %> diff --git a/app/views/users/_course_form.html.erb b/app/views/users/_course_form.html.erb index df77b565..4b3469c1 100644 --- a/app/views/users/_course_form.html.erb +++ b/app/views/users/_course_form.html.erb @@ -1,6 +1,6 @@