Commit 3250a024ef82bc6bb89f7c1dafdc824b6e09439b

Authored by Dmitriy Zaporozhets
1 parent f1795a49

1. Improved admin -> new project form

2. Fixed bug: post-receive file was not added when create project via admin
app/controllers/admin/projects_controller.rb
... ... @@ -34,6 +34,8 @@ class Admin::ProjectsController < ApplicationController
34 34 params[:project_access]
35 35 )
36 36  
  37 + @admin_project.update_repository
  38 +
37 39 redirect_to [:admin, @admin_project], notice: 'Project was successfully updated.'
38 40 end
39 41  
... ...
app/models/project/repository_trait.rb
... ... @@ -47,6 +47,11 @@ module Project::RepositoryTrait
47 47 File.chmod(0775, hook_file)
48 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 55 def tags
51 56 repo.tags.map(&:name).sort.reverse
52 57 end
... ...
app/views/admin/projects/_form.html.haml
... ... @@ -56,11 +56,11 @@
56 56 .actions
57 57 = f.submit 'Save', :class => "btn primary"
58 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 62 :javascript
62 63 $(function(){
63   - taggifyForm();
64 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 7 %th Name
8 8 %th Path
9 9 %th Team Members
  10 + %th Post Receive
10 11 %th Last Commit
11 12 %th
12 13 %th
... ... @@ -16,6 +17,7 @@
16 17 %td= link_to project.name, [:admin, project]
17 18 %td= project.path
18 19 %td= project.users_projects.count
  20 + %td= check_box_tag :post_receive_file, 1, project.has_post_receive_file?, :disabled => true
19 21 %td= last_commit(project)
20 22 %td= link_to 'Edit', edit_admin_project_path(project), :id => "edit_#{dom_id(project)}", :class => "btn small"
21 23 %td= link_to 'Destroy', [:admin, project], :confirm => 'Are you sure?', :method => :delete, :class => "btn small danger"
... ...
app/views/admin/projects/new.html.haml
1   -%h1 New project
2   -
  1 +%h2 New project
  2 +%hr
3 3 = render 'form'
4   -
5   -%br
6   -= link_to 'Back', admin_projects_path, :class => ''
... ...
app/views/admin/projects/show.html.haml
... ... @@ -28,6 +28,12 @@
28 28 Description:
29 29 %td
30 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 37 %br
32 38 %h3
33 39 Team
... ...