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
|
def index
|
||||||
@conversations = Conversation.joins(:conversation_visibilities).where(
|
@conversations = Conversation.joins(:conversation_visibilities).where(
|
||||||
:conversation_visibilities => {:person_id => current_user.person.id}).paginate(
|
: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 = Conversation.joins(:conversation_visibilities).where(
|
||||||
:conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
|
:conversation_visibilities => {:person_id => current_user.person.id, :conversation_id => params[:conversation_id]}).first
|
||||||
|
|
@ -22,7 +24,12 @@ class ConversationsController < ApplicationController
|
||||||
|
|
||||||
@conversation = Conversation.create(params[:conversation])
|
@conversation = Conversation.create(params[:conversation])
|
||||||
|
|
||||||
redirect_to conversations_path(:conversation_id => @conversation.id)
|
flash[:notice] = "Message sent"
|
||||||
|
if params[:profile]
|
||||||
|
redirect_to person_path(params[:profile])
|
||||||
|
else
|
||||||
|
redirect_to conversations_path(:conversation_id => @conversation.id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
|
@ -37,6 +44,7 @@ class ConversationsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@contact = current_user.contacts.find(params[:contact_id]) if params[:contact_id]
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,32 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
%h2
|
#new_message_pane
|
||||||
New Message
|
#facebox_header
|
||||||
|
%h4
|
||||||
|
New Message
|
||||||
|
|
||||||
= form_for Conversation.new do |conversation|
|
= form_for Conversation.new do |conversation|
|
||||||
%h4
|
|
||||||
to
|
|
||||||
= text_field_tag "conversation[contact_ids]"
|
|
||||||
|
|
||||||
%h4
|
- if @contact
|
||||||
subject
|
send a message to
|
||||||
= conversation.text_field :subject
|
= @contact.person.name
|
||||||
|
|
||||||
%h4
|
= hidden_field_tag "conversation[contact_ids]", @contact.id
|
||||||
message
|
= hidden_field_tag "profile", @contact.person.id
|
||||||
= text_area_tag "conversation[text]", '', :rows => 5
|
|
||||||
|
|
||||||
= conversation.submit :send
|
-else
|
||||||
= link_to 'cancel', conversations_path
|
%h4
|
||||||
|
to
|
||||||
|
= text_field_tag "conversation[contact_ids]"
|
||||||
|
|
||||||
|
%h4
|
||||||
|
subject
|
||||||
|
= conversation.text_field :subject
|
||||||
|
|
||||||
|
%h4
|
||||||
|
message
|
||||||
|
= text_area_tag "conversation[text]", '', :rows => 5
|
||||||
|
|
||||||
|
= conversation.submit :send
|
||||||
|
= link_to 'cancel', conversations_path
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,12 @@
|
||||||
|
|
||||||
- else
|
- else
|
||||||
.right
|
.right
|
||||||
- if @post_type == :photos
|
= link_to 'Message', new_conversation_path(:contact_id => @contact.id), :class => 'button', :rel => 'facebox'
|
||||||
= link_to t('layouts.header.view_profile'), person_path(@person)
|
|
||||||
- else
|
/- if @post_type == :photos
|
||||||
= link_to t('_photos'), person_photos_path(@person)
|
/ = link_to t('layouts.header.view_profile'), person_path(@person)
|
||||||
|
/- else
|
||||||
|
/ = link_to t('_photos'), person_photos_path(@person)
|
||||||
|
|
||||||
%h3
|
%h3
|
||||||
= @person.name
|
= @person.name
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue