消息框架及示例
This commit is contained in:
parent
f0e7bf1147
commit
dcbade51c8
|
|
@ -9,15 +9,6 @@ class DiscussesController < ApplicationController
|
|||
if params[:reply_id].blank?
|
||||
notes = User.current.show_name.to_s + " 评论了你发布的实训:<a href='#{shixun_discuss_shixun_path(@model)}'>#{params[:content]}</a>"
|
||||
@model.discusses << Discuss.new(:content => params[:content], :user_id => User.current.id, :praise_count => 0, :challenge_id => params[:challenge_id])
|
||||
JournalsForMessage.create(
|
||||
:jour_id => @model.user_id,
|
||||
:jour_type => "Principal",
|
||||
:user_id => User.current.id,
|
||||
:reply_id => 0,
|
||||
:is_readed => 0,
|
||||
:private => 1,
|
||||
:notes => notes
|
||||
)
|
||||
else
|
||||
notes = User.current.show_name.to_s + " 评论了你的回复:<a href='#{shixun_discuss_shixun_path(@model)}'>#{params[:content]}</a>"
|
||||
user_id = Discuss.find(params[:reply_id]).try(:user_id)
|
||||
|
|
@ -29,18 +20,7 @@ class DiscussesController < ApplicationController
|
|||
:praise_count => 0,
|
||||
:challenge_id => params[:challenge_id]
|
||||
)
|
||||
JournalsForMessage.create(
|
||||
:jour_id => user_id,
|
||||
:jour_type => "Principal",
|
||||
:user_id => User.current.id,
|
||||
:reply_id => 0,
|
||||
:is_readed => 0,
|
||||
:private => 1,
|
||||
:notes => notes
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
if params[:dis_type] == "Shixun"
|
||||
redirect_to shixun_discuss_shixun_path(@model, :challenge_id => params[:challenge_id])
|
||||
end
|
||||
|
|
|
|||
|
|
@ -203,14 +203,10 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
# 消息
|
||||
def user_tiddings
|
||||
def user_tidings
|
||||
# @tids = @user.tidings
|
||||
@tids = Tiding.where(:user_id => @user.id)
|
||||
render :layout => "base_edu_user"
|
||||
# @user_tidding = Tiding.where("0=0")
|
||||
# respond_to do |format|
|
||||
# format.html
|
||||
# format.js
|
||||
# end
|
||||
end
|
||||
|
||||
# 我收到的issue
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ class Discuss < ActiveRecord::Base
|
|||
has_one :praise_tread_cache, as: :object, dependent: :destroy
|
||||
acts_as_tree :foreign_key => 'parent_id'
|
||||
belongs_to :dis, :polymorphic => true
|
||||
has_many :tidings, :class_name => 'Tiding', :as => :container , :dependent => :destroy
|
||||
validates_presence_of :dis, :user, :content
|
||||
after_create :send_tiding
|
||||
|
||||
def creator_user
|
||||
User.find(self.user_id)
|
||||
|
|
@ -15,4 +17,8 @@ class Discuss < ActiveRecord::Base
|
|||
def content_detail
|
||||
self.content
|
||||
end
|
||||
|
||||
def send_tiding
|
||||
self.tidings << Tiding.new(:user_id => self.user_id, :parent_container_id => self.dis_id, :parent_container_type => self.dis_type)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#encoding: utf-8
|
||||
# 使用请了解以下描述,不清楚请@Hjqreturn
|
||||
#
|
||||
# user_id: 信息接收人
|
||||
|
|
@ -14,13 +15,17 @@
|
|||
class Tiding < ActiveRecord::Base
|
||||
attr_accessible :belong_container_id, :belong_container_type, :container_id, :container_type, :parent_container_id,
|
||||
:parent_container_type, :status, :trigger_user_id, :user_id, :viewed
|
||||
default_scope :order => 'created_at desc'
|
||||
belongs_to :container, :polymorphic => true
|
||||
|
||||
default :scope
|
||||
def link_image
|
||||
self.user_id
|
||||
end
|
||||
|
||||
def subject
|
||||
case at_message_type
|
||||
when "Issue"
|
||||
"新建问题: " + at_message.subject
|
||||
case container_type
|
||||
when "Discuss"
|
||||
"ppp: " + at_message.subject
|
||||
when "Journal"
|
||||
"问题留言: " + at_message.journalized.subject
|
||||
when 'Message'
|
||||
|
|
@ -41,7 +46,7 @@ class Tiding < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def description
|
||||
case at_message_type
|
||||
case container_type
|
||||
when "Issue"
|
||||
at_message.description
|
||||
when "Journal"
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
<% @user = User.current %>
|
||||
<%= stylesheet_link_tag "css/edu-admin" %>
|
||||
<div class="-task-con">
|
||||
<div class="-task-con-per box_bg_shandow bor-grey-e cl">
|
||||
<div style="width: 100%;clear: both;overflow: hidden" class="" >
|
||||
<div class="photo fl ml30" style="margin-left: 3%">
|
||||
<%= image_tag(url_to_avatar(@user), :class => "person",:width => 100, :height => 100, :alt => "头像",:style => "border-radius:50%" ) %>
|
||||
</div>
|
||||
<div class="fl ml10">
|
||||
<div class="top-left fl" style="width: 600px">
|
||||
<p class="p1 font-16 mt30 color-grey">
|
||||
<span><%= @user.show_real_name %></span>
|
||||
</p>
|
||||
<li class="mt10 color-grey font-14">上次访问时间:<span class="color-grey3">2017-08-25 09:15</span></li>
|
||||
</div>
|
||||
<div class="fl">
|
||||
<ul class="fl" style="padding: 15px 0px;text-align:right">
|
||||
<li class="fl tiding_logo"><i class="fa fa-commenting font-30 mr10 mt20" style="color:#29bd8b"></i><span>50</span><br><span class="font-16">新增消息数</span></li>
|
||||
<li class="fl ml10 tiding_logo" ><i class="fa fa-comments font-30 mr10 mt20"></i><span>50</span><br><span class="font-16">总消息数</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="fl ml30 mb15" style="border-top: 1px solid #eee;padding-top: 10px;width: 100% ">
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 active fl" data-remote="true">全部</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">审核</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">作业</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">试卷</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">评论</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">留言</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">@ </a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true"> 赞</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true"> 踩</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">粉丝</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">系统</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edu-con-bg01 mt15" id="user_tiddings">
|
||||
<%= render :partial => "user_tiddings_list" %>
|
||||
</div>
|
||||
<% @user = User.current %>
|
||||
<%= stylesheet_link_tag "css/edu-admin" %>
|
||||
<div class="-task-con">
|
||||
<div class="-task-con-per box_bg_shandow bor-grey-e cl">
|
||||
<div style="width: 100%;clear: both;overflow: hidden" class="" >
|
||||
<div class="photo fl ml30" style="margin-left: 3%">
|
||||
<%= image_tag(url_to_avatar(@user), :class => "person",:width => 100, :height => 100, :alt => "头像",:style => "border-radius:50%" ) %>
|
||||
</div>
|
||||
<div class="fl ml10">
|
||||
<div class="top-left fl" style="width: 600px">
|
||||
<p class="p1 font-16 mt30 color-grey">
|
||||
<span><%= @user.show_real_name %></span>
|
||||
</p>
|
||||
<li class="mt10 color-grey font-14">上次访问时间:<span class="color-grey3">2017-08-25 09:15</span></li>
|
||||
</div>
|
||||
<div class="fl">
|
||||
<ul class="fl" style="padding: 15px 0px;text-align:right">
|
||||
<li class="fl tiding_logo"><i class="fa fa-commenting font-30 mr10 mt20" style="color:#29bd8b"></i><span>50</span><br><span class="font-16">新增消息数</span></li>
|
||||
<li class="fl ml10 tiding_logo" ><i class="fa fa-comments font-30 mr10 mt20"></i><span>50</span><br><span class="font-16">总消息数</span></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="fl ml30 mb15" style="border-top: 1px solid #eee;padding-top: 10px;width: 100% ">
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 active fl" data-remote="true">全部</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">审核</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">作业</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">试卷</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">评论</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">留言</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">@ </a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true"> 赞</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true"> 踩</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">粉丝</a>
|
||||
<a href="" class="edu-filter-cir-grey mr15 font-14 fl" data-remote="true">系统</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edu-con-bg01 mt15" id="user_tiddings">
|
||||
<%= render :partial => "user_tiddings_list" %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1042,7 +1042,7 @@ RedmineApp::Application.routes.draw do
|
|||
end
|
||||
|
||||
member do
|
||||
get "user_tiddings"
|
||||
get "user_tidings"
|
||||
get 'shixuns', :to => 'users#shixuns'
|
||||
get 'user_myshixuns', :to => 'users#user_myshixuns'
|
||||
match 'user_projects_index', :to => 'users#user_projects_index', :via => :get
|
||||
|
|
|
|||
Loading…
Reference in New Issue