From 0ddc67e592fc1e44a8156c8c2039b9fb3a0259a7 Mon Sep 17 00:00:00 2001 From: Chris Matthieu Date: Sat, 30 Jun 2012 19:18:31 -0700 Subject: [PATCH] added council_id to all tables --- app/controllers/pages_controller.rb | 10 +- app/controllers/posts_controller.rb | 8 +- app/controllers/sponsors_controller.rb | 2 +- app/views/councils/_form.html.erb | 37 +- app/views/councils/edit.html.erb | 2 +- app/views/councils/index.html.erb | 18 +- app/views/councils/new.html.erb | 2 +- app/views/layouts/application.html.erb | 3 +- app/views/pages/join.html.erb | 4 +- app/views/posts/_form.html.erb | 2 + app/views/sponsors/_form.html.erb | 7 +- app/views/sponsors/edit.html.erb | 2 +- .../20120701011455_add_council_id_to_posts.rb | 5 + ...120701014620_add_council_id_to_sponsors.rb | 5 + db/schema.rb | 4 +- log/development.log | 752 ++++++++++++++++++ 16 files changed, 812 insertions(+), 51 deletions(-) create mode 100644 db/migrate/20120701011455_add_council_id_to_posts.rb create mode 100644 db/migrate/20120701014620_add_council_id_to_sponsors.rb diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 86cf042..024f266 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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 diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index c711ee1..405352f 100644 --- a/app/controllers/posts_controller.rb +++ b/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 @@ -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 } diff --git a/app/controllers/sponsors_controller.rb b/app/controllers/sponsors_controller.rb index 4e758be..7cd4bcf 100644 --- a/app/controllers/sponsors_controller.rb +++ b/app/controllers/sponsors_controller.rb @@ -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 diff --git a/app/views/councils/_form.html.erb b/app/views/councils/_form.html.erb index 254e429..6e4c335 100644 --- a/app/views/councils/_form.html.erb +++ b/app/views/councils/_form.html.erb @@ -13,51 +13,40 @@ <% end %>
- <%= f.label :councilname %>
- <%= f.text_field :councilname %> + <%= f.label :councilname %><%= f.text_field :councilname, :class=>"input-xxlarge" %>
- <%= f.label :councilnumber %>
- <%= f.text_field :councilnumber %> + <%= f.label :councilnumber %><%= f.text_field :councilnumber, :class=>"input-xxlarge" %>
- <%= f.label :twitterurl %>
- <%= f.text_field :twitterurl %> + <%= f.label :twitterurl %><%= f.text_field :twitterurl, :class=>"input-xxlarge" %>
- <%= f.label :facebookurl %>
- <%= f.text_field :facebookurl %> + <%= f.label :facebookurl %><%= f.text_field :facebookurl, :class=>"input-xxlarge" %>
- <%= f.label :linkedinurl %>
- <%= f.text_field :linkedinurl %> + <%= f.label :linkedinurl %><%= f.text_field :linkedinurl, :class=>"input-xxlarge" %>
- <%= f.label :googleplusurl %>
- <%= f.text_field :googleplusurl %> + <%= f.label :googleplusurl %><%= f.text_field :googleplusurl, :class=>"input-xxlarge" %>
- <%= f.label :mobileurl %>
- <%= f.text_field :mobileurl %> + <%= f.label :mobileurl %><%= f.text_field :mobileurl, :class=>"input-xxlarge" %>
- <%= f.label :email %>
- <%= f.text_field :email %> + <%= f.label :email %><%= f.text_field :email, :class=>"input-xxlarge" %>
- <%= f.label :posterousurl %>
- <%= f.text_field :posterousurl %> + <%= f.label :posterousurl %><%= f.text_field :posterousurl, :class=>"input-xxlarge" %>
- <%= f.label :calendarurl %>
- <%= f.text_field :calendarurl %> + <%= f.label :calendarurl %><%= f.text_field :calendarurl, :class=>"input-xxlarge" %>
- <%= f.label :about %>
- <%= f.text_area :about %> + <%= f.label :about %><%= f.text_area :about, :class=>"input-xxlarge" %>
-
-

<%= f.submit %>

+
+

<%= f.submit "Submit", :class=>"btn btn-primary btn-large" %>

<% end %>
\ No newline at end of file diff --git a/app/views/councils/edit.html.erb b/app/views/councils/edit.html.erb index 133f936..7833ded 100644 --- a/app/views/councils/edit.html.erb +++ b/app/views/councils/edit.html.erb @@ -1,4 +1,4 @@ -

Editing council

+

Editing Council


<%= render 'form' %> diff --git a/app/views/councils/index.html.erb b/app/views/councils/index.html.erb index 837cc35..af8bf4c 100644 --- a/app/views/councils/index.html.erb +++ b/app/views/councils/index.html.erb @@ -1,17 +1,12 @@ -

Listing councils

+

Listing Councils


- +
- - - - - @@ -23,15 +18,12 @@ - - - - - - + + + <% end %>
Councilname Councilnumber Twitterurl FacebookurlLinkedinurlGoogleplusurl EmailPosterousurlCalendarurlAbout <%= council.councilnumber %> <%= council.twitterurl %> <%= council.facebookurl %><%= council.linkedinurl %><%= council.googleplusurl %> <%= council.email %><%= council.posterousurl %><%= council.calendarurl %><%= council.about %> <%= link_to 'Show', council %> <%= link_to 'Edit', edit_council_path(council) %><%= link_to 'Destroy', council, :confirm => 'Are you sure?', :method => :delete %><%= link_to 'Destroy', council, confirm: 'Are you sure?', method: :delete %>
diff --git a/app/views/councils/new.html.erb b/app/views/councils/new.html.erb index d91cc97..1a82496 100644 --- a/app/views/councils/new.html.erb +++ b/app/views/councils/new.html.erb @@ -1,4 +1,4 @@ -

New council

+

New Council


<%= render 'form' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 0e61cf9..52ec63a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -85,7 +85,8 @@
  • <%= link_to 'Become a Knight', '/join'%>
  • <% if @current_user && @current_user.admin %> -
  • <%= link_to 'Posts', '/posts'%>
  • +
  • <%= link_to 'Posts*', '/posts'%>
  • +
  • <%= link_to 'Councils*', '/councils'%>
  • <% end %>