Commit 3250a024ef82bc6bb89f7c1dafdc824b6e09439b
1 parent
f1795a49
Exists in
master
and in
4 other branches
1. Improved admin -> new project form
2. Fixed bug: post-receive file was not added when create project via admin
Showing
6 changed files
with
20 additions
and
8 deletions
Show diff stats
app/controllers/admin/projects_controller.rb
| @@ -34,6 +34,8 @@ class Admin::ProjectsController < ApplicationController | @@ -34,6 +34,8 @@ class Admin::ProjectsController < ApplicationController | ||
| 34 | params[:project_access] | 34 | params[:project_access] |
| 35 | ) | 35 | ) |
| 36 | 36 | ||
| 37 | + @admin_project.update_repository | ||
| 38 | + | ||
| 37 | redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.' | 39 | redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.' |
| 38 | end | 40 | end |
| 39 | 41 |
app/models/project/repository_trait.rb
| @@ -47,6 +47,11 @@ module Project::RepositoryTrait | @@ -47,6 +47,11 @@ module Project::RepositoryTrait | ||
| 47 | File.chmod(0775, hook_file) | 47 | File.chmod(0775, hook_file) |
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | + def has_post_receive_file? | ||
| 51 | + hook_file = File.join(path_to_repo, 'hooks', 'post-receive') | ||
| 52 | + File.exists?(hook_file) | ||
| 53 | + end | ||
| 54 | + | ||
| 50 | def tags | 55 | def tags |
| 51 | repo.tags.map(&:name).sort.reverse | 56 | repo.tags.map(&:name).sort.reverse |
| 52 | end | 57 | end |
app/views/admin/projects/_form.html.haml
| @@ -56,11 +56,11 @@ | @@ -56,11 +56,11 @@ | ||
| 56 | .actions | 56 | .actions |
| 57 | = f.submit 'Save', :class => "btn primary" | 57 | = f.submit 'Save', :class => "btn primary" |
| 58 | = link_to 'Cancel', [:admin, @admin_project], :class => "btn" | 58 | = link_to 'Cancel', [:admin, @admin_project], :class => "btn" |
| 59 | - = link_to 'Destroy', [:admin, @admin_project], :confirm => 'Are you sure?', :method => :delete, :class => "btn danger right" | 59 | + - unless @admin_project.new_record? |
| 60 | + = link_to 'Destroy', [:admin, @admin_project], :confirm => 'Are you sure?', :method => :delete, :class => "btn danger right" | ||
| 60 | 61 | ||
| 61 | :javascript | 62 | :javascript |
| 62 | $(function(){ | 63 | $(function(){ |
| 63 | - taggifyForm(); | ||
| 64 | $('#project_owner_id').chosen(); | 64 | $('#project_owner_id').chosen(); |
| 65 | - $('#project_default_branch').chosen(); | 65 | + new Projects(); |
| 66 | }) | 66 | }) |
app/views/admin/projects/index.html.haml
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | %th Name | 7 | %th Name |
| 8 | %th Path | 8 | %th Path |
| 9 | %th Team Members | 9 | %th Team Members |
| 10 | + %th Post Receive | ||
| 10 | %th Last Commit | 11 | %th Last Commit |
| 11 | %th | 12 | %th |
| 12 | %th | 13 | %th |
| @@ -16,6 +17,7 @@ | @@ -16,6 +17,7 @@ | ||
| 16 | %td= link_to project.name, [:admin, project] | 17 | %td= link_to project.name, [:admin, project] |
| 17 | %td= project.path | 18 | %td= project.path |
| 18 | %td= project.users_projects.count | 19 | %td= project.users_projects.count |
| 20 | + %td= check_box_tag :post_receive_file, 1, project.has_post_receive_file?, :disabled => true | ||
| 19 | %td= last_commit(project) | 21 | %td= last_commit(project) |
| 20 | %td= link_to 'Edit', edit_admin_project_path(project), :id => "edit_#{dom_id(project)}", :class => "btn small" | 22 | %td= link_to 'Edit', edit_admin_project_path(project), :id => "edit_#{dom_id(project)}", :class => "btn small" |
| 21 | %td= link_to 'Destroy', [:admin, project], :confirm => 'Are you sure?', :method => :delete, :class => "btn small danger" | 23 | %td= link_to 'Destroy', [:admin, project], :confirm => 'Are you sure?', :method => :delete, :class => "btn small danger" |
app/views/admin/projects/new.html.haml
app/views/admin/projects/show.html.haml
| @@ -28,6 +28,12 @@ | @@ -28,6 +28,12 @@ | ||
| 28 | Description: | 28 | Description: |
| 29 | %td | 29 | %td |
| 30 | = @admin_project.description | 30 | = @admin_project.description |
| 31 | + %tr | ||
| 32 | + %td | ||
| 33 | + %b | ||
| 34 | + Post Receive File: | ||
| 35 | + %td | ||
| 36 | + = check_box_tag :post_receive_file, 1, @admin_project.has_post_receive_file?, :disabled => true | ||
| 31 | %br | 37 | %br |
| 32 | %h3 | 38 | %h3 |
| 33 | Team | 39 | Team |