diff --git a/app/controllers/antechamber_controller.rb b/app/controllers/antechamber_controller.rb new file mode 100644 index 0000000..d0f57fd --- /dev/null +++ b/app/controllers/antechamber_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 74194f6..4dd68f0 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -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 \ No newline at end of file diff --git a/app/models/message.rb b/app/models/message.rb new file mode 100644 index 0000000..35d3c2c --- /dev/null +++ b/app/models/message.rb @@ -0,0 +1,3 @@ +class Message < ActiveRecord::Base + belongs_to :person +end \ No newline at end of file diff --git a/app/models/team.rb b/app/models/team.rb index 914faba..03fda4e 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -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={} diff --git a/app/views/antechamber/index.html.slim b/app/views/antechamber/index.html.slim new file mode 100644 index 0000000..e61ca8f --- /dev/null +++ b/app/views/antechamber/index.html.slim @@ -0,0 +1,6 @@ +h1 = @team.name + +- @messages.each do |message| + blockquote + p = message.content + small Someone famous #{message.person.full_name} diff --git a/app/views/teams/show.html.slim b/app/views/teams/show.html.slim index 41efb77..ec85a56 100644 --- a/app/views/teams/show.html.slim +++ b/app/views/teams/show.html.slim @@ -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' diff --git a/config/routes.rb b/config/routes.rb index 2b72ce4..f5a5d02 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -30,5 +30,7 @@ Ocelots::Application.routes.draw do get 'quiz/:slug' => 'teams#quiz' + get 'antechamber/:slug' => 'antechamber#index' + root to: 'home#index' end \ No newline at end of file diff --git a/db/migrate/20121018121645_create_messages.rb b/db/migrate/20121018121645_create_messages.rb new file mode 100644 index 0000000..a0e250c --- /dev/null +++ b/db/migrate/20121018121645_create_messages.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 7211cbd..772d3f4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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' diff --git a/lib/team_filter.rb b/lib/team_filter.rb new file mode 100644 index 0000000..2a75e63 --- /dev/null +++ b/lib/team_filter.rb @@ -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 \ No newline at end of file