项目列表

This commit is contained in:
yanxd 2014-01-24 10:55:25 +08:00
parent 3df7bfb3bb
commit 0ed2e19268
9 changed files with 61 additions and 66 deletions

View File

@ -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

View File

@ -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,

View File

@ -8,7 +8,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= 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 %>

View File

@ -1,6 +1,6 @@
<div class="content_frame">
<ul class="user_project_sort">
<% for membership in @memberships %>
<% 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>

View File

@ -10,8 +10,22 @@
<%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %>
</p>
<% end %>
<% else %>
<p><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %></p>
<%= render :partial => 'course_form' %>
<% end %>
<% else %>
<p>
<span><%=l(:label_course_doing)%>(<%=@memberships_doing.count%>)</span>
<%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1, :project_type => 1}, :class => 'icon icon-add' %>
</p>
<div>
<%= render :partial => 'course_form', :locals => {:memberships => @memberships_doing}%>
</div>
<div style="clear:both;"></div>
<p>
<span><%=l(:label_course_done)%>(<%=@memberships_done.count%>)</span>
</p>
<div class="courses_history" >
<%= render :partial => 'course_form', :locals => {:memberships => @memberships_done}%>
</div>
<% end %>
</div>

View File

@ -1,6 +1,5 @@
<!--huang-->
<% if @user.user_extensions.identity == 0 %> <!-- for teacher-->
<%= render :partial => 'my_course' %>
<% else %> <!--for student-->
<%= render :partial => 'my_joinedcourse' %>
<% end %>
<% if @user.user_extensions.identity == UserExtensions::TEACHER %>
<%= render :partial => 'my_course' %>
<% else %> <!--for student-->
<%= render :partial => 'my_joinedcourse' %>
<% end %>

View File

@ -1433,7 +1433,7 @@ en:
#end
label_course: Course
label_course_new: New course
label_public_info: If you don't choose public, only the project's members can see the project.
label_public_info: "If you don't choose public, only the project's members can see the project."
label_course_student: Student
label_homework: Task
label_course_new_homework: New homework
@ -1471,8 +1471,10 @@ en:
label_question_student: Feedback
label_student_response: Feedback
label_my_question: Please raise your questions here
label_teacher_homework: Teacher's name
label_course_homework: Corresponding course
label_teacher_homework: "Teacher's name"
label_course_homework: Corresponding courses
label_course_done: finished courses
label_course_doing: Doing course
label_limit_time: Deadline
label_commit_homework: Submitted Task
label_no_course_project: No submitted work

View File

@ -563,6 +563,8 @@ zh:
label_limit_time: 截止日期
label_commit_homework: 提交作业
label_course_homework: 对应课程
label_course_doing: 进行中的课程
label_course_done: 已结束的课程
label_homework_response: 作业咨询
label_bidding_homework: 提交作业

View File

@ -494,4 +494,11 @@ input.blueinputbar:focus {
font-size: 16px;
color: #3333cc;
}
/* course 用户 课程 历史
*******************************************************************************/
.courses_history{
opacity: 0.7;
}
.courses_history a {
color: #666;
}