From a48fbaaf5992186f446a0e32d400f3ea55022e58 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 10 Aug 2010 11:36:00 -0700 Subject: [PATCH] RS, DG; DashboardsController has been eliminated. --- app/controllers/dashboards_controller.rb | 14 -------------- app/controllers/groups_controller.rb | 9 ++++++++- app/controllers/photos_controller.rb | 4 ++-- app/views/{dashboards => groups}/index.html.haml | 0 app/views/shared/_group_nav.haml | 4 ++-- config/routes.rb | 2 +- 6 files changed, 13 insertions(+), 20 deletions(-) delete mode 100644 app/controllers/dashboards_controller.rb rename app/views/{dashboards => groups}/index.html.haml (100%) diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb deleted file mode 100644 index 6801f734f..000000000 --- a/app/controllers/dashboards_controller.rb +++ /dev/null @@ -1,14 +0,0 @@ -class DashboardsController < ApplicationController - before_filter :authenticate_user! - include ApplicationHelper - - def index - if params[:group] - @people_ids = @group.people.map {|p| p.id} - - @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' - else - @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' - end - end -end diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index e12809fb6..27f5ae782 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -1,12 +1,16 @@ class GroupsController < ApplicationController before_filter :authenticate_user! + def index + @posts = Post.paginate :page => params[:page], :order => 'created_at DESC' + end + def create @group = current_user.group(params[:group]) if @group.created_at flash[:notice] = "Successfully created group." - redirect_to root_url + redirect_to @group else render :action => 'new' end @@ -24,7 +28,10 @@ class GroupsController < ApplicationController end def show + @people_ids = @group.people.map {|p| p.id} + @posts = Post.paginate :person_id => @people_ids, :order => 'created_at DESC' @group = Group.first(:id => params[:id]) + render :index end def edit diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 128115d6a..995690213 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -25,14 +25,14 @@ class PhotosController < ApplicationController end def destroy - @photo = Photo.where(:id => params[:id]).first + @photo = Photo.first(:id => params[:id]) @photo.destroy flash[:notice] = "Successfully deleted photo." redirect_to @photo.album end def show - @photo = Photo.where(:id => params[:id]).first + @photo = Photo.first(:id => params[:id]) @album = @photo.album end diff --git a/app/views/dashboards/index.html.haml b/app/views/groups/index.html.haml similarity index 100% rename from app/views/dashboards/index.html.haml rename to app/views/groups/index.html.haml diff --git a/app/views/shared/_group_nav.haml b/app/views/shared/_group_nav.haml index a98690150..782025581 100644 --- a/app/views/shared/_group_nav.haml +++ b/app/views/shared/_group_nav.haml @@ -1,8 +1,8 @@ #group %ul - for group in @groups - %li{:class => ("selected" if group.id.to_s == params[:group])} - = link_to group.name, root_path(:group =>group.id) + %li{:class => ("selected" if group.id.to_s == params[:id])} + = link_to group.name, group %li#add_group_button.new_group= link_to "NEW GROUP", "#" diff --git a/config/routes.rb b/config/routes.rb index 50811fa73..fb7d71fc6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -32,5 +32,5 @@ Diaspora::Application.routes.draw do |map| match 'hcard', :to => 'publics#hcard' #root - root :to => 'dashboards#index' + root :to => 'groups#index' end