started adding antechamber to team

This commit is contained in:
Mark Ryall
2012-10-18 23:51:15 +11:00
parent 40be3fd943
commit 30b7f6ef28
10 changed files with 63 additions and 13 deletions
+12
View File
@@ -0,0 +1,12 @@
require 'team_filter'
class AntechamberController < ApplicationController
include TeamFilter
def index
with_team do |team|
@message = Message.new
@messages = team.messages
end
end
end
+4 -12
View File
@@ -1,4 +1,8 @@
require 'team_filter'
class TeamsController < ApplicationController
include TeamFilter
def index
@memberships = current_person.memberships
@team = Team.new
@@ -45,16 +49,4 @@ class TeamsController < ApplicationController
render :quiz
end
end
private
def with_team *args
@team = Team.find_by_slug params[:slug]
unless current_person.blessed?
@team = nil unless current_person.teams.include?(@team) or @team.creator == current_person
end
if @team
yield @team
else
render :unknown
end
end
end
+3
View File
@@ -0,0 +1,3 @@
class Message < ActiveRecord::Base
belongs_to :person
end
+1
View File
@@ -7,6 +7,7 @@ class Team < ActiveRecord::Base
has_many :memberships
has_many :people, through: :memberships
has_many :messages
belongs_to :creator, class_name: 'Person'
def api_attributes params={}
+6
View File
@@ -0,0 +1,6 @@
h1 = @team.name
- @messages.each do |message|
blockquote
p = message.content
small Someone famous <cite title="Source Title">#{message.person.full_name}</cite>
+2
View File
@@ -5,6 +5,8 @@
= link_to 'avatars', "/avatars/#{@team.slug}"
li
= link_to 'quiz', "/quiz/#{@team.slug}"
li
= link_to 'antechamber', "/antechamber/#{@team.slug}"
- content_for :javascript_includes do
= javascript_include_tag 'teams_show'
+2
View File
@@ -30,5 +30,7 @@ Ocelots::Application.routes.draw do
get 'quiz/:slug' => 'teams#quiz'
get 'antechamber/:slug' => 'antechamber#index'
root to: 'home#index'
end
@@ -0,0 +1,11 @@
class CreateMessages < ActiveRecord::Migration
def change
create_table :messages do |t|
t.integer :person_id
t.integer :team_id
t.text :content
t.timestamps
end
end
end
+9 -1
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20121002100106) do
ActiveRecord::Schema.define(:version => 20121018121645) do
create_table "facts", :force => true do |t|
t.integer "person_id"
@@ -34,6 +34,14 @@ ActiveRecord::Schema.define(:version => 20121002100106) do
t.string "role"
end
create_table "messages", :force => true do |t|
t.integer "person_id"
t.integer "team_id"
t.text "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
# Could not dump table "people" because of following StandardError
# Unknown type 'real' for column 'lat'
+13
View File
@@ -0,0 +1,13 @@
module TeamFilter
def with_team
@team = Team.find_by_slug params[:slug]
unless current_person.blessed?
@team = nil unless current_person.teams.include?(@team) or @team.creator == current_person
end
if @team
yield @team
else
render :unknown
end
end
end