Commit d40b9ce26d9df5c9245d9a4f3c07c91dd1706f06
1 parent
369df86e
Exists in
master
and in
4 other branches
Admin gitolite logs. Refactored project creation. Few style fixes.
Showing
15 changed files
with
66 additions
and
24 deletions
Show diff stats
app/assets/stylesheets/gitlab_bootstrap.scss
app/controllers/projects_controller.rb
@@ -21,20 +21,13 @@ class ProjectsController < ApplicationController | @@ -21,20 +21,13 @@ class ProjectsController < ApplicationController | ||
21 | @project = Project.create_by_user(params[:project], current_user) | 21 | @project = Project.create_by_user(params[:project], current_user) |
22 | 22 | ||
23 | respond_to do |format| | 23 | respond_to do |format| |
24 | - if @project.valid? | ||
25 | - format.html { redirect_to @project, notice: 'Project was successfully created.' } | ||
26 | - format.js | ||
27 | - else | ||
28 | - format.html { render action: "new" } | ||
29 | - format.js | 24 | + format.html do |
25 | + if @project.saved? | ||
26 | + redirect_to(@project, notice: 'Project was successfully created.') | ||
27 | + else | ||
28 | + render action: "new" | ||
29 | + end | ||
30 | end | 30 | end |
31 | - end | ||
32 | - rescue Gitlab::Gitolite::AccessDenied | ||
33 | - render :js => "location.href = '#{errors_githost_path}'" and return | ||
34 | - rescue StandardError => ex | ||
35 | - @project.errors.add(:base, "Cant save project. Please try again later") | ||
36 | - respond_to do |format| | ||
37 | - format.html { render action: "new" } | ||
38 | format.js | 31 | format.js |
39 | end | 32 | end |
40 | end | 33 | end |
app/helpers/application_helper.rb
@@ -127,6 +127,7 @@ module ApplicationHelper | @@ -127,6 +127,7 @@ module ApplicationHelper | ||
127 | when :admin_projects; controller.controller_name == "projects" | 127 | when :admin_projects; controller.controller_name == "projects" |
128 | when :admin_emails; controller.controller_name == 'mailer' | 128 | when :admin_emails; controller.controller_name == 'mailer' |
129 | when :admin_resque; controller.controller_name == 'resque' | 129 | when :admin_resque; controller.controller_name == 'resque' |
130 | + when :admin_logs; controller.controller_name == 'logs' | ||
130 | 131 | ||
131 | else | 132 | else |
132 | false | 133 | false |
app/models/project.rb
@@ -23,6 +23,8 @@ class Project < ActiveRecord::Base | @@ -23,6 +23,8 @@ class Project < ActiveRecord::Base | ||
23 | has_many :wikis, :dependent => :destroy | 23 | has_many :wikis, :dependent => :destroy |
24 | has_many :protected_branches, :dependent => :destroy | 24 | has_many :protected_branches, :dependent => :destroy |
25 | 25 | ||
26 | + attr_accessor :error_code | ||
27 | + | ||
26 | # | 28 | # |
27 | # Protected attributes | 29 | # Protected attributes |
28 | # | 30 | # |
@@ -48,7 +50,7 @@ class Project < ActiveRecord::Base | @@ -48,7 +50,7 @@ class Project < ActiveRecord::Base | ||
48 | Project.transaction do | 50 | Project.transaction do |
49 | project.owner = user | 51 | project.owner = user |
50 | 52 | ||
51 | - return project unless project.save | 53 | + project.save! |
52 | 54 | ||
53 | # Add user as project master | 55 | # Add user as project master |
54 | project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) | 56 | project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) |
@@ -59,6 +61,21 @@ class Project < ActiveRecord::Base | @@ -59,6 +61,21 @@ class Project < ActiveRecord::Base | ||
59 | end | 61 | end |
60 | 62 | ||
61 | project | 63 | project |
64 | + rescue Gitlab::Gitolite::AccessDenied => ex | ||
65 | + project.error_code = :gitolite | ||
66 | + project | ||
67 | + rescue => ex | ||
68 | + project.error_code = :db | ||
69 | + project.errors.add(:base, "Cant save project. Please try again later") | ||
70 | + project | ||
71 | + end | ||
72 | + | ||
73 | + def git_error? | ||
74 | + error_code == :gitolite | ||
75 | + end | ||
76 | + | ||
77 | + def saved? | ||
78 | + id && valid? | ||
62 | end | 79 | end |
63 | 80 | ||
64 | # | 81 | # |
app/views/events/_event_last_push.html.haml
@@ -12,5 +12,5 @@ | @@ -12,5 +12,5 @@ | ||
12 | = time_ago_in_words(event.created_at) | 12 | = time_ago_in_words(event.created_at) |
13 | ago. | 13 | ago. |
14 | 14 | ||
15 | - = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn small grouped primary" do | 15 | + = link_to new_mr_path_from_push_event(event), :title => "New Merge Request", :class => "btn very_small primary" do |
16 | Create Merge Request | 16 | Create Merge Request |
app/views/layouts/admin.html.haml
@@ -12,6 +12,8 @@ | @@ -12,6 +12,8 @@ | ||
12 | = link_to "Projects", admin_projects_path | 12 | = link_to "Projects", admin_projects_path |
13 | %li{:class => tab_class(:admin_users)} | 13 | %li{:class => tab_class(:admin_users)} |
14 | = link_to "Users", admin_users_path | 14 | = link_to "Users", admin_users_path |
15 | + %li{:class => tab_class(:admin_logs)} | ||
16 | + = link_to "Logs", admin_logs_path | ||
15 | %li{:class => tab_class(:admin_emails)} | 17 | %li{:class => tab_class(:admin_emails)} |
16 | = link_to "Emails", admin_emails_path | 18 | = link_to "Emails", admin_emails_path |
17 | %li{:class => tab_class(:admin_resque)} | 19 | %li{:class => tab_class(:admin_resque)} |
app/views/projects/_form.html.haml
@@ -10,17 +10,16 @@ | @@ -10,17 +10,16 @@ | ||
10 | .input | 10 | .input |
11 | = f.text_field :name, :placeholder => "Example Project", :class => "xxlarge" | 11 | = f.text_field :name, :placeholder => "Example Project", :class => "xxlarge" |
12 | 12 | ||
13 | - %hr | 13 | + %h5.page_title |
14 | .alert.alert-info | 14 | .alert.alert-info |
15 | %h5 Advanced settings: | 15 | %h5 Advanced settings: |
16 | .clearfix | 16 | .clearfix |
17 | = f.label :path do | 17 | = f.label :path do |
18 | - Git Clone | 18 | + Path |
19 | .input | 19 | .input |
20 | .input-prepend | 20 | .input-prepend |
21 | - %span.add-on= Gitlab.config.ssh_path | ||
22 | - = f.text_field :path, :placeholder => "example_project", :disabled => !@project.new_record? | ||
23 | - %span.add-on= ".git" | 21 | + %strong |
22 | + = text_field_tag :ppath, @project.path_to_repo, :class => "xlarge", :disabled => true | ||
24 | .clearfix | 23 | .clearfix |
25 | = f.label :code do | 24 | = f.label :code do |
26 | URL | 25 | URL |
app/views/projects/create.js.haml
1 | -- if @project.valid? | 1 | +- if @project.saved? |
2 | :plain | 2 | :plain |
3 | location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}"; | 3 | location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}"; |
4 | - else | 4 | - else |
5 | + - if @project.git_error? | ||
6 | + location.href = "#{errors_githost_path}"; | ||
7 | + -else | ||
5 | :plain | 8 | :plain |
6 | $('.project_new_holder').show(); | 9 | $('.project_new_holder').show(); |
7 | $("#new_project").replaceWith("#{escape_javascript(render('new_form'))}"); | 10 | $("#new_project").replaceWith("#{escape_javascript(render('new_form'))}"); |
app/views/projects/edit.html.haml
app/views/projects/new.html.haml
config/routes.rb
@@ -50,6 +50,8 @@ Gitlab::Application.routes.draw do | @@ -50,6 +50,8 @@ Gitlab::Application.routes.draw do | ||
50 | get 'mailer/preview_note' | 50 | get 'mailer/preview_note' |
51 | get 'mailer/preview_user_new' | 51 | get 'mailer/preview_user_new' |
52 | get 'mailer/preview_issue_new' | 52 | get 'mailer/preview_issue_new' |
53 | + | ||
54 | + resource :logs | ||
53 | resource :resque, :controller => 'resque' | 55 | resource :resque, :controller => 'resque' |
54 | root :to => "dashboard#index" | 56 | root :to => "dashboard#index" |
55 | end | 57 | end |
lib/gitlab/logger.rb
@@ -2,7 +2,13 @@ module Gitlab | @@ -2,7 +2,13 @@ module Gitlab | ||
2 | class Logger | 2 | class Logger |
3 | def self.error(message) | 3 | def self.error(message) |
4 | @@logger ||= ::Logger.new(File.join(Rails.root, "log/githost.log")) | 4 | @@logger ||= ::Logger.new(File.join(Rails.root, "log/githost.log")) |
5 | + message = Time.now.to_s(:long) + " -> " + message | ||
5 | @@logger.error(message) | 6 | @@logger.error(message) |
6 | end | 7 | end |
8 | + | ||
9 | + def self.read_latest | ||
10 | + path = Rails.root.join("log/githost.log") | ||
11 | + logs = `tail -n 50 #{path}`.split("\n") | ||
12 | + end | ||
7 | end | 13 | end |
8 | end | 14 | end |
spec/requests/projects_spec.rb
@@ -120,7 +120,7 @@ describe "Projects" do | @@ -120,7 +120,7 @@ describe "Projects" do | ||
120 | visit edit_project_path(@project) | 120 | visit edit_project_path(@project) |
121 | 121 | ||
122 | fill_in 'project_name', :with => 'Awesome' | 122 | fill_in 'project_name', :with => 'Awesome' |
123 | - fill_in 'project_path', :with => 'gitlabhq' | 123 | + fill_in 'project_code', :with => 'gitlabhq' |
124 | click_button "Save" | 124 | click_button "Save" |
125 | @project = @project.reload | 125 | @project = @project.reload |
126 | end | 126 | end |