Project

General

Profile

Feature #296 » rest.diff

Markus Knittig, 2008-07-05 21:49

View differences:

app/controllers/issues_controller.rb (working copy)
53 53
      limit = per_page_option
54 54
      respond_to do |format|
55 55
        format.html { }
56
        format.xml  { }
56 57
        format.atom { }
57 58
        format.csv  { limit = Setting.issues_export_limit.to_i }
58 59
        format.pdf  { limit = Setting.issues_export_limit.to_i }
......
66 67
                           :offset =>  @issue_pages.current.offset
67 68
      respond_to do |format|
68 69
        format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
70
        format.xml  { render :xml => @issues.to_xml }
69 71
        format.atom { render_feed(@issues, :title => l(:label_issue_plural)) }
70 72
        format.csv  { send_data(issues_to_csv(@issues, @project).read, :type => 'text/csv; header=present', :filename => 'export.csv') }
71 73
        format.pdf  { send_data(render(:template => 'issues/index.rfpdf', :layout => false), :type => 'application/pdf', :filename => 'export.pdf') }
......
104 106
    @time_entry = TimeEntry.new
105 107
    respond_to do |format|
106 108
      format.html { render :template => 'issues/show.rhtml' }
109
      format.xml  { render :xml => @journals.to_xml }
107 110
      format.atom { render :action => 'changes', :layout => false, :content_type => 'application/atom+xml' }
108 111
      format.pdf  { send_data(render(:template => 'issues/show.rfpdf', :layout => false), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
109 112
    end
110 113
  end
111 114
  def new
......
171 174
      @issue.attributes = attrs
172 175
    end
173 176

  
174
    if request.post?
177
    if request.post? || request.put?
175 178
      @time_entry = TimeEntry.new(:project => @project, :issue => @issue, :user => User.current, :spent_on => Date.today)
176 179
      @time_entry.attributes = params[:time_entry]
177 180
      attachments = attach_files(@issue, params[:attachments])
......
216 224
  
217 225
  # Bulk edit a set of issues
218 226
  def bulk_edit
219
    if request.post?
227
    if request.post? || request.put?
220 228
      status = params[:status_id].blank? ? nil : IssueStatus.find_by_id(params[:status_id])
221 229
      priority = params[:priority_id].blank? ? nil : Enumeration.find_by_id(params[:priority_id])
222 230
      assigned_to = (params[:assigned_to_id].blank? || params[:assigned_to_id] == 'none') ? nil : User.find_by_id(params[:assigned_to_id])
......
267 275
    @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:new_project_id]} if params[:new_project_id]
268 276
    @target_project ||= @project    
269 277
    @trackers = @target_project.trackers
270
    if request.post?
278
    if request.post? || request.put?
271 279
      new_tracker = params[:new_tracker_id].blank? ? nil : @target_project.trackers.find_by_id(params[:new_tracker_id])
272 280
      unsaved_issue_ids = []
273 281
      @issues.each do |issue|
app/controllers/messages_controller.rb (working copy)
64 64

  
65 65
  # Edit a message
66 66
  def edit
67
    if params[:message] && User.current.allowed_to?(:edit_messages, @project)
67
    if params[:message] && User.current.allowed_to?(:edit_messages, @project))
68 68
      @message.locked = params[:message]['locked']
69 69
      @message.sticky = params[:message]['sticky']
70 70
    end
app/controllers/admin_controller.rb (working copy)
23 23
  include SortHelper	
24 24

  
25 25
  def index
26
    @no_configuration_data = Redmine::DefaultData::Loader::no_data?
26
    if request.delete? and User.current.admin
27
      @project.destroy
28
      respond_to do |format|
29
        format.xml  { head :ok }
30
      end
31
    else
32
      @no_configuration_data = Redmine::DefaultData::Loader::no_data?
33
    end
27 34
  end
28 35
	
29 36
  def projects
......
58 62
        render_feed(projects.sort_by(&:created_on).reverse.slice(0, Setting.feeds_limit.to_i), 
59 63
                                  :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
60 64
      }
65
      format.xml  { render :xml => projects.to_xml }
61 66
    end
62 67
  end
63 68
  
......
77 82
      @project.enabled_module_names = params[:enabled_modules]
78 83
      if @project.save
79 84
        flash[:notice] = l(:notice_successful_create)
80
        redirect_to :controller => 'admin', :action => 'projects'
81
	  end		
85
        respond_to do |format|
86
          format.html { redirect_to :controller => 'admin', :action => 'projects' }
87
          format.xml  { head :ok }
88
	end
89
      end		
82 90
    end	
83 91
  end
84 92
	
......
104 112
                                   :conditions => cond).to_f
105 113
    end
106 114
    @key = User.current.rss_key
115

  
116
    respond_to do |format|
117
      format.html
118
      format.xml  { render :xml => @project.to_xml }
119
    end
107 120
  end
108 121

  
109 122
  def settings
......
130 143
        render :action => 'settings'
131 144
      end
132 145
    end
146

  
147
    respond_to do |format|
148
      format.html
149
      format.xml  { render :xml => @project.to_xml }
150
    end
133 151
  end
134 152
  
135 153
  def modules
......
150 168
  # Delete @project
151 169
  def destroy
152 170
    @project_to_destroy = @project
153
    if request.post? and params[:confirm]
171
    if request.delete? and params[:confirm]
154 172
      @project_to_destroy.destroy
155
      redirect_to :controller => 'admin', :action => 'projects'
173
      respond_to do |format|
174
        format.html { redirect_to :controller => 'admin', :action => 'projects' }
175
        format.xml  { head :ok }
176
      end
177
      #redirect_to :controller => 'admin', :action => 'projects'
156 178
    end
157 179
    # hide project in layout
158 180
    @project = nil
......
161 183
  # Add a new issue category to @project
162 184
  def add_issue_category
163 185
    @category = @project.issue_categories.build(params[:category])
164
    if request.post? and @category.save
186
    if request.delete? and @category.save
165 187
  	  respond_to do |format|
166 188
        format.html do
167 189
          flash[:notice] = l(:notice_successful_create)
(1-1/2)