You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

versions_controller.rb 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # redMine - project management software
  2. # Copyright (C) 2006 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. class VersionsController < ApplicationController
  18. layout 'base'
  19. before_filter :find_project, :authorize
  20. def edit
  21. if request.post? and @version.update_attributes(params[:version])
  22. flash[:notice] = l(:notice_successful_update)
  23. redirect_to :controller => 'projects', :action => 'settings', :id => @project
  24. end
  25. end
  26. def destroy
  27. @version.destroy
  28. redirect_to :controller => 'projects', :action => 'settings', :id => @project
  29. rescue
  30. flash[:notice] = "Unable to delete version"
  31. redirect_to :controller => 'projects', :action => 'settings', :id => @project
  32. end
  33. def download
  34. @attachment = @version.attachments.find(params[:attachment_id])
  35. @attachment.increment_download
  36. send_file @attachment.diskfile, :filename => @attachment.filename
  37. rescue
  38. flash.now[:notice] = l(:notice_file_not_found)
  39. render :text => "", :layout => true, :status => 404
  40. end
  41. def destroy_file
  42. @version.attachments.find(params[:attachment_id]).destroy
  43. flash[:notice] = l(:notice_successful_delete)
  44. redirect_to :controller => 'projects', :action => 'list_files', :id => @project
  45. end
  46. private
  47. def find_project
  48. @version = Version.find(params[:id])
  49. @project = @version.project
  50. end
  51. end