Skip to content

Commit

Permalink
added council_id to all tables
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismatthieu committed Jul 1, 2012
1 parent 8d229f8 commit 0ddc67e
Show file tree
Hide file tree
Showing 16 changed files with 812 additions and 51 deletions.
10 changes: 8 additions & 2 deletions app/controllers/pages_controller.rb
Expand Up @@ -4,9 +4,15 @@ class PagesController < ApplicationController
before_filter :current_council

def index
@post = Post.first :conditions => ["privateflag = ?", false], :order => 'created_at DESC'

# render :layout => false
@post = Post.first :conditions => ["privateflag = ? and council_id = ?", false, @council.id], :order => 'created_at DESC'

if @council and @council.id > 1
render "social"
else
render "index"
end

end

def about
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/posts_controller.rb
@@ -1,13 +1,15 @@
class PostsController < ApplicationController

before_filter :current_user
before_filter :current_council


# GET /posts
# GET /posts.json
def index
# @posts = Post.order("created_at DESC")
# @posts = Post.all :page => params[:page], :order => 'created_at DESC'
@posts = Post.paginate :page => params[:page], :per_page => 3, :order => 'created_at DESC'
@posts = Post.paginate :page => params[:page], :per_page => 3, :conditions => ['council_id = ?', @council.id], :order => 'created_at DESC'

respond_to do |format|
format.html # index.html.erb
Expand Down Expand Up @@ -79,7 +81,9 @@ def update
# DELETE /posts/1.json
def destroy
@post = Post.find(params[:id])
@post.destroy
if @current_user.council_id == @post.council_id or @current_user.admin
@post.destroy
end

respond_to do |format|
format.html { redirect_to posts_url }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sponsors_controller.rb
Expand Up @@ -6,7 +6,7 @@ class SponsorsController < ApplicationController
# GET /sponsors
# GET /sponsors.json
def index
@sponsors = Sponsor.all
@sponsors = Sponsor.order("sponsorname").where("council_id = ?", @council.id)

respond_to do |format|
format.html # index.html.erb
Expand Down
37 changes: 13 additions & 24 deletions app/views/councils/_form.html.erb
Expand Up @@ -13,51 +13,40 @@
<% end %>

<div class="field">
<%= f.label :councilname %><br />
<%= f.text_field :councilname %>
<%= f.label :councilname %><%= f.text_field :councilname, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :councilnumber %><br />
<%= f.text_field :councilnumber %>
<%= f.label :councilnumber %><%= f.text_field :councilnumber, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :twitterurl %><br />
<%= f.text_field :twitterurl %>
<%= f.label :twitterurl %><%= f.text_field :twitterurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :facebookurl %><br />
<%= f.text_field :facebookurl %>
<%= f.label :facebookurl %><%= f.text_field :facebookurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :linkedinurl %><br />
<%= f.text_field :linkedinurl %>
<%= f.label :linkedinurl %><%= f.text_field :linkedinurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :googleplusurl %><br />
<%= f.text_field :googleplusurl %>
<%= f.label :googleplusurl %><%= f.text_field :googleplusurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :mobileurl %><br />
<%= f.text_field :mobileurl %>
<%= f.label :mobileurl %><%= f.text_field :mobileurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :email %><br />
<%= f.text_field :email %>
<%= f.label :email %><%= f.text_field :email, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :posterousurl %><br />
<%= f.text_field :posterousurl %>
<%= f.label :posterousurl %><%= f.text_field :posterousurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :calendarurl %><br />
<%= f.text_field :calendarurl %>
<%= f.label :calendarurl %><%= f.text_field :calendarurl, :class=>"input-xxlarge" %>
</div>
<div class="field">
<%= f.label :about %><br />
<%= f.text_area :about %>
<%= f.label :about %><%= f.text_area :about, :class=>"input-xxlarge" %>
</div>
<div class="actions">
<p><%= f.submit %></p>
<div>
<p><%= f.submit "Submit", :class=>"btn btn-primary btn-large" %></p>
</div>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/councils/edit.html.erb
@@ -1,4 +1,4 @@
<h1>Editing council</h1>
<h1>Editing Council</h1><br />

<%= render 'form' %>
Expand Down
18 changes: 5 additions & 13 deletions app/views/councils/index.html.erb
@@ -1,17 +1,12 @@
<h1>Listing councils</h1>
<h1>Listing Councils</h1><br />

<table>
<table class="table table-striped">
<tr>
<th>Councilname</th>
<th>Councilnumber</th>
<th>Twitterurl</th>
<th>Facebookurl</th>
<th>Linkedinurl</th>
<th>Googleplusurl</th>
<th>Email</th>
<th>Posterousurl</th>
<th>Calendarurl</th>
<th>About</th>
<th></th>
<th></th>
<th></th>
Expand All @@ -23,15 +18,12 @@
<td><%= council.councilnumber %></td>
<td><%= council.twitterurl %></td>
<td><%= council.facebookurl %></td>
<td><%= council.linkedinurl %></td>
<td><%= council.googleplusurl %></td>
<td><%= council.email %></td>
<td><%= council.posterousurl %></td>
<td><%= council.calendarurl %></td>
<td><%= council.about %></td>
<td><%= link_to 'Show', council %></td>
<td><%= link_to 'Edit', edit_council_path(council) %></td>
<td><%= link_to 'Destroy', council, :confirm => 'Are you sure?', :method => :delete %></td>
<td><%= link_to 'Destroy', council, confirm: 'Are you sure?', method: :delete %></td>


</tr>
<% end %>
</table>
Expand Down
2 changes: 1 addition & 1 deletion app/views/councils/new.html.erb
@@ -1,4 +1,4 @@
<h1>New council</h1>
<h1>New Council</h1><br />

<%= render 'form' %>
Expand Down
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Expand Up @@ -85,7 +85,8 @@
<li><%= link_to 'Become a Knight', '/join'%> </li>

<% if @current_user && @current_user.admin %>
<li><%= link_to 'Posts', '/posts'%> </li>
<li><%= link_to 'Posts*', '/posts'%> </li>
<li><%= link_to 'Councils*', '/councils'%> </li>
<% end %>
</ul>
<ul class="nav pull-right">
Expand Down
4 changes: 3 additions & 1 deletion app/views/pages/join.html.erb
@@ -1,4 +1,6 @@
<h1>Join the Knights of Columbus</h1>
<h1>
Join the Knights of Columbus
</h1>
<!-- <button>Get Started!</button> -->
<div id="joincontact" style="display:none">
<br />
Expand Down
2 changes: 2 additions & 0 deletions app/views/posts/_form.html.erb
Expand Up @@ -11,6 +11,8 @@
</div>
<% end %>
<%= f.hidden_field :council_id, :value => @council.id %>

<div>
<%= f.text_field :postname, :class=>"input-xxlarge", :placeholder=>"title", :autofocus => true %>
</div>
Expand Down
7 changes: 4 additions & 3 deletions app/views/sponsors/_form.html.erb
Expand Up @@ -11,14 +11,15 @@
</div>
<% end %>
<%= f.hidden_field :council_id, :value => @council.id %>
<div class="field">
<%= f.text_field :sponsorname, :autofocus => true, :class=>"input-large focus", :placeholder=>"Spondor name" %>
<%= f.text_field :sponsorname, :autofocus => true, :class=>"input-xxlarge", :autofocus => true, :placeholder=>"Spondor name" %>
</div>
<div class="field">
<%= f.text_field :url, :class=>"input-large", :placeholder=>"Spondor website" %>
<%= f.text_field :url, :class=>"input-xxlarge", :placeholder=>"Spondor website" %>
</div>
<div class="field">
<%= f.text_area :description, :class=>"input-large", :placeholder=>"Spondor descrtiption" %>
<%= f.text_area :description, :class=>"input-xxlarge", :placeholder=>"Spondor descrtiption" %>
</div>
<div>
<p><%= f.submit "Submit", :class=>"btn btn-primary btn-large" %></p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sponsors/edit.html.erb
@@ -1,4 +1,4 @@
<h1>Editing sponsor</h1>
<h1>Editing Sponsor</h1><br />

<%= render 'form' %>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20120701011455_add_council_id_to_posts.rb
@@ -0,0 +1,5 @@
class AddCouncilIdToPosts < ActiveRecord::Migration
def change
add_column :posts, :council_id, :integer
end
end
5 changes: 5 additions & 0 deletions db/migrate/20120701014620_add_council_id_to_sponsors.rb
@@ -0,0 +1,5 @@
class AddCouncilIdToSponsors < ActiveRecord::Migration
def change
add_column :sponsors, :council_id, :integer
end
end
4 changes: 3 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120619205126) do
ActiveRecord::Schema.define(:version => 20120701014620) do

create_table "councils", :force => true do |t|
t.string "councilname"
Expand Down Expand Up @@ -47,6 +47,7 @@
t.datetime "updated_at"
t.integer "user_id"
t.boolean "privateflag"
t.integer "council_id"
end

create_table "sponsors", :force => true do |t|
Expand All @@ -55,6 +56,7 @@
t.text "description"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "council_id"
end

create_table "users", :force => true do |t|
Expand Down

0 comments on commit 0ddc67e

Please sign in to comment.