app/controllers/collections_controller.rb
# TODO - review these. There are too many and as a result there's some redundancy in, for example, checking whether the user is logged in on unpublished
# collections
review these. There are too many and as a result there's some redundancy in, for example, checking whether the user is logged in on unpublished
collections
review these . There are too many and as a result there ' s some redundancy in for example checking whether the user is logged in on unpublished collections
def annotate
    Collection.with_master do
      Collection.uncached do
        if @collection.update_attributes(params[:collection])
          @collection_item = CollectionItem.find(params[:collection][:collection_items_attributes].keys.map { |i|
                params[:collection][:collection_items_attributes][i][:id] }.first)
          if @collection.show_references
            @collection_item.refs.clear
            unless params[:references].blank?
              params[:references].split("\n").each do |original_ref|
                reference = original_ref.strip
                unless reference.blank?
                  ref = Ref.find_or_create_by_full_reference_and_user_submitted_and_published_and_visibility_id(reference, 1, 1, Visibility.get_visible.id)
                  @collection_item.refs << ref
                  @collection_item.save!
                end
              end
            end
          end
          respond_to do |format|
            format.js do
              render partial: 'collection_items/show_editable_attributes',
                locals: { collection_item: @collection_item, item_editable: true }
            end
          end
        else
          respond_to do |format|
            format.js { render text: I18n.t(:item_not_updated_in_collection_error) }
            format.html do
              flash[:error] = I18n.t(:item_not_updated_in_collection_error)
              redirect_to @collection
            end
          end
        end
      end
    end
  end
def annotate Collection . with_master do Collection . uncached do if @collection . update_attributes ( params [ :collection ] ) @collection_item = CollectionItem . find ( params [ :collection ] [ :collection_items_attributes ] . keys . map { | i | params [ :collection ] [ :collection_items_attributes ] [ i ] [ :id ] } . first ) if @collection . show_references @collection_item . refs . clear unless params [ :references ] . blank? params [ :references ] . split ( "\n" ) . each do | original_ref | reference = original_ref . strip unless reference . blank? ref = Ref . find_or_create_by_full_reference_and_user_submitted_and_published_and_visibility_id ( reference , 1 , 1 , Visibility . get_visible . id ) @collection_item . refs << ref @collection_item . save! end end end end respond_to do | format | format . js do render partial : 'collection_items/show_editable_attributes' , locals : { collection_item : @collection_item , item_editable : true } end end else respond_to do | format | format . js { render text : I18n . t ( :item_not_updated_in_collection_error ) } format . html do flash [ :error ] = I18n . t ( :item_not_updated_in_collection_error ) redirect_to @collection end end end end end end
TODO - review these.
TODO - review these .