Method: ItemsController#new

Defined in:
app/controllers/items_controller.rb

#newObject

GET /items/new GET /items/new.json



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'app/controllers/items_controller.rb', line 148

def new
  if Shelf.real.blank?
    flash[:notice] = t('item.create_shelf_first')
    redirect_to libraries_url
    return
  end
  unless @manifestation
    flash[:notice] = t('item.specify_manifestation')
    redirect_to manifestations_url
    return
  end
  @item = Item.new
  @item.shelf = @library.shelves.first
  @item.manifestation = @manifestation
  if defined?(EnjuCirculation)
    @circulation_statuses = CirculationStatus.where(
      name: [
        'In Process',
        'Available For Pickup',
        'Available On Shelf',
        'Claimed Returned Or Never Borrowed',
        'Not Available']
    ).order(:position)
    @item.circulation_status = CirculationStatus.where(name: 'In Process').first
    @item.checkout_type = @manifestation.carrier_type.checkout_types.first
    @item.item_has_use_restriction = ItemHasUseRestriction.new
    @item.item_has_use_restriction.use_restriction = UseRestriction.where(name: 'Not For Loan').first
  end

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @item }
  end
end