项目申请类消息处理
This commit is contained in:
parent
518bad811c
commit
b36089c45d
|
@ -58,7 +58,7 @@ class MembersController < ApplicationController
|
|||
applied_project = @applied_message.applied
|
||||
user = User.find(@applied_message.applied_user_id)
|
||||
project = Project.find(applied_project.project_id) if !applied_project.nil?
|
||||
if user.member_of?(project)|| AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 1).count == 0
|
||||
if user.member_of?(project)|| AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 0).count == 0
|
||||
@flash_message = "该申请已被其他管理员处理"
|
||||
# @applied_message.update_attribute(:status, 2)
|
||||
else
|
||||
|
@ -77,7 +77,7 @@ class MembersController < ApplicationController
|
|||
project.user_grades << user_grades unless user_grades.first.user_id.nil?
|
||||
|
||||
# 添加成功后所有管理员收到的消息状态都要更新
|
||||
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1,
|
||||
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 0,
|
||||
:applied_type => "AppliedProject")
|
||||
applied_messages.update_all(:status => 7, :viewed => true)
|
||||
@applied_message = AppliedMessage.find(params[:applied_message_id])
|
||||
|
@ -88,7 +88,7 @@ class MembersController < ApplicationController
|
|||
ps.send_wechat_join_project_notice user,project,ap_role,0
|
||||
# 添加成功后,批准人收到消息
|
||||
# AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
|
||||
# :status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||
# :status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
|
@ -106,7 +106,7 @@ class MembersController < ApplicationController
|
|||
applied_project = @applied_message.applied
|
||||
project = Project.find(@applied_message.project_id) if !applied_project.nil?
|
||||
user = User.find(@applied_message.applied_user_id)
|
||||
if user.member_of?(project) || AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 1).count == 0
|
||||
if user.member_of?(project) || AppliedMessage.where(:applied_id => @applied_message.applied_id, :status => 0).count == 0
|
||||
@flash_message = "该申请已被其他管理员处理"
|
||||
# @applied_message.update_attribute(:status, 2)
|
||||
else
|
||||
|
@ -115,7 +115,7 @@ class MembersController < ApplicationController
|
|||
:viewed => false, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
|
||||
|
||||
# 拒绝功后所有管理员收到的消息状态都要更新
|
||||
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 1,
|
||||
applied_messages = AppliedMessage.where(:applied_id => @applied_message.applied_id, :project_id => @applied_message.project_id, :status => 0,
|
||||
:applied_type => "AppliedProject")
|
||||
applied_messages.update_all(:status => 5, :viewed => true)
|
||||
@applied_message = AppliedMessage.find(params[:applied_message_id])
|
||||
|
|
|
@ -136,7 +136,7 @@ module UsersHelper
|
|||
end
|
||||
# 判断当前用户能否对消息进行操作
|
||||
def allow_to_show applied_message
|
||||
(User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false
|
||||
(User.current.id == applied_message.user_id && applied_message.status == 0) ? true : false
|
||||
end
|
||||
|
||||
# 项目申请消息通过状态判断用户
|
||||
|
|
|
@ -11,7 +11,7 @@ class AppliedProject < ActiveRecord::Base
|
|||
# 仅仅给项目管理人员发送消息
|
||||
def send_appliled_message
|
||||
self.project.managers.each do |member|
|
||||
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id)
|
||||
self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => false, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id)
|
||||
|
||||
#----------------微信通知----------------------
|
||||
count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count
|
||||
|
|
93
db/schema.rb
93
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170111030006) do
|
||||
ActiveRecord::Schema.define(:version => 20170112082231) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -698,8 +698,8 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.string "code"
|
||||
t.integer "time"
|
||||
t.string "extra"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "location"
|
||||
t.string "term"
|
||||
t.string "string"
|
||||
|
@ -709,27 +709,28 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.string "class_period"
|
||||
t.integer "school_id"
|
||||
t.text "description"
|
||||
t.integer "status", :default => 1
|
||||
t.integer "attachmenttype", :default => 2
|
||||
t.integer "status", :default => 1
|
||||
t.integer "attachmenttype", :default => 2
|
||||
t.integer "lft"
|
||||
t.integer "rgt"
|
||||
t.integer "is_public", :limit => 1, :default => 1
|
||||
t.integer "inherit_members", :limit => 1, :default => 1
|
||||
t.integer "open_student", :default => 0
|
||||
t.integer "outline", :default => 0
|
||||
t.integer "publish_resource", :default => 0
|
||||
t.integer "is_delete", :default => 0
|
||||
t.integer "is_public", :limit => 1, :default => 1
|
||||
t.integer "inherit_members", :limit => 1, :default => 1
|
||||
t.integer "open_student", :default => 0
|
||||
t.integer "outline", :default => 0
|
||||
t.integer "publish_resource", :default => 0
|
||||
t.integer "is_delete", :default => 0
|
||||
t.integer "end_time"
|
||||
t.string "end_term"
|
||||
t.integer "is_excellent", :default => 0
|
||||
t.integer "excellent_option", :default => 0
|
||||
t.integer "is_copy", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "is_excellent", :default => 0
|
||||
t.integer "excellent_option", :default => 0
|
||||
t.integer "is_copy", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "syllabus_id"
|
||||
t.string "invite_code"
|
||||
t.string "qrcode"
|
||||
t.integer "qrcode_expiretime", :default => 0
|
||||
t.integer "invite_code_halt", :limit => 1, :default => 0
|
||||
t.integer "qrcode_expiretime", :default => 0
|
||||
t.integer "professional_level_id", :limit => 1
|
||||
t.integer "invite_code_halt", :limit => 1, :default => 0
|
||||
end
|
||||
|
||||
add_index "courses", ["invite_code"], :name => "index_courses_on_invite_code", :unique => true
|
||||
|
@ -804,19 +805,9 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
|
||||
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
|
||||
|
||||
create_table "delayed_jobs_20161218", :id => false, :force => true do |t|
|
||||
t.integer "id", :default => 0, :null => false
|
||||
t.integer "priority", :default => 0, :null => false
|
||||
t.integer "attempts", :default => 0, :null => false
|
||||
t.text "handler", :null => false
|
||||
t.text "last_error"
|
||||
t.datetime "run_at"
|
||||
t.datetime "locked_at"
|
||||
t.datetime "failed_at"
|
||||
t.string "locked_by"
|
||||
t.string "queue"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
create_table "disciplines", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "professional_level_id", :limit => 1
|
||||
end
|
||||
|
||||
create_table "discuss_demos", :force => true do |t|
|
||||
|
@ -1138,19 +1129,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "ii", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.string "author_login"
|
||||
t.string "rep_identifier"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "sonar_version", :default => 0
|
||||
t.string "path"
|
||||
t.string "branch"
|
||||
t.string "language"
|
||||
t.string "sonar_name"
|
||||
end
|
||||
|
||||
create_table "innodb_monitor", :id => false, :force => true do |t|
|
||||
t.integer "a"
|
||||
end
|
||||
|
@ -1687,9 +1665,12 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
end
|
||||
|
||||
create_table "professional_levels", :force => true do |t|
|
||||
t.string "level"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "level"
|
||||
end
|
||||
|
||||
create_table "professions", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "discipline_id", :limit => 1
|
||||
end
|
||||
|
||||
create_table "project_infos", :force => true do |t|
|
||||
|
@ -1752,7 +1733,6 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.boolean "hidden_repo", :default => false, :null => false
|
||||
t.integer "attachmenttype", :default => 1
|
||||
t.integer "user_id"
|
||||
t.integer "dts_test", :default => 0
|
||||
t.string "enterprise_name"
|
||||
t.integer "organization_id"
|
||||
t.integer "project_new_type"
|
||||
|
@ -1760,6 +1740,11 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.integer "forked_from_project_id"
|
||||
t.integer "forked_count"
|
||||
t.integer "publish_resource", :default => 0
|
||||
t.integer "boards_count", :default => 0
|
||||
t.integer "news_count", :default => 0
|
||||
t.integer "acts_count", :default => 0
|
||||
t.integer "journals_count", :default => 0
|
||||
t.integer "boards_reply_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "hot", :default => 0
|
||||
t.string "invite_code"
|
||||
|
@ -2082,9 +2067,10 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.integer "score"
|
||||
t.text "comment"
|
||||
t.integer "reviewer_role"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "appeal_status", :default => 0
|
||||
t.boolean "is_hidden", :default => false
|
||||
end
|
||||
|
||||
add_index "student_works_scores", ["student_work_id"], :name => "student_work_id"
|
||||
|
@ -2157,8 +2143,8 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.string "title"
|
||||
t.text "description"
|
||||
t.integer "user_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "eng_name"
|
||||
t.integer "syllabus_type"
|
||||
t.integer "credit"
|
||||
|
@ -2167,8 +2153,9 @@ ActiveRecord::Schema.define(:version => 20170111030006) do
|
|||
t.integer "practice_hours"
|
||||
t.string "applicable_major"
|
||||
t.string "pre_course"
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "des_status", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.integer "des_status", :default => 0
|
||||
t.integer "professional_level_id", :limit => 1
|
||||
end
|
||||
|
||||
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
|
||||
|
|
Loading…
Reference in New Issue