Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
This commit is contained in:
commit
612b79410b
|
@ -0,0 +1 @@
|
|||
{"access_token":"t3XVpwqZbAO6-uRz_ltKUiplgHcYVstA0p43ECTHEjt0-FvVLU7VXzD7n6Z76PYFWHf8hvNHZtLNAUT-FlTl98wWLIK_lh9mhzHxS_x1iXCc0mC38RjxFzZ_NSeERW7dJZCfADAOEH","expires_in":7200,"got_token_at":1460105603}
|
|
@ -13,6 +13,7 @@ module Mobile
|
|||
end
|
||||
post do
|
||||
user = UserWechat.find_by_openid(params[:openid]).user
|
||||
=begin
|
||||
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
page = params[:page] ? params[:page] : 0
|
||||
|
@ -27,6 +28,26 @@ module Mobile
|
|||
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||
=end
|
||||
|
||||
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||
page = params[:page] ? params[:page] : 0
|
||||
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||
user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||
principal_types = "JournalsForMessage"
|
||||
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
||||
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
||||
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
||||
blog_ids = "(" + watched_user_blog_ids + ")"
|
||||
|
||||
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}) "+
|
||||
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||
|
||||
all_count = activities.count
|
||||
activities = activities.limit(10).offset(page * 10)
|
||||
count = activities.count
|
||||
|
|
|
@ -23,7 +23,7 @@ module Mobile
|
|||
homework_common = HomeworkCommon.find(params[:id])
|
||||
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
||||
if (feedback.errors.empty?)
|
||||
homework_common.update_attributes(:updated_at => Time.now)
|
||||
homework_common.update_column(:updated_at, Time.now)
|
||||
result = 2
|
||||
end
|
||||
when "News"
|
||||
|
|
|
@ -30,16 +30,14 @@ module Mobile
|
|||
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
|
||||
end
|
||||
when :subject
|
||||
unless ac.act.nil?
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.name unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||
ac.act.title unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
if ac.act_type == "HomeworkCommon"
|
||||
ac.act.name unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||
ac.act.title unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||
elsif ac.act_type == "JournalsForMessage"
|
||||
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
|
||||
end
|
||||
when :description
|
||||
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
|
||||
|
@ -135,11 +133,13 @@ module Mobile
|
|||
act_expose :course_project_name #课程/项目名字
|
||||
act_expose :activity_type_name #课程问答区/项目缺陷等
|
||||
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||
has_praise = false
|
||||
current_user = options[:user]
|
||||
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id)
|
||||
has_praise = obj.empty? ? false : true
|
||||
has_praise
|
||||
if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue"
|
||||
has_praise = false
|
||||
current_user = options[:user]
|
||||
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id)
|
||||
has_praise = obj.empty? ? false : true
|
||||
has_praise
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,6 +24,8 @@ module Mobile
|
|||
'BlogComment'
|
||||
when :act_id
|
||||
u.id
|
||||
when :comment_count
|
||||
u.children.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -41,7 +43,7 @@ module Mobile
|
|||
blog_comment_expose :blog_id
|
||||
blog_comment_expose :title
|
||||
blog_comment_expose :content
|
||||
blog_comment_expose :comments_count
|
||||
blog_comment_expose :comment_count
|
||||
blog_comment_expose :created_at
|
||||
blog_comment_expose :lasted_comment
|
||||
blog_comment_expose :id
|
||||
|
|
|
@ -99,7 +99,7 @@ class BlogComment < ActiveRecord::Base
|
|||
color:"#173177"
|
||||
},
|
||||
keyword3:{
|
||||
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||
value:self.content.html_safe,
|
||||
color:"#173177"
|
||||
},
|
||||
remark:{
|
||||
|
|
|
@ -260,7 +260,7 @@ class Journal < ActiveRecord::Base
|
|||
color:"#173177"
|
||||
},
|
||||
keyword3:{
|
||||
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||
value:self.description.html_safe,
|
||||
color:"#173177"
|
||||
},
|
||||
remark:{
|
||||
|
|
|
@ -331,7 +331,7 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
color:"#173177"
|
||||
},
|
||||
keyword3:{
|
||||
value:h(truncate(key3, :length=>50, :omission=> '...')),
|
||||
value:self.notes.html_safe,
|
||||
color:"#173177"
|
||||
},
|
||||
remark:{
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
class DeleteBlogUserActivity < ActiveRecord::Migration
|
||||
def up
|
||||
UserActivity.all.each do |activity|
|
||||
if activity.act_type == 'BlogComment'
|
||||
if activity.act
|
||||
unless activity.act.parent_id.nil?
|
||||
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='BlogComment'").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
|
24
db/schema.rb
24
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160317090350) do
|
||||
ActiveRecord::Schema.define(:version => 20160408074854) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -405,6 +405,8 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "course_activities", ["course_id", "course_act_id", "course_act_type", "created_at"], :name => "course_act_index"
|
||||
|
||||
create_table "course_attachments", :force => true do |t|
|
||||
t.string "filename"
|
||||
t.string "disk_filename"
|
||||
|
@ -465,6 +467,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.integer "status"
|
||||
end
|
||||
|
||||
add_index "course_messages", ["course_message_type"], :name => "index_course_messages_on_course_message_type"
|
||||
add_index "course_messages", ["user_id", "course_id", "created_at"], :name => "index_course_messages_on_user_id_and_course_id_and_created_at"
|
||||
|
||||
create_table "course_statuses", :force => true do |t|
|
||||
t.integer "changesets_count"
|
||||
t.integer "watchers_count"
|
||||
|
@ -728,6 +733,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
end
|
||||
|
||||
add_index "forge_activities", ["forge_act_id"], :name => "index_forge_activities_on_forge_act_id"
|
||||
add_index "forge_activities", ["project_id", "forge_act_id", "created_at", "forge_act_type"], :name => "forge_act_index"
|
||||
|
||||
create_table "forge_messages", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
|
@ -741,6 +747,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.integer "status"
|
||||
end
|
||||
|
||||
add_index "forge_messages", ["forge_message_id", "forge_message_type"], :name => "index_forge_messages_on_forge_message_id_and_forge_message_type"
|
||||
add_index "forge_messages", ["user_id", "project_id", "created_at"], :name => "index_forge_messages_on_user_id_and_project_id_and_created_at"
|
||||
|
||||
create_table "forums", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
t.text "description"
|
||||
|
@ -1055,6 +1064,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "memo_messages", ["memo_id", "memo_type"], :name => "index_memo_messages_on_memo_id_and_memo_type"
|
||||
add_index "memo_messages", ["user_id", "forum_id", "created_at"], :name => "index_memo_messages_on_user_id_and_forum_id_and_created_at"
|
||||
|
||||
create_table "memos", :force => true do |t|
|
||||
t.integer "forum_id", :null => false
|
||||
t.integer "parent_id"
|
||||
|
@ -1078,6 +1090,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "message_alls", ["message_type"], :name => "index_message_alls_on_message_type"
|
||||
add_index "message_alls", ["user_id", "message_id", "created_at"], :name => "index_message_alls_on_user_id_and_message_id_and_created_at"
|
||||
|
||||
create_table "messages", :force => true do |t|
|
||||
t.integer "board_id", :null => false
|
||||
t.integer "parent_id"
|
||||
|
@ -1274,6 +1289,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.string "field_type"
|
||||
t.integer "hide", :default => 0
|
||||
t.integer "status", :default => 1
|
||||
end
|
||||
|
||||
create_table "organizations", :force => true do |t|
|
||||
|
@ -1286,6 +1302,7 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.boolean "allow_guest_download", :default => true
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "show_mode", :default => 0
|
||||
end
|
||||
|
||||
create_table "phone_app_versions", :force => true do |t|
|
||||
|
@ -1800,6 +1817,8 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.integer "user_id"
|
||||
end
|
||||
|
||||
add_index "user_activities", ["act_id", "act_type", "container_id", "created_at"], :name => "user_act_index"
|
||||
|
||||
create_table "user_extensions", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.date "birthday"
|
||||
|
@ -1830,6 +1849,9 @@ ActiveRecord::Schema.define(:version => 20160317090350) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "user_feedback_messages", ["journals_for_message_id"], :name => "index_user_feedback_messages_on_journals_for_message_id"
|
||||
add_index "user_feedback_messages", ["user_id", "created_at"], :name => "index_user_feedback_messages_on_user_id_and_created_at"
|
||||
|
||||
create_table "user_grades", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
t.integer "project_id", :null => false
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10">{{blog.user.realname}}</a>发表博客</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content" style="height:auto;">
|
||||
<div class="post-all-content c-grey2 mt10">{{blog.content}}<br /></div>
|
||||
<div class="post-all-content c-grey2 mt10" ng-bind-html="blog.content|safeHtml"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
<span class="c-grey f13 mt10 fl">{{blog.created_at}}</span>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div class="post-interactive border-bottom">
|
||||
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{blog.comments_count}})</span></div>
|
||||
<div class="post-interactive-reply c-grey2">回复 <span class="reply-num">({{blog.comment_count}})</span></div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="blog.has_praise" ng-click="decreasePraise(blog);">已赞 ({{blog.praise_count}})</div>
|
||||
<div class="post-interactive-column c-grey2" ng-if="!blog.has_praise" ng-click="addPraise(blog);">赞 ({{blog.praise_count}})</div>
|
||||
</div>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div class="post-title hidden">{{message.created_on}}</div>
|
||||
<div class="cl"></div>
|
||||
<div class="post-content c-grey2 mt10" style="height:auto;">
|
||||
<div class="post-all-content">{{message.notes}}</div>
|
||||
<div class="post-all-content" ng-bind-html="message.notes|safeHtml"></div>
|
||||
</div>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@ app.factory('auth', function($http,$routeParams, $cookies, $q){
|
|||
var _openid = '';
|
||||
|
||||
if(debug===true){
|
||||
_openid = "oCnvgv1erQGHzv5GlNZ3sxa2hnSo";
|
||||
_openid = "1";
|
||||
}
|
||||
|
||||
var getOpenId = function() {
|
||||
|
@ -68,7 +68,7 @@ app.controller('ActivityController',function($scope, $http, auth, rms, common){
|
|||
|
||||
console.log("ActivityController load");
|
||||
$scope.activities = rms.get("activities") || [];
|
||||
$scope.page = 1;
|
||||
$scope.page = 0;
|
||||
|
||||
var loadActData = function(page){
|
||||
$scope.page = page;
|
||||
|
|
Loading…
Reference in New Issue