Class Admin::ItemsController
In: app/controllers/admin/items_controller.rb
Parent: Admin::BaseController

Methods

add_question   edit   flagged   flick   index   merge   new   update  

Included Modules

Systems::Flickr

Public Instance methods

[Source]

     # File app/controllers/admin/items_controller.rb, line 113
113:   def add_question
114:     render :update do |page|
115:       page[:questions].append render(:partial => 'questions', :locals => { :num => params[:num].to_i + 1 })
116:     end
117:   end

GET /items/1/edit

[Source]

    # File app/controllers/admin/items_controller.rb, line 15
15:   def edit
16:     @item = Item.find(params[:id])
17:   end

[Source]

    # File app/controllers/admin/items_controller.rb, line 8
 8:   def flagged
 9:     @items = Item.all(:include => [:flags, :questions], :conditions => 'flags.item_id IS NOT NULL', :order => 'flags.updated_at desc').paginate
10:     
11:     render :action => 'index'
12:   end

DELETE /profiles/1 DELETE /profiles/1.xml def destroy

  @item = Item.find(params[:id])
  @item.destroy

  respond_to do |format|
    format.html { redirect_to(admin_items_path) }
    format.xml  { head :ok }
  end

end

[Source]

     # File app/controllers/admin/items_controller.rb, line 74
 74:   def flick
 75:     if request.post? && ids = params[:photo_ids]
 76:       activate = !params[:activate].nil?
 77:       data = []
 78:       Flickr.transaction do
 79:         Item.transaction do
 80:           data = ids.split("\n").map(&:chomp).inject([]) do |array, id|
 81:             path, data = temp_file_for_flickr_id(id)
 82:             item, flickr = data_for_flickr_id(id)
 83:             unless item && flickr
 84:               flash[:error] = "Photo ID '#{id}' is invalid."
 85:               redirect_to admin_items_path
 86:               return
 87:             end
 88:             params[:item] = { :agree => '1' }.merge(item)
 89:             item = Item.new(params[:item])
 90:             attachment = Attachment.new(:uploaded_data => data)
 91:             questions = params[:question].values.uniq.compact.reject { |el| el.empty? }
 92:             File.delete(path)
 93:             array << [item, attachment, questions, flickr]
 94:           end
 95:         end
 96:       end
 97:       Flickr.transaction do
 98:         Item.transaction do
 99:           data.each do |item, attachment, questions, flickr|
100:             item = Item.new_remote(item, attachment, questions, current_visit_id)
101:             Flickr.create!(flickr.merge(:item_id => item.id))
102:             item.activate if activate
103:           end
104:         end
105:       end
106:       flash[:notice] = 'The photos have been uploaded'
107:       redirect_to admin_items_path
108:     end
109:   ensure
110:     GC.start
111:   end

[Source]

   # File app/controllers/admin/items_controller.rb, line 4
4:   def index
5:     @items = Item.page_find
6:   end

[Source]

     # File app/controllers/admin/items_controller.rb, line 119
119:   def merge
120:   end

[Source]

    # File app/controllers/admin/items_controller.rb, line 36
36:   def new
37:     @item = Item.new
38:     # don't pull up uncleaned files
39:     Dir["#{Constants::Config::DIR_PATH}/*"].each { |file| File.delete(file) }
40:   end

PUT /items/1 PUT /items/1.xml

[Source]

    # File app/controllers/admin/items_controller.rb, line 21
21:   def update
22:     @item = Item.find(params[:id])
23: 
24:     respond_to do |format|
25:       if @item.update_attributes(params[:item])
26:         flash[:notice] = 'Item was successfully updated.'
27:         format.html { redirect_to(:action => :index) }
28:         format.xml  { head :ok }
29:       else
30:         format.html { render :action => "edit" }
31:         format.xml  { render :xml => @item.errors, :status => :unprocessable_entity }
32:       end
33:     end
34:   end

[Validate]