Sha256: 23fedf8f50848fb2c2920bced4fe66283c23d8334ac2a4d1f0650e2f1f9d52a4

Contents?: true

Size: 967 Bytes

Versions: 23

Compression:

Stored size: 967 Bytes

Contents

class GroupsController < ReaderActionController
  helper :reader
  
  before_filter :require_reader
  before_filter :get_group_or_groups
  before_filter :require_group_visibility, :only => [:show]

  def index
  end

  def show
    @readers = @group.readers.uniq
    respond_to do |format|
      format.html
      format.csv {
        send_data Reader.csv_for(@readers), :type => 'text/csv; charset=utf-8; header=present', :filename => "#{@group.filename}.csv"
      }
      format.vcard {
        send_data Reader.vcards_for(@readers), :filename => "everyone.vcf"
      }
    end
  end
    
private
  
  def get_group_or_groups
    @groups = current_reader.all_visible_groups
    @group = Group.find(params[:id]) if params[:id]
  end

  def require_group_visibility
     if @group && !@group.visible_to?(current_reader)    # nb. @groups is a smaller set
       raise ReaderError::AccessDenied, "That group is not public and you are not in it."
     end
  end
  
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
radiant-reader-extension-3.0.9 app/controllers/groups_controller.rb
radiant-reader-extension-3.0.8 app/controllers/groups_controller.rb
radiant-reader-extension-3.0.7 app/controllers/groups_controller.rb