app/controllers/collections_controller.rb
# TODO - this should be its own controller (or possibly two with a shared view).
# Either a user is passed in and we're making her a manager, or a community is passed in and we're "featuring" it.
this should be its own controller (or possibly two with a shared view).
Either a user is passed in and we're making her a manager, or a community is passed in and we're "featuring" it.
this should be its own controller ( or possibly two with a shared view ) . Either a user is passed in and we ' re making her a manager or a community is passed in and we ' re " featuring " it .
def choose_editor_target
    return must_be_logged_in unless logged_in?
    @user = User.find(params[:user_id]) rescue nil
    @sorts = {
      I18n.t(:sort_by_alphabetical_option) => :alpha,
      I18n.t(:sort_by_recently_updated_option) => :recent,
    }
    @community = Community.find(params[:community_id]) rescue nil
    @item = @user || @community 
    @collections = current_user.all_collections
    Collection.preload_associations(@collections, [ :resource, :resource_preview ])
    @collections.delete_if{ |c| c.is_resource_collection? || c.watch_collection? }
    @collections_recently_updated = @collections.sort_by(&:updated_at).reverse
    raise EOL::Exceptions::NoCollectionsApply if @collections.blank?
    @page_title = I18n.t(:make_user_an_editor_title, user: @item.summary_name)
    respond_to do |format|
      format.html { render 'choose_editor_target', layout: 'users' }
      format.js   { render partial: 'choose_editor_target' }
    end
  end
def choose_editor_target return must_be_logged_in unless logged_in? @user = User . find ( params [ :user_id ] ) rescue nil @sorts = { I18n . t ( :sort_by_alphabetical_option ) => :alpha , I18n . t ( :sort_by_recently_updated_option ) => :recent , } @community = Community . find ( params [ :community_id ] ) rescue nil @item = @user || @community @collections = current_user . all_collections Collection . preload_associations ( @collections , [ :resource , :resource_preview ] ) @collections . delete_if { | c | c . is_resource_collection? || c . watch_collection? } @collections_recently_updated = @collections . sort_by ( & :updated_at ) . reverse raise EOL :: Exceptions :: NoCollectionsApply if @collections . blank? @page_title = I18n . t ( :make_user_an_editor_title , user : @item . summary_name ) respond_to do | format | format . html { render 'choose_editor_target' , layout : 'users' } format . js { render partial : 'choose_editor_target' } end end
TODO - this should be its own controller (or possibly two with a shared view).
TODO - this should be its own controller ( or possibly two with a shared view ) .
# @item is for views, makes life easier.