mirror of
https://github.com/wahyd4/ocelots.git
synced 2026-08-09 04:56:21 +10:00
started adding antechamber to team
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -0,0 +1,3 @@
|
||||
class Message < ActiveRecord::Base
|
||||
belongs_to :person
|
||||
end
|
||||
@@ -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={}
|
||||
|
||||
@@ -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>
|
||||
@@ -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'
|
||||
|
||||
@@ -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
@@ -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'
|
||||
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user