added PrivateMessage and PrivateMessageVisibility models and migrations

This commit is contained in:
danielvincent 2011-02-25 11:49:47 -08:00
parent a7f149e399
commit 9fe0320881
15 changed files with 133 additions and 9 deletions

View file

@ -0,0 +1,2 @@
class PrivateMessagesController < ApplicationController
end

View file

@ -0,0 +1,2 @@
module PrivateMessagesHelper
end

View 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

View file

@ -0,0 +1,6 @@
class PrivateMessageVisibility < ActiveRecord::Base
belongs_to :private_message
belongs_to :person
end

View 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.

View 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

View 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.

View 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'

View file

@ -3,6 +3,8 @@
# the COPYRIGHT file.
Diaspora::Application.routes.draw do
resources :private_messages
resources :status_messages, :only => [:create, :destroy, :show]
resources :comments, :only => [:create]
resources :requests, :only => [:destroy, :create]

View 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

View file

@ -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

View file

@ -10,7 +10,11 @@
#
# It's strongly recommended to check this file into your version control system.
<<<<<<< HEAD
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|
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"], :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|
t.string "diaspora_handle"
t.string "first_name", :limit => 127

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe PrivateMessagesController do
end

View 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

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe PrivateMessage do
pending "add some examples to (or delete) #{__FILE__}"
end