Commit d50863cc authored by danielgrippi's avatar danielgrippi

added the ability to message someone from their profile page

parent 48fff29b
......@@ -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,7 +24,12 @@ class ConversationsController < ApplicationController
@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
def show
......@@ -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,21 +3,32 @@
-# the COPYRIGHT file.
%h2
New Message
#new_message_pane
#facebox_header
%h4
New Message
= form_for Conversation.new do |conversation|
%h4
to
= text_field_tag "conversation[contact_ids]"
= form_for Conversation.new do |conversation|
%h4
subject
= conversation.text_field :subject
- if @contact
send a message to
= @contact.person.name
%h4
message
= text_area_tag "conversation[text]", '', :rows => 5
= hidden_field_tag "conversation[contact_ids]", @contact.id
= hidden_field_tag "profile", @contact.person.id
= conversation.submit :send
= link_to 'cancel', conversations_path
-else
%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
.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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment