修改用户活动页面,添加了过滤功能。修改留言中引用和删除功能的显示问题
This commit is contained in:
parent
eacb4ff66a
commit
c7beefa556
|
@ -215,18 +215,48 @@ class UsersController < ApplicationController
|
|||
# @activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
# @offset ||= @activity_pages.offset
|
||||
# @events_by_day_ = @events.slice(@offset,@limit)
|
||||
if @user == User.current
|
||||
case params[:type]
|
||||
when "1"
|
||||
if @user == User.current
|
||||
activity = Activity.where('user_id = ?', User.current.id).order('id desc')
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @activity_pages.offset
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@state = 1
|
||||
end
|
||||
when "2"
|
||||
message = []
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = message.size
|
||||
@info_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @info_pages.offset
|
||||
|
||||
messages = message.sort {|x,y| y.created_on <=> x.created_on }
|
||||
|
||||
@message = messages[@offset, @limit]
|
||||
@state = 2
|
||||
else
|
||||
if @user == User.current
|
||||
watcher = User.watched_by(@user)
|
||||
watcher.push(User.current)
|
||||
activity = Activity.where('user_id in (?)', watcher).order('id desc')
|
||||
else
|
||||
else
|
||||
activity = Activity.where('user_id = ?', @user.id).order('id desc')
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @activity_pages.offset
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
@state = 0
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@activity_count = activity.count
|
||||
@activity_pages = Paginator.new @activity_count, @limit, params['page']
|
||||
@offset ||= @activity_pages.offset
|
||||
@activity = activity.offset(@offset).limit(@limit)
|
||||
|
||||
|
||||
#Modified by nie
|
||||
unless User.current.admin?
|
||||
|
@ -249,10 +279,10 @@ class UsersController < ApplicationController
|
|||
def info
|
||||
|
||||
message = []
|
||||
if @user == User.current
|
||||
|
||||
if @user == User.current
|
||||
message = JournalsForMessage.reference_message(@user.id)
|
||||
message += Journal.reference_message(@user.id) end
|
||||
message += Journal.reference_message(@user.id)
|
||||
end
|
||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||
@info_count = message.size
|
||||
@info_pages = Paginator.new @info_count, @limit, params['page']
|
||||
|
|
|
@ -62,5 +62,33 @@ module UsersHelper
|
|||
end
|
||||
|
||||
# added by fq
|
||||
# <div class="pagination" >
|
||||
# <ul>
|
||||
# <li><%= link_to("所有动态", {:controller => 'users', :action => 'show'}) %></li>
|
||||
# <li><%= link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}) %></li>
|
||||
# <li><%= link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}) %></li>
|
||||
# </ul></div>
|
||||
|
||||
def show_activity(state)
|
||||
content = ''.html_safe
|
||||
case state
|
||||
when 0
|
||||
s = content_tag('span', "所有动态", :class => "current-page")
|
||||
content << content_tag('li', s)
|
||||
content << content_tag('li', link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}))
|
||||
content << content_tag('li', link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}))
|
||||
when 1
|
||||
s = content_tag('span', "只看自己", :class => "current-page")
|
||||
content << content_tag('li', link_to("所有动态", {:controller => 'users', :action => 'show'}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
content << content_tag('li', link_to("所有反馈", {:controller => 'users', :action => 'show', :type => 2}))
|
||||
when 2
|
||||
s = content_tag('span', "所有反馈", :class => "current-page")
|
||||
content << content_tag('li', link_to("所有动态", {:controller => 'users', :action => 'show'}))
|
||||
content << content_tag('li', link_to("只看自己", {:controller => 'users', :action => 'show', :type => 1}))
|
||||
content << content_tag('li', s, :class => "current-page")
|
||||
end
|
||||
content_tag('div', content, :class => "pagination")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -84,6 +84,7 @@ class User < Principal
|
|||
has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1"
|
||||
has_many :journal_replies
|
||||
has_many :activities
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
#####
|
||||
|
||||
######added by nie
|
||||
|
@ -128,6 +129,9 @@ class User < Principal
|
|||
before_create :set_mail_notification
|
||||
before_save :update_hashed_password
|
||||
before_destroy :remove_references_before_destroy
|
||||
# added by fq
|
||||
after_create :act_as_activity
|
||||
# end
|
||||
|
||||
scope :in_group, lambda {|group|
|
||||
group_id = group.is_a?(Group) ? group.id : group.to_i
|
||||
|
@ -665,6 +669,10 @@ class User < Principal
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
def act_as_activity
|
||||
self.acts << Activity.new(:user_id => self.id)
|
||||
end
|
||||
|
||||
# Removes references that are not handled by associations
|
||||
# Things that are not deleted are reassociated with the anonymous user
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
|
||||
<% if journals.size >0 %>
|
||||
<% remove_allowed = (User.current.id == journals.first.jour_id) %>
|
||||
|
||||
<% for journal in journals%>
|
||||
<table width="660px" border="0" align="center">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(journal.user), :class => "avatar"), user_path(journal.user), :class => "avatar" %></td>
|
||||
<td><table width="580px" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong> <%=link_to journal.user, user_path(journal.user)%></strong> <span class="font_lighter"><%= l(:label_respond_requirement) %></span><%= link_to "##{journal.indice}", respond_path(bid), :class => "journal-link" %> </td>
|
||||
<td colspan="2" valign="top"><strong> <%=link_to journal.user, user_path(journal.user)%></strong> <span class="font_lighter"><%= l(:label_respond_requirement) %></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580px" ><p class="font_description"><%= textilizable journal.notes%></p></td>
|
||||
|
@ -26,17 +26,18 @@
|
|||
<tr>
|
||||
<td align="left"><span class="font_lighter"><%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %></span></td>
|
||||
<% if @user==User.current|| User.current.admin? %>
|
||||
<td width="200" align="right" class="a"><%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
<td width="200" align="right" class="a"><%= link_to("引用", {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<%= link_to(image_tag('delete.png'), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
|
||||
:remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) if remove_allowed || journal.user_id == User.current.id %></td>
|
||||
<%= link_to("删除", {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
|
||||
:remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %></td>
|
||||
<% else %>
|
||||
<td width="200" align="right" class="a"><%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
<td width="200" align="right" class="a"><%= link_to("引用", {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<% end %>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="line_under"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -123,11 +123,9 @@
|
|||
|
||||
<div id="content" style="padding-top: 0px;">
|
||||
<div class="tabs_new">
|
||||
<% if @user == User.current %>
|
||||
<%= render_menu :user_menu_self %>
|
||||
<%else%>
|
||||
|
||||
<%= render_menu :user_menu %>
|
||||
<%end%>
|
||||
|
||||
</div>
|
||||
<%= yield %>
|
||||
<%= call_hook :view_layouts_base_content %>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
<% if User.current.id == @user.id%>
|
||||
<%= show_activity @state%>
|
||||
<% end %>
|
||||
<% unless @state == 2%>
|
||||
<% unless @activity.empty? %>
|
||||
<div id="activity">
|
||||
<% @activity.each do |e| %>
|
||||
|
@ -75,6 +79,23 @@
|
|||
<%= textilizable act.content %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="display: inline-block; float: right; margin-top: 0px"></div>
|
||||
<% when 'Principal' %>
|
||||
<tr>
|
||||
<% if e.user == User.current%>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to("#{l(:label_i)}", user_path(e.user_id)) %></strong><span class="font_lighter">新建了用户</span></td>
|
||||
<% else %>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user_id)) %></strong><span class="font_lighter">新建了用户</span></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580" >
|
||||
<p class="font_description">
|
||||
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="display: inline-block; float: right; margin-top: 0px"></div>
|
||||
|
@ -142,4 +163,63 @@
|
|||
<%= l(:label_user_activities_other) %>
|
||||
</p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<!-- fq -->
|
||||
<% unless @message.empty? %>
|
||||
<div id="activity">
|
||||
<% @message.each do |e| -%>
|
||||
<table width="660" border="0" align="left" style="border-bottom: 1px dashed rgb(204, 204, 204); margin-bottom: 10px;">
|
||||
<tr>
|
||||
<!-- fq -->
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(e.user), :class => "avatar"), user_path(e.user), :class => "avatar" %></td>
|
||||
<td>
|
||||
<table width="580" border="0">
|
||||
<tr>
|
||||
<td colspan="2" valign="top"><strong> <%= link_to(h(e.user), user_path(e.user)) %></strong><span class="font_lighter">
|
||||
<% if e.instance_of?(JournalsForMessage)%>
|
||||
<% if e.reply_id == User.current.id%>
|
||||
<%if e.jour_type == 'Bid'%>
|
||||
<%= l(:label_in_bids)%><%= link_to(e.jour.name, respond_path(e.jour))%><%= l(:label_quote_my_words) %>
|
||||
<% else %>
|
||||
<%= l(:label_in_users)%><%= link_to(e.jour.firstname, feedback_path(e.jour))%><%= l(:label_quote_my_words) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= l(:label_about_requirement) %><%= link_to(e.jour.name, respond_path(e.jour_id))%><%= l(:label_have_respond) %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if e.journal_reply.nil? || e.journal_reply.reply_id != User.current.id %>
|
||||
<%= l(:label_about_issue) %><%= link_to(e.issue.subject, issue_path(e.journalized_id))%><%= l(:label_have_respond) %>
|
||||
|
||||
<% else %>
|
||||
<%= l(:label_in_issues)%><%= link_to(e.issue.subject, issue_path(e.issue))%><%= l(:label_quote_my_words) %>
|
||||
<% end %>
|
||||
<% end %> </span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" width="580" >
|
||||
<p class="font_description">
|
||||
<%= textilizable e.notes %>
|
||||
</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a class="font_lighter"></a></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_time e.created_on %></span></td>
|
||||
</tr>
|
||||
<!-- <tr><div class="line_under"></div></tr> -->
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="pagination" style="float:left;">
|
||||
<ul>
|
||||
<%= pagination_links_full @info_pages %>
|
||||
<ul>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="font_description"><%= l(:label_no_user_respond_you) %></p>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% end %>
|
||||
|
|
|
@ -21,12 +21,12 @@
|
|||
<td align="left"><span class="font_lighter"> <%= format_time journal.created_on %></span></td>
|
||||
|
||||
<td width="200" align="right" class="a"> <% if @user == User.current %>
|
||||
<%= link_to(image_tag('comment.png'), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
||||
<%= link_to("引用", {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<%= link_to(image_tag('delete.png'), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user},
|
||||
<%= link_to("删除", {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) if remove_allowed || journal.jour_id == User.current.id %></td>
|
||||
<% else %>
|
||||
<%= link_to(image_tag('comment.png'), {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
||||
<%= link_to("引用", {:controller => 'words', :action => 'new', :id => user, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<% end %>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in New Issue