2012-05-02 10:18:07 +01:00
|
|
|
# -*- encoding : utf-8 -*-
|
|
|
|
class Groups::ProfileController < Groups::BaseController
|
2012-10-03 17:38:42 +01:00
|
|
|
include AvatarHelper
|
2012-10-02 16:14:08 +01:00
|
|
|
load_and_authorize_resource :class => Group, :instance_name => 'group'
|
2012-10-02 13:04:26 +01:00
|
|
|
skip_before_filter :authenticate_user!, :only => :show if APP_CONFIG['anonymous_access']
|
2012-05-02 10:18:07 +01:00
|
|
|
|
|
|
|
def index
|
|
|
|
@groups = current_user.groups.paginate(:page => params[:group_page]) # accessible_by(current_ability)
|
|
|
|
@groups = @groups.search(params[:query]) if params[:query].present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2013-07-01 11:50:35 +01:00
|
|
|
@projects = @group.projects.opened.search(params[:search])
|
|
|
|
.paginate(:page => params[:page], :per_page => 25)
|
|
|
|
@projects = @projects.recent if params[:search].blank?
|
2012-05-02 10:18:07 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2012-10-16 17:38:49 +01:00
|
|
|
@group = current_user.own_groups.new params[:group]
|
2012-05-02 10:18:07 +01:00
|
|
|
if @group.save
|
|
|
|
flash[:notice] = t('flash.group.saved')
|
|
|
|
redirect_to group_path(@group)
|
|
|
|
else
|
|
|
|
flash[:error] = t('flash.group.save_error')
|
|
|
|
flash[:warning] = @group.errors.full_messages.join('. ')
|
|
|
|
render :action => :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if @group.update_attributes(params[:group])
|
2012-10-03 17:38:42 +01:00
|
|
|
update_avatar(@group, params)
|
2012-05-02 10:18:07 +01:00
|
|
|
flash[:notice] = t('flash.group.saved')
|
|
|
|
redirect_to group_path(@group)
|
|
|
|
else
|
|
|
|
flash[:error] = t('flash.group.save_error')
|
|
|
|
render :action => :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@group.destroy
|
|
|
|
flash[:notice] = t("flash.group.destroyed")
|
|
|
|
redirect_to groups_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def remove_user
|
2012-07-27 05:12:09 +01:00
|
|
|
Relation.by_actor(current_user).by_target(@group).destroy_all
|
2012-05-02 10:18:07 +01:00
|
|
|
redirect_to groups_path
|
|
|
|
end
|
|
|
|
end
|