added PrivateMessage and PrivateMessageVisibility models and migrations
This commit is contained in:
parent
a7f149e399
commit
9fe0320881
15 changed files with 133 additions and 9 deletions
2
app/controllers/private_messages_controller.rb
Normal file
2
app/controllers/private_messages_controller.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
class PrivateMessagesController < ApplicationController
|
||||||
|
end
|
||||||
2
app/helpers/private_messages_helper.rb
Normal file
2
app/helpers/private_messages_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
module PrivateMessagesHelper
|
||||||
|
end
|
||||||
5
app/models/private_message.rb
Normal file
5
app/models/private_message.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
class PrivateMessage < ActiveRecord::Base
|
||||||
|
belongs_to :author, :class_name => 'Person'
|
||||||
|
has_many :private_message_visibilities
|
||||||
|
has_many :recipients, :class_name => 'Person', :through => :private_message_visibilities, :source => :person
|
||||||
|
end
|
||||||
6
app/models/private_message_visibility.rb
Normal file
6
app/models/private_message_visibility.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
class PrivateMessageVisibility < ActiveRecord::Base
|
||||||
|
|
||||||
|
belongs_to :private_message
|
||||||
|
belongs_to :person
|
||||||
|
|
||||||
|
end
|
||||||
5
app/views/private_messages/index.haml
Normal file
5
app/views/private_messages/index.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
19
app/views/private_messages/new.haml
Normal file
19
app/views/private_messages/new.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
|
%h2
|
||||||
|
New Message
|
||||||
|
|
||||||
|
= form_for PrivateMessage.new do |private_message|
|
||||||
|
%h4
|
||||||
|
to
|
||||||
|
= private_message.text_field :recipients
|
||||||
|
|
||||||
|
%h4
|
||||||
|
message
|
||||||
|
= private_message.text_area :message, :rows => 5
|
||||||
|
|
||||||
|
= link_to 'cancel', private_messages_path
|
||||||
|
= private_message.submit :send
|
||||||
5
app/views/private_messages/show.haml
Normal file
5
app/views/private_messages/show.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
-# Copyright (c) 2010, Diaspora Inc. This file is
|
|
||||||
-# licensed under the Affero General Public License version 3 or later. See
|
|
||||||
-# the COPYRIGHT file.
|
|
||||||
|
|
||||||
= form_for StatusMessage.new, :remote => true do |f|
|
|
||||||
= f.error_messages
|
|
||||||
%p
|
|
||||||
= f.text_field :message, :value => t('.tell_me_something_good')
|
|
||||||
= f.submit t('.oh_yeah'), :class => 'button'
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
Diaspora::Application.routes.draw do
|
Diaspora::Application.routes.draw do
|
||||||
|
resources :private_messages
|
||||||
|
|
||||||
resources :status_messages, :only => [:create, :destroy, :show]
|
resources :status_messages, :only => [:create, :destroy, :show]
|
||||||
resources :comments, :only => [:create]
|
resources :comments, :only => [:create]
|
||||||
resources :requests, :only => [:destroy, :create]
|
resources :requests, :only => [:destroy, :create]
|
||||||
|
|
|
||||||
18
db/migrate/20110225190919_create_private_messages.rb
Normal file
18
db/migrate/20110225190919_create_private_messages.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
class CreatePrivateMessages < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :private_messages do |t|
|
||||||
|
t.integer :author_id, :null => false
|
||||||
|
t.boolean :unread, :null => false, :default => true
|
||||||
|
t.string :guid, :null => false
|
||||||
|
t.text :message, :null => false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :private_messages, :author_id
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :private_messages
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
class CreatePrivateMessageVisibilities < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
create_table :private_message_visibilities do |t|
|
||||||
|
t.integer :private_message_id
|
||||||
|
t.integer :person_id
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index :private_message_visibilities, :person_id
|
||||||
|
add_index :private_message_visibilities, :private_message_id
|
||||||
|
add_index :private_message_visibilities, [:private_message_id, :person_id], :name => 'pm_visibilities_on_pm_id_and_person_id', :unique => true
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
drop_table :private_message_visibilities
|
||||||
|
end
|
||||||
|
end
|
||||||
26
db/schema.rb
26
db/schema.rb
|
|
@ -10,7 +10,11 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
ActiveRecord::Schema.define(:version => 20110228201109) do
|
ActiveRecord::Schema.define(:version => 20110228201109) do
|
||||||
|
=======
|
||||||
|
ActiveRecord::Schema.define(:version => 20110225193130) do
|
||||||
|
>>>>>>> added PrivateMessage and PrivateMessageVisibility models and migrations
|
||||||
|
|
||||||
create_table "aspect_memberships", :force => true do |t|
|
create_table "aspect_memberships", :force => true do |t|
|
||||||
t.integer "aspect_id", :null => false
|
t.integer "aspect_id", :null => false
|
||||||
|
|
@ -383,6 +387,28 @@ ActiveRecord::Schema.define(:version => 20110228201109) do
|
||||||
add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id"
|
add_index "posts", ["type", "pending", "id"], :name => "index_posts_on_type_and_pending_and_id"
|
||||||
add_index "posts", ["type"], :name => "index_posts_on_type"
|
add_index "posts", ["type"], :name => "index_posts_on_type"
|
||||||
|
|
||||||
|
create_table "private_message_visibilities", :force => true do |t|
|
||||||
|
t.integer "private_message_id"
|
||||||
|
t.integer "person_id"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "private_message_visibilities", ["person_id"], :name => "index_private_message_visibilities_on_person_id"
|
||||||
|
add_index "private_message_visibilities", ["private_message_id", "person_id"], :name => "pm_visibilities_on_pm_id_and_person_id", :unique => true
|
||||||
|
add_index "private_message_visibilities", ["private_message_id"], :name => "index_private_message_visibilities_on_private_message_id"
|
||||||
|
|
||||||
|
create_table "private_messages", :force => true do |t|
|
||||||
|
t.integer "author_id", :null => false
|
||||||
|
t.boolean "unread", :default => true, :null => false
|
||||||
|
t.string "guid", :null => false
|
||||||
|
t.text "message", :null => false
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "private_messages", ["author_id"], :name => "index_private_messages_on_author_id"
|
||||||
|
|
||||||
create_table "profiles", :force => true do |t|
|
create_table "profiles", :force => true do |t|
|
||||||
t.string "diaspora_handle"
|
t.string "diaspora_handle"
|
||||||
t.string "first_name", :limit => 127
|
t.string "first_name", :limit => 127
|
||||||
|
|
|
||||||
5
spec/controllers/private_messages_controller_spec.rb
Normal file
5
spec/controllers/private_messages_controller_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe PrivateMessagesController do
|
||||||
|
|
||||||
|
end
|
||||||
15
spec/helpers/private_messages_helper_spec.rb
Normal file
15
spec/helpers/private_messages_helper_spec.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
# Specs in this file have access to a helper object that includes
|
||||||
|
# the PrivateMessagesHelper. For example:
|
||||||
|
#
|
||||||
|
# describe PrivateMessagesHelper do
|
||||||
|
# describe "string concat" do
|
||||||
|
# it "concats two strings with spaces" do
|
||||||
|
# helper.concat_strings("this","that").should == "this that"
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
describe PrivateMessagesHelper do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
5
spec/models/private_message_spec.rb
Normal file
5
spec/models/private_message_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe PrivateMessage do
|
||||||
|
pending "add some examples to (or delete) #{__FILE__}"
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue