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 | 21 | @project = Project.create_by_user(params[:project], current_user) |
| 22 | 22 | |
| 23 | 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 | 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 | 31 | format.js |
| 39 | 32 | end |
| 40 | 33 | end | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -127,6 +127,7 @@ module ApplicationHelper |
| 127 | 127 | when :admin_projects; controller.controller_name == "projects" |
| 128 | 128 | when :admin_emails; controller.controller_name == 'mailer' |
| 129 | 129 | when :admin_resque; controller.controller_name == 'resque' |
| 130 | + when :admin_logs; controller.controller_name == 'logs' | |
| 130 | 131 | |
| 131 | 132 | else |
| 132 | 133 | false | ... | ... |
app/models/project.rb
| ... | ... | @@ -23,6 +23,8 @@ class Project < ActiveRecord::Base |
| 23 | 23 | has_many :wikis, :dependent => :destroy |
| 24 | 24 | has_many :protected_branches, :dependent => :destroy |
| 25 | 25 | |
| 26 | + attr_accessor :error_code | |
| 27 | + | |
| 26 | 28 | # |
| 27 | 29 | # Protected attributes |
| 28 | 30 | # |
| ... | ... | @@ -48,7 +50,7 @@ class Project < ActiveRecord::Base |
| 48 | 50 | Project.transaction do |
| 49 | 51 | project.owner = user |
| 50 | 52 | |
| 51 | - return project unless project.save | |
| 53 | + project.save! | |
| 52 | 54 | |
| 53 | 55 | # Add user as project master |
| 54 | 56 | project.users_projects.create!(:project_access => UsersProject::MASTER, :user => user) |
| ... | ... | @@ -59,6 +61,21 @@ class Project < ActiveRecord::Base |
| 59 | 61 | end |
| 60 | 62 | |
| 61 | 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 | 79 | end |
| 63 | 80 | |
| 64 | 81 | # | ... | ... |
app/views/events/_event_last_push.html.haml
| ... | ... | @@ -12,5 +12,5 @@ |
| 12 | 12 | = time_ago_in_words(event.created_at) |
| 13 | 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 | 16 | Create Merge Request | ... | ... |
app/views/layouts/admin.html.haml
| ... | ... | @@ -12,6 +12,8 @@ |
| 12 | 12 | = link_to "Projects", admin_projects_path |
| 13 | 13 | %li{:class => tab_class(:admin_users)} |
| 14 | 14 | = link_to "Users", admin_users_path |
| 15 | + %li{:class => tab_class(:admin_logs)} | |
| 16 | + = link_to "Logs", admin_logs_path | |
| 15 | 17 | %li{:class => tab_class(:admin_emails)} |
| 16 | 18 | = link_to "Emails", admin_emails_path |
| 17 | 19 | %li{:class => tab_class(:admin_resque)} | ... | ... |
app/views/projects/_form.html.haml
| ... | ... | @@ -10,17 +10,16 @@ |
| 10 | 10 | .input |
| 11 | 11 | = f.text_field :name, :placeholder => "Example Project", :class => "xxlarge" |
| 12 | 12 | |
| 13 | - %hr | |
| 13 | + %h5.page_title | |
| 14 | 14 | .alert.alert-info |
| 15 | 15 | %h5 Advanced settings: |
| 16 | 16 | .clearfix |
| 17 | 17 | = f.label :path do |
| 18 | - Git Clone | |
| 18 | + Path | |
| 19 | 19 | .input |
| 20 | 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 | 23 | .clearfix |
| 25 | 24 | = f.label :code do |
| 26 | 25 | URL | ... | ... |
app/views/projects/create.js.haml
| 1 | -- if @project.valid? | |
| 1 | +- if @project.saved? | |
| 2 | 2 | :plain |
| 3 | 3 | location.href = "#{project_path(@project, :notice => 'Project was successfully created.')}"; |
| 4 | 4 | - else |
| 5 | + - if @project.git_error? | |
| 6 | + location.href = "#{errors_githost_path}"; | |
| 7 | + -else | |
| 5 | 8 | :plain |
| 6 | 9 | $('.project_new_holder').show(); |
| 7 | 10 | $("#new_project").replaceWith("#{escape_javascript(render('new_form'))}"); | ... | ... |
app/views/projects/edit.html.haml
app/views/projects/new.html.haml
config/routes.rb
lib/gitlab/logger.rb
| ... | ... | @@ -2,7 +2,13 @@ module Gitlab |
| 2 | 2 | class Logger |
| 3 | 3 | def self.error(message) |
| 4 | 4 | @@logger ||= ::Logger.new(File.join(Rails.root, "log/githost.log")) |
| 5 | + message = Time.now.to_s(:long) + " -> " + message | |
| 5 | 6 | @@logger.error(message) |
| 6 | 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 | 13 | end |
| 8 | 14 | end | ... | ... |
spec/requests/projects_spec.rb
| ... | ... | @@ -120,7 +120,7 @@ describe "Projects" do |
| 120 | 120 | visit edit_project_path(@project) |
| 121 | 121 | |
| 122 | 122 | fill_in 'project_name', :with => 'Awesome' |
| 123 | - fill_in 'project_path', :with => 'gitlabhq' | |
| 123 | + fill_in 'project_code', :with => 'gitlabhq' | |
| 124 | 124 | click_button "Save" |
| 125 | 125 | @project = @project.reload |
| 126 | 126 | end | ... | ... |