Project

General

Profile

Feature #296 » projects_json_format.diff

Eddie Ringle, 2010-02-20 05:03

View differences:

app/controllers/projects_controller.rb (working copy)
61 61
                                              :limit => Setting.feeds_limit.to_i)
62 62
        render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
63 63
      }
64
      format.json {
65
        projects = Project.visible_find(:all, :order => 'lft')
66
        render :json => { :projects => projects }
67
      }
64 68
    end
65 69
  end
66 70
  
......
90 94
            redirect_to :controller => 'projects', :action => 'settings', :id => @project
91 95
          }
92 96
          format.xml  { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
97
          format.json { head :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
93 98
        end
94 99
      else
95 100
        respond_to do |format|
96 101
          format.html
97 102
          format.xml  { render :xml => @project.errors, :status => :unprocessable_entity }
103
          format.json { render :json => @project.errors, :status => :unprocessable_entity }
98 104
        end
99 105
      end
100 106
    end	
......
164 170
    respond_to do |format|
165 171
      format.html
166 172
      format.xml
173
      format.json { render :json => { :project => @project } }
167 174
    end
168 175
  end
169 176

  
......
189 196
            redirect_to :action => 'settings', :id => @project
190 197
          }
191 198
          format.xml  { head :ok }
199
          format.json { head :ok }
192 200
        end
193 201
      else
194 202
        respond_to do |format|
......
197 205
            render :action => 'settings'
198 206
          }
199 207
          format.xml  { render :xml => @project.errors, :status => :unprocessable_entity }
208
          format.json { render :json => @project.errors, :status => :unprocessable_entity }
200 209
        end
201 210
      end
202 211
    end
......
227 236
    if request.get?
228 237
      # display confirmation view
229 238
    else
230
      if params[:format] == 'xml' || params[:confirm]
239
      if params[:format] == 'xml' || params[:format] == 'json' || params[:confirm]
231 240
        @project_to_destroy.destroy
232 241
        respond_to do |format|
233 242
          format.html { redirect_to :controller => 'admin', :action => 'projects' }
234 243
          format.xml  { head :ok }
244
          format.json { head :ok }
235 245
        end
236 246
      end
237 247
    end
(2-2/2)