Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
0233c9b14b
|
@ -468,13 +468,17 @@ class CoursesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@course_type = params[:course_type] ||= params[:course]
|
if User.current.login?
|
||||||
@issue_custom_fields = IssueCustomField.sorted.all
|
@course_type = params[:course_type] ||= params[:course]
|
||||||
@trackers = Tracker.sorted.all
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
@course = Course.new
|
@trackers = Tracker.sorted.all
|
||||||
@course.safe_attributes = params[:course]
|
@course = Course.new
|
||||||
# month = Time.now.month
|
@course.safe_attributes = params[:course]
|
||||||
render :layout => 'new_base'
|
# month = Time.now.month
|
||||||
|
render :layout => 'new_base'
|
||||||
|
else
|
||||||
|
redirect_to signin_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def desc_sort_course_by_avtivity(activity_count, courses)
|
def desc_sort_course_by_avtivity(activity_count, courses)
|
||||||
|
|
|
@ -863,7 +863,7 @@ class UsersController < ApplicationController
|
||||||
when "project_message"
|
when "project_message"
|
||||||
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10)
|
@user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10)
|
||||||
when "current_user"
|
when "current_user"
|
||||||
@user_activities = UserActivity.where("user_id = #{User.current.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('created_at desc').limit(10).offset(@page * 10)
|
@user_activities = UserActivity.where("user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))").order('created_at desc').limit(10).offset(@page * 10)
|
||||||
else
|
else
|
||||||
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('created_at desc').limit(10).offset(@page * 10)
|
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})").order('created_at desc').limit(10).offset(@page * 10)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,13 +14,19 @@ class CourseActivity < ActiveRecord::Base
|
||||||
if user_activity
|
if user_activity
|
||||||
user_activity.save
|
user_activity.save
|
||||||
else
|
else
|
||||||
user_activity = UserActivity.new
|
if self.course_act_type == 'Message' && !self.course_act.parent_id.nil?
|
||||||
user_activity.act_id = self.course_act_id
|
user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.course_act.parent.id}").first
|
||||||
user_activity.act_type = self.course_act_type
|
user_activity.created_at = self.created_at
|
||||||
user_activity.container_type = "Course"
|
user_activity.save
|
||||||
user_activity.container_id = self.course_id
|
else
|
||||||
user_activity.user_id = self.user_id
|
user_activity = UserActivity.new
|
||||||
user_activity.save
|
user_activity.act_id = self.course_act_id
|
||||||
|
user_activity.act_type = self.course_act_type
|
||||||
|
user_activity.container_type = "Course"
|
||||||
|
user_activity.container_id = self.course_id
|
||||||
|
user_activity.user_id = self.user_id
|
||||||
|
user_activity.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,12 +29,19 @@ class ForgeActivity < ActiveRecord::Base
|
||||||
if user_activity
|
if user_activity
|
||||||
user_activity.save
|
user_activity.save
|
||||||
else
|
else
|
||||||
user_activity = UserActivity.new
|
if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil?
|
||||||
user_activity.act_id = self.forge_act_id
|
user_activity = UserActivity.where("act_type = 'Message' and act_id = #{self.forge_act.parent.id}").first
|
||||||
user_activity.act_type = self.forge_act_type
|
user_activity.created_at = self.created_at
|
||||||
user_activity.container_type = "Project"
|
user_activity.save
|
||||||
user_activity.container_id = self.project_id
|
else
|
||||||
user_activity.save
|
user_activity = UserActivity.new
|
||||||
|
user_activity.act_id = self.forge_act_id
|
||||||
|
user_activity.act_type = self.forge_act_type
|
||||||
|
user_activity.container_type = "Project"
|
||||||
|
user_activity.container_id = self.project_id
|
||||||
|
user_activity.user_id = self.user_id
|
||||||
|
user_activity.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
<% if is_teacher%>
|
<% if is_teacher%>
|
||||||
<%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, {:controller => 'courses', :action => 'settings', :id => @course}, :class => "pr_join_a" %>
|
<%= link_to "<span class='pr_setting'></span>#{l(:button_configure)}".html_safe, {:controller => 'courses', :action => 'settings', :id => @course}, :class => "pr_join_a" %>
|
||||||
<%= set_course_time @course%>
|
<%= set_course_time @course%>
|
||||||
<%= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %>
|
<%#= link_to "<span class='pr_copy'></span>#{l(:button_copy)}".html_safe, copy_course_course_path(@course.id), :class => "pr_join_a" %>
|
||||||
<% else%>
|
<% else%>
|
||||||
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
|
<div id="join_in_course_header"><%= join_in_course_header(@course, User.current) %></div>
|
||||||
<% end%>
|
<% end%>
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
class AlterUserActivities < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
UserActivity.all.each do |activity|
|
||||||
|
if activity.act_type == 'Message'
|
||||||
|
if activity.act
|
||||||
|
unless activity.act.parent_id.nil?
|
||||||
|
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='Message'").first
|
||||||
|
parent_act.created_at = activity.act.parent.children.maximum("created_on")
|
||||||
|
parent_act.save
|
||||||
|
activity.destroy
|
||||||
|
end
|
||||||
|
else
|
||||||
|
activity.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
3401
db/schema.rb
3401
db/schema.rb
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue