Commit 2a750bf2ca649fb7aac6ae352a6eb1c4d7820c9f
Exists in
master
and in
4 other branches
Merge pull request #1704 from riyad/small-file-edit-fixes
Small fixes for editing files
Showing
1 changed file
with
11 additions
and
2 deletions
Show diff stats
app/controllers/tree_controller.rb
| @@ -8,6 +8,7 @@ class TreeController < ProjectResourceController | @@ -8,6 +8,7 @@ class TreeController < ProjectResourceController | ||
| 8 | before_filter :require_non_empty_project | 8 | before_filter :require_non_empty_project |
| 9 | 9 | ||
| 10 | before_filter :assign_ref_vars | 10 | before_filter :assign_ref_vars |
| 11 | + before_filter :edit_requirements, only: [:edit, :update] | ||
| 11 | 12 | ||
| 12 | def show | 13 | def show |
| 13 | @hex_path = Digest::SHA1.hexdigest(@path) | 14 | @hex_path = Digest::SHA1.hexdigest(@path) |
| @@ -34,10 +35,18 @@ class TreeController < ProjectResourceController | @@ -34,10 +35,18 @@ class TreeController < ProjectResourceController | ||
| 34 | ) | 35 | ) |
| 35 | 36 | ||
| 36 | if update_status | 37 | if update_status |
| 37 | - redirect_to project_tree_path(@project, @id), :notice => "File has been successfully changed" | 38 | + redirect_to project_tree_path(@project, @id), notice: "Your changes have been successfully commited" |
| 38 | else | 39 | else |
| 39 | - flash[:notice] = "You can't save file because it has been changed" | 40 | + flash[:notice] = "Your changes could not be commited, because the file has been changed" |
| 40 | render :edit | 41 | render :edit |
| 41 | end | 42 | end |
| 42 | end | 43 | end |
| 44 | + | ||
| 45 | + private | ||
| 46 | + | ||
| 47 | + def edit_requirements | ||
| 48 | + unless @tree.is_blob? && @tree.text? | ||
| 49 | + redirect_to project_tree_path(@project, @id), notice: "You can only edit text files" | ||
| 50 | + end | ||
| 51 | + end | ||
| 43 | end | 52 | end |