Skip to content
Browse files

Adding peding requests basic page

  • Loading branch information...
1 parent 328c359 commit 4e2b9fab2a4b4f46f73dcadc3d37b2b7d878c50e @Roendal Roendal committed Jul 13, 2011
Showing with 25 additions and 9 deletions.
  1. +16 −8 app/controllers/contacts_controller.rb
  2. +5 −1 app/views/contacts/_index.html.erb
  3. +4 −0 app/views/contacts/index.html.erb
View
24 app/controllers/contacts_controller.rb
@@ -3,16 +3,24 @@ class ContactsController < ApplicationController
def index
@contacts =
- current_subject.
- contact_subjects(:direction => :sent, :relations => params[:relation]){ |q|
- q.alphabetic.
- letter(params[:letter]).
- search(params[:search])
- }
+ Contact.sent_by(current_subject).
+ joins(:receiver).merge(Actor.alphabetic).
+ merge(Actor.letter(params[:letter])).
+ merge(Actor.search(params[:search]))
+
+ if params[:pending].present?
+ @contacts =
+ Contact.received_by(current_subject).
+ joins(:sender).merge(Actor.alphabetic).
+ merge(Actor.letter(params[:letter])).
+ merge(Actor.search(params[:search])).
+ pending.
+ not_reflexive
+ end
respond_to do |format|
- format.html { @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
- format.js { @contacts = Kaminari.paginate_array(@contacts).page(params[:page]).per(10) }
+ format.html { @contacts = @contacts.page(params[:page]).per(10) }
+ format.js { @contacts = @contacts.page(params[:page]).per(10) }
format.json { render :text => @contacts.map{ |c| { 'key' => c.actor_id.to_s, 'value' => self.class.helpers.truncate_name(c.name) } }.to_json }
end
end
View
6 app/views/contacts/_index.html.erb
@@ -1,7 +1,11 @@
<% cont=0; %>
<% @contacts.each do |contact| %>
-
+ <% if params[:pending].present? %>
+ <% contact = contact.sender.subject %>
+ <% else %>
+ <% contact = contact.receiver.subject %>
+ <% end %>
<% if (cont%2) == 0 %>
<% cont+=1; %>
<div class="row">
View
4 app/views/contacts/index.html.erb
@@ -6,6 +6,10 @@
<%= javascript_include_tag 'jquery.ba-url','ajax.paginate' %>
<% end %>
+<% content_for :sidebar do %>
+ <%= render :partial => 'home/sidebar' %>
+<% end %>
+
<% toolbar :option => :contacts %>
<div id="my_conferences">

0 comments on commit 4e2b9fa

Please sign in to comment.
Something went wrong with that request. Please try again.