diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 5c64ad332..1e16d19be 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -27,7 +27,7 @@ class AccountController < ApplicationController if request.get? @login = params[:login] || true if User.current.logged? - redirect_to home_url + redirect_to user_path(User.current) else render :layout => 'login' end @@ -58,7 +58,7 @@ class AccountController < ApplicationController # Lets user choose a new password def lost_password - (redirect_to(home_url); return) unless Setting.lost_password? + (redirect_to(signin_path); return) unless Setting.lost_password? if params[:token] @token = Token.find_token("recovery", params[:token].to_s) if @token.nil? || @token.expired? @@ -110,7 +110,7 @@ class AccountController < ApplicationController # User self-registration def register - (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] + (redirect_to(signin_path); return) unless Setting.self_registration? || session[:auth_source_registration] if request.get? session[:auth_source_registration] = nil @user = User.new(:language => current_language.to_s) @@ -187,11 +187,11 @@ class AccountController < ApplicationController # Token based account activation def activate - (redirect_to(home_url); return) unless Setting.self_registration? && params[:token].present? + (redirect_to(signin_path); return) unless Setting.self_registration? && params[:token].present? token = Token.find_token('register', params[:token].to_s) - (redirect_to(home_url); return) unless token and !token.expired? + (redirect_to(signin_path); return) unless token and !token.expired? user = token.user - (redirect_to(home_url); return) unless user.registered? + (redirect_to(signin_path); return) unless user.registered? user.activate if user.save token.destroy @@ -278,7 +278,7 @@ class AccountController < ApplicationController user = User.find_or_initialize_by_identity_url(identity_url) if user.new_record? # Self-registration off - (redirect_to(home_url); return) unless Setting.self_registration? + (redirect_to(signin_path); return) unless Setting.self_registration? # Create on the fly user.login = registration['nickname'] unless registration['nickname'].nil? diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 698b0de48..1c233ed6b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -557,7 +557,7 @@ class ApplicationController < ActionController::Base end def redirect_back_or_default(default, options={}) - back_url = params[:back_url].to_s + back_url = '' #params[:back_url].to_s if back_url.present? begin uri = URI.parse(back_url) diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb index 4124472e1..9728ddf11 100644 --- a/app/controllers/my_controller.rb +++ b/app/controllers/my_controller.rb @@ -174,7 +174,7 @@ class MyController < ApplicationController logout_user flash.now[:notice] = l(:notice_account_deleted) end - redirect_to home_url + redirect_to signin_path end end diff --git a/app/controllers/softapplications_controller.rb b/app/controllers/softapplications_controller.rb index e47cfc2ff..bedb2541f 100644 --- a/app/controllers/softapplications_controller.rb +++ b/app/controllers/softapplications_controller.rb @@ -207,7 +207,7 @@ class SoftapplicationsController < ApplicationController @softapplication.destroy respond_to do |format| - format.html { redirect_to home_url } + format.html { redirect_to signin_path } format.json { head :no_content } end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 900af0e77..0058e6e4c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -627,14 +627,15 @@ class UsersController < ApplicationController end def show + @page = params[:page] ? params[:page].to_i + 1 : 0 - @type = params[:type] + user_project_ids = @user.projects.visible.empty? ? "(-1)" : "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = @user.courses.visible.empty? ? "(-1)" : "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" course_types = "('Message','News','HomeworkCommon','poll')" project_types = "('Message','Issue')" - if @type - case @type + if params[:type].present? + case params[:type] when "course_homework" @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page * 10) when "course_news" @@ -654,6 +655,7 @@ class UsersController < ApplicationController @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 # @user_activities = paginateHelper @user_activities,500 + @type = params[:type] respond_to do |format| format.js format.html {render :layout => 'new_base_user'} diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 6b14db9bb..809f78ddc 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -27,7 +27,8 @@ class WelcomeController < ApplicationController def index # 企业版定制: params[:project]为传过来的参数 - + redirect_to signin_path + return unless params[:organization].nil? @organization = Organization.find params[:organization] # @organization_projects = Project.joins(:project_status).joins("LEFT JOIN project_scores ON projects.id = project_scores.project_id").where("projects.organization_id = ?", @organization.id).order("score DESC").limit(10).all @@ -171,7 +172,7 @@ class WelcomeController < ApplicationController redirect_to users_search_url(:name => search_condition, :search_by => search_by, :role => :student) else #redirect_to home_path, :alert => l(:label_sumbit_empty) - (redirect_to home_url, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? + (redirect_to signin_path, :notice => l(:label_sumbit_empty);return) #if params[:name].blank? end } end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 1d0920c1c..284687870 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -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 diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index b7fc5e4c2..9bc10bebf 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -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 diff --git a/app/views/layouts/_user_watch_btn.html.erb b/app/views/layouts/_user_watch_btn.html.erb index 5f9c550b7..aeb8ee08f 100644 --- a/app/views/layouts/_user_watch_btn.html.erb +++ b/app/views/layouts/_user_watch_btn.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb index e7810d45a..b5dc9e75a 100644 --- a/app/views/layouts/login.html.erb +++ b/app/views/layouts/login.html.erb @@ -15,7 +15,6 @@ <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> -< - +
最新动态
@@ -55,4 +55,4 @@
-<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => @page} %> \ No newline at end of file +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0} %> \ No newline at end of file diff --git a/app/views/watchers/_set_watcher.js.erb b/app/views/watchers/_set_watcher.js.erb index 1365468cc..d875a38c4 100644 --- a/app/views/watchers/_set_watcher.js.erb +++ b/app/views/watchers/_set_watcher.js.erb @@ -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 )%> diff --git a/db/migrate/20150810064247_add_created_at_to_activities.rb b/db/migrate/20150810064247_add_created_at_to_activities.rb index 864ed82d6..e2f35441f 100644 --- a/db/migrate/20150810064247_add_created_at_to_activities.rb +++ b/db/migrate/20150810064247_add_created_at_to_activities.rb @@ -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 diff --git a/db/migrate/20150811010817_update_activities_data.rb b/db/migrate/20150811010817_update_activities_data.rb index 7ed19a607..374407cd3 100644 --- a/db/migrate/20150811010817_update_activities_data.rb +++ b/db/migrate/20150811010817_update_activities_data.rb @@ -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 diff --git a/db/migrate/20150811065543_add_course_activities.rb b/db/migrate/20150811065543_add_course_activities.rb index 03ec7e354..86b96bd44 100644 --- a/db/migrate/20150811065543_add_course_activities.rb +++ b/db/migrate/20150811065543_add_course_activities.rb @@ -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 diff --git a/db/migrate/20150811080754_course_activities.rb b/db/migrate/20150811080754_course_activities.rb index a4cae915d..910cb4520 100644 --- a/db/migrate/20150811080754_course_activities.rb +++ b/db/migrate/20150811080754_course_activities.rb @@ -35,6 +35,6 @@ class CourseActivities < ActiveRecord::Migration end def down - CourseActivity.destroy_all + # CourseActivity.destroy_all end end diff --git a/db/migrate/20150814031258_update_course_activity_time.rb b/db/migrate/20150814031258_update_course_activity_time.rb index 155e212a3..26d0dc4bc 100644 --- a/db/migrate/20150814031258_update_course_activity_time.rb +++ b/db/migrate/20150814031258_update_course_activity_time.rb @@ -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 diff --git a/db/migrate/20150820022416_create_user_activity.rb b/db/migrate/20150820022416_create_user_activity.rb index 7d6a978d1..0ff64b1f3 100644 --- a/db/migrate/20150820022416_create_user_activity.rb +++ b/db/migrate/20150820022416_create_user_activity.rb @@ -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 diff --git a/db/migrate/20150820025358_about_user_activities.rb b/db/migrate/20150820025358_about_user_activities.rb index 82b58a537..e02b4711f 100644 --- a/db/migrate/20150820025358_about_user_activities.rb +++ b/db/migrate/20150820025358_about_user_activities.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 5b09c8f3d..3c43292e5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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" diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 2fa219423..190cc7984 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -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;}