Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
cxt 2015-08-29 16:40:00 +08:00
commit d48cc8073a
16 changed files with 70 additions and 63 deletions

View File

@ -10,7 +10,7 @@ class CourseActivity < ActiveRecord::Base
#在个人动态里面增加当前动态
def add_user_activity
user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first
user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'").first
if user_activity
user_activity.save
else
@ -24,7 +24,7 @@ class CourseActivity < ActiveRecord::Base
end
def destroy_user_activity
user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'")
user_activity = UserActivity.where("act_type = '#{self.course_act_type.to_s}' and act_id = '#{self.course_act_id}'")
user_activity.destroy_all
end
end

View File

@ -25,7 +25,7 @@ class ForgeActivity < ActiveRecord::Base
#在个人动态里面增加当前动态
def add_user_activity
user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'").first
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'").first
if user_activity
user_activity.save
else
@ -39,7 +39,7 @@ class ForgeActivity < ActiveRecord::Base
end
def destroy_user_activity
user_activity = UserActivity.where("act_type = '#{self.class.to_s}' and act_id = '#{self.id}'")
user_activity = UserActivity.where("act_type = '#{self.forge_act_type.to_s}' and act_id = '#{self.forge_act_id}'")
user_activity.destroy_all
end
end

View File

@ -1,7 +1,11 @@
<% if User.current.logged?%>
<%if(target.watched_by?(User.current))%>
<%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollow", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "homepageFollowCancel", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
<% if User.current == target%>
<%= link_to("编辑资料", my_account_path, :class => "fl UsersEditBtn")%>
<% else%>
<%if(target.watched_by?(User.current))%>
<%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "UsersApBtn", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
<%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>target.id,:target_id=>target.id),:class => "UsersAttBtn", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
<% end%>
<% end %>

View File

@ -15,7 +15,6 @@
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
</head>
<
<script type="text/javascript" charset="utf-8">
$(function() {
$(document).keyup(function (e) {

View File

@ -39,10 +39,6 @@
<a href="<%= url_for(:controller => 'my', :action => 'clear_user_avatar_temp') %>" data-remote="true" class="homepageEditProfileIcon"></a>
</div>
</div>
<% else %>
<div id="watch_user_btn" class="none">
<%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %>
</div>
<% end %>
<% end%>
</div>
@ -54,10 +50,12 @@
<span class="<%= @user.user_extensions.gender == 1 ? 'homepageImageSexWomen' : 'homepageImageSexMan' %> "></span>
<% end %>
<div class="cl"></div>
<p class="mb20 c_dark f14">教授</p>
<%= link_to("编辑资料", my_account_path, :class => "fl UsersEditBtn") if is_current_user%>
<a href="javascript:void(0);" class="UsersAttBtn" style="display:none;">添加关注</a>
<a href="javascript:void(0);" class="UsersApBtn" style="display:none;">取消关注</a>
<p class="mb20 c_dark f14">
<%= get_technical_title @user %>
</p>
<div id="watch_user_btn_div">
<%= render :partial => 'layouts/user_watch_btn', :locals => {:target => @user} %>
</div>
</div>
<div class="cl"></div>
<div>

View File

@ -1,3 +1,3 @@
$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:214px;height:214px;overflow:hidden",:alt=>"头像") %>');
$("#nh_user_tx").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_tx',:style=>"width:90px;height:90px;overflow:hidden",:alt=>"头像") %>');
$("#nh_user_logo").replaceWith('<%= image_tag(url_to_avatar(@user), :id=>'nh_user_logo',:width =>"40",:height => "40",:alt=>"头像") %>');
hideModal();

View File

@ -1,7 +1,7 @@
<% if( params[:object_type] == 'user') %>
//点击头像下面的添加关注按钮
<% if( params[:target_id] == params[:object_id] ) %>
$("#watch_user_btn").html("<%= escape_javascript render(:partial => "layouts/user_watch_btn", :locals => {:target => watched.first}) %>");
$("#watch_user_btn_div").html("<%= escape_javascript render(:partial => "layouts/user_watch_btn", :locals => {:target => watched.first}) %>");
$("#user_fans_number").html("<%= watched.first.watcher_users.count.to_s%>");
//在当前用户的粉丝、关注页面
<% elsif( params[:target_id] == User.current.id.to_s )%>

View File

@ -3,6 +3,6 @@ class AddCreatedAtToActivities < ActiveRecord::Migration
add_column :activities, :created_at, :timestamp
end
def end
remove_column :activities, :created_at
remove_column :activities, :created_at
end
end

View File

@ -1,19 +1,19 @@
class UpdateActivitiesData < ActiveRecord::Migration
def up
count = Activity.all.count / 20 + 1
transaction do
for i in 1 ... count do i
Activity.page(i).per(20).each do |activity|
type = activity.act_type
if type=='Contest' || type=='Message' || type=='News'|| type=='Journal'|| type=='Issue'|| type=='Principal'||type=='JournalsForMessage'
activity.created_at = activity.act.created_on if activity.act
elsif type=='Contestnotification' || type=='HomeworkCommon' || type=='Poll'
activity.created_at = activity.act.created_at if activity.act
end
activity.save
end
end
end
# count = Activity.all.count / 20 + 1
# transaction do
# for i in 1 ... count do i
# Activity.page(i).per(20).each do |activity|
# type = activity.act_type
# if type=='Contest' || type=='Message' || type=='News'|| type=='Journal'|| type=='Issue'|| type=='Principal'||type=='JournalsForMessage'
# activity.created_at = activity.act.created_on if activity.act
# elsif type=='Contestnotification' || type=='HomeworkCommon' || type=='Poll'
# activity.created_at = activity.act.created_at if activity.act
# end
# activity.save
# end
# end
# end
end
def down

View File

@ -1,5 +1,14 @@
class AddCourseActivities < ActiveRecord::Migration
def up
create_table :user_activities do |t|
t.string :act_type
t.integer :act_id
t.string :container_type
t.integer :container_id
t.timestamps
end
create_table :course_activities do |t|
t.integer :user_id
t.integer :course_id
@ -11,5 +20,6 @@ class AddCourseActivities < ActiveRecord::Migration
def down
drop_table :course_activities
drop_table :user_activities
end
end

View File

@ -35,6 +35,6 @@ class CourseActivities < ActiveRecord::Migration
end
def down
CourseActivity.destroy_all
# CourseActivity.destroy_all
end
end

View File

@ -1,9 +1,9 @@
class UpdateCourseActivityTime < ActiveRecord::Migration
def up
count = CourseActivity.all.count / 10 + 1
count = CourseActivity.all.count / 30 + 1
transaction do
for i in 1 ... count do i
CourseActivity.page(i).per(10).each do |activity|
CourseActivity.page(i).per(30).each do |activity|
if activity.course_act
if activity.course_act.respond_to?("created_at")
activity.created_at = activity.course_act.created_at
@ -11,6 +11,10 @@ class UpdateCourseActivityTime < ActiveRecord::Migration
activity.created_at = activity.course_act.created_on
end
activity.save
user_activity = UserActivity.where("act_type = '#{activity.course_act_type.to_s}' and act_id = '#{activity.course_act_id}'").first
user_activity.created_at = activity.created_at
user_activity.save
end
end
end

View File

@ -1,16 +1,9 @@
class CreateUserActivity < ActiveRecord::Migration
def up
create_table :user_activities do |t|
t.string :act_type
t.integer :act_id
t.string :container_type
t.integer :container_id
t.timestamps
end
end
def down
drop_table :user_activities
end
end

View File

@ -15,23 +15,23 @@ class AboutUserActivities < ActiveRecord::Migration
end
end
course_count = CourseActivity.all.count / 30 + 2
transaction do
for i in 1 ... course_count do i
CourseActivity.page(i).per(30).each do |activity|
user_activity = UserActivity.new
user_activity.act_id = activity.course_act_id
user_activity.act_type = activity.course_act_type
user_activity.container_type = "Course"
user_activity.container_id = activity.course_id
user_activity.created_at = activity.created_at
user_activity.save
end
end
end
# course_count = CourseActivity.all.count / 30 + 2
# transaction do
# for i in 1 ... course_count do i
# CourseActivity.page(i).per(30).each do |activity|
# user_activity = UserActivity.new
# user_activity.act_id = activity.course_act_id
# user_activity.act_type = activity.course_act_type
# user_activity.container_type = "Course"
# user_activity.container_id = activity.course_id
# user_activity.created_at = activity.created_at
# user_activity.save
# end
# end
# end
end
def down
UserActivity.destroy_all
# UserActivity.destroy_all
end
end

View File

@ -913,7 +913,6 @@ ActiveRecord::Schema.define(:version => 20150826061843) do
t.datetime "created_on"
t.integer "comments_count", :default => 0, :null => false
t.integer "course_id"
t.datetime "updated_on"
end
add_index "news", ["author_id"], :name => "index_news_on_author_id"

View File

@ -511,7 +511,7 @@ a.UsersAttBtn{ display:block; width:55px; height:20px; border:1px solid #d3d3d3;
a:hover.UsersAttBtn{border:1px solid #888888; }
a.UsersApBtn{ display:block; width:55px; height:20px; border:1px solid #d3d3d3; color:#888888; background:#f2f3f3 url(../images/homepage_icon.png) -177px -6px no-repeat; padding-left:25px; line-height:1.9;-moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px;}
a:hover.UsersApBtn{border:1px solid #888888; }
.homepageSignatureTextarea {width:207px; height:80px; max-width:207px; max-height:80px; border:1px solid #d9d9d9; outline:none; margin:0px 0px 12px 15px;;}
.homepageSignatureTextarea {width:207px; height:80px; max-width:207px; max-height:80px; border:1px solid #d9d9d9; outline:none; margin:0px 0px 12px 0px;}
.homepageSignature {font-size:12px; color:#888888; margin:10px 0; width:208px;}
.homepageImageBlock {margin:0 auto; width:68px; float:left; text-align:center; display:inline-block;}
a.homepageImageNumber {font-size:12px; color:#484848; font-weight: bold;}