added the ability to message someone from their profile page
This commit is contained in:
parent
48fff29bf6
commit
d50863cc90
3 changed files with 41 additions and 20 deletions
|
|
@ -6,7 +6,9 @@ class ConversationsController < ApplicationController
|
|||
def index
|
||||
@conversations = Conversation.joins(:conversation_visibilities).where(
|
||||
:conversation_visibilities => {:person_id => current_user.person.id}).paginate(
|
||||
:page => params[:page], :per_page => 7, :order => 'updated_at DESC')
|
||||
:page => params[:page], :per_page => 15, :order => 'updated_at DESC')
|
||||
@authors = {}
|
||||
@conversations.each{|c| @authors[c.id] = c.last_author}
|
||||
|
||||
@conversation = Conversation.joins(:conversation_visibilities).where(
|
||||
:conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
|
||||
|
|
@ -22,8 +24,13 @@ class ConversationsController < ApplicationController
|
|||
|
||||
@conversation = Conversation.create(params[:conversation])
|
||||
|
||||
flash[:notice] = "Message sent"
|
||||
if params[:profile]
|
||||
redirect_to person_path(params[:profile])
|
||||
else
|
||||
redirect_to conversations_path(:conversation_id => @conversation.id)
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
@conversation = Conversation.joins(:conversation_visibilities).where(:id => params[:id],
|
||||
|
|
@ -37,6 +44,7 @@ class ConversationsController < ApplicationController
|
|||
end
|
||||
|
||||
def new
|
||||
@contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id]
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,21 @@
|
|||
-# the COPYRIGHT file.
|
||||
|
||||
|
||||
%h2
|
||||
#new_message_pane
|
||||
#facebox_header
|
||||
%h4
|
||||
New Message
|
||||
|
||||
= form_for Conversation.new do |conversation|
|
||||
= form_for Conversation.new do |conversation|
|
||||
|
||||
- if @contact
|
||||
send a message to
|
||||
= @contact.person.name
|
||||
|
||||
= hidden_field_tag "conversation[contact_ids]", @contact.id
|
||||
= hidden_field_tag "profile", @contact.person.id
|
||||
|
||||
-else
|
||||
%h4
|
||||
to
|
||||
= text_field_tag "conversation[contact_ids]"
|
||||
|
|
|
|||
|
|
@ -42,10 +42,12 @@
|
|||
|
||||
- else
|
||||
.right
|
||||
- if @post_type == :photos
|
||||
= link_to t('layouts.header.view_profile'), person_path(@person)
|
||||
- else
|
||||
= link_to t('_photos'), person_photos_path(@person)
|
||||
= link_to 'Message', new_conversation_path(:contact_id => @contact.id), :class => 'button', :rel => 'facebox'
|
||||
|
||||
/- if @post_type == :photos
|
||||
/ = link_to t('layouts.header.view_profile'), person_path(@person)
|
||||
/- else
|
||||
/ = link_to t('_photos'), person_photos_path(@person)
|
||||
|
||||
%h3
|
||||
= @person.name
|
||||
|
|
|
|||
Loading…
Reference in a new issue