Commit e6d2e569 authored by Andrew8xx8's avatar Andrew8xx8

Issue tracker field added to projects

parent 8f621c9e
...@@ -40,4 +40,31 @@ module IssuesHelper ...@@ -40,4 +40,31 @@ module IssuesHelper
def issues_active_milestones def issues_active_milestones
@project.milestones.active.order("id desc").all @project.milestones.active.order("id desc").all
end end
def url_for_issue(issue_id)
if @project.issues_tracker == Project.issues_tracker.default_value
url = project_issue_url project_id: @project, id: issue_id
else
url = Settings[:issues_tracker][@project.issues_tracker]["issues_url"]
url.gsub(':id', issue_id.to_s).gsub(':project_id', @project.id.to_s)
end
end
def title_for_issue(issue_id)
if issue = @project.issues.where(id: issue_id).first
issue.title
else
""
end
end
def issue_exists?(issue_id)
return false if @project.nil?
if @project.issues_tracker == Project.issues_tracker.default_value
@project.issues.where(id: issue_id).first.present?
else
true
end
end
end end
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
# creator_id :integer # creator_id :integer
# default_branch :string(255) # default_branch :string(255)
# issues_enabled :boolean default(TRUE), not null # issues_enabled :boolean default(TRUE), not null
# issues_tracker :string not null
# wall_enabled :boolean default(TRUE), not null # wall_enabled :boolean default(TRUE), not null
# merge_requests_enabled :boolean default(TRUE), not null # merge_requests_enabled :boolean default(TRUE), not null
# wiki_enabled :boolean default(TRUE), not null # wiki_enabled :boolean default(TRUE), not null
...@@ -22,10 +23,11 @@ require "grit" ...@@ -22,10 +23,11 @@ require "grit"
class Project < ActiveRecord::Base class Project < ActiveRecord::Base
include Gitolited include Gitolited
extend Enumerize
class TransferError < StandardError; end class TransferError < StandardError; end
attr_accessible :name, :path, :description, :default_branch, attr_accessible :name, :path, :description, :default_branch, :issues_tracker,
:issues_enabled, :wall_enabled, :merge_requests_enabled, :issues_enabled, :wall_enabled, :merge_requests_enabled,
:wiki_enabled, :public, :import_url, as: [:default, :admin] :wiki_enabled, :public, :import_url, as: [:default, :admin]
...@@ -93,6 +95,8 @@ class Project < ActiveRecord::Base ...@@ -93,6 +95,8 @@ class Project < ActiveRecord::Base
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) } scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :public_only, -> { where(public: true) } scope :public_only, -> { where(public: true) }
enumerize :issues_tracker, :in => (Settings[:issues_tracker].keys).append(:gitlab), :default => :gitlab
class << self class << self
def abandoned def abandoned
project_ids = Event.select('max(created_at) as latest_date, project_id'). project_ids = Event.select('max(created_at) as latest_date, project_id').
......
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
= f.check_box :issues_enabled = f.check_box :issues_enabled
%span.descr Lightweight issue tracking system for this project %span.descr Lightweight issue tracking system for this project
.control-group
= f.label :issues_tracker, "Issues tracker", class: 'control-label'
.input= f.select(:issues_tracker, Project.issues_tracker.values, {}, { disabled: !@project.issues_enabled })
.control-group .control-group
= f.label :merge_requests_enabled, "Merge Requests", class: 'control-label' = f.label :merge_requests_enabled, "Merge Requests", class: 'control-label'
.controls .controls
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# 2. Replace gitlab -> host with your domain # 2. Replace gitlab -> host with your domain
# 3. Replace gitlab -> email_from # 3. Replace gitlab -> email_from
<<<<<<< HEAD
production: &base production: &base
# #
# 1. GitLab app settings # 1. GitLab app settings
...@@ -37,6 +38,11 @@ production: &base ...@@ -37,6 +38,11 @@ production: &base
# signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled.
# username_changing_enabled: false # default: true - User can change her username/namespace # username_changing_enabled: false # default: true - User can change her username/namespace
## Available issues trackers
issues_tracker:
redmine:
issues_url: "http://redmine.sample/issues/:id"
## Gravatar ## Gravatar
gravatar: gravatar:
enabled: true # Use user avatar images from Gravatar.com (default: true) enabled: true # Use user avatar images from Gravatar.com (default: true)
......
class AddIssuesTrackerToProject < ActiveRecord::Migration
def change
add_column :projects, :issues_tracker, :string, default: :gitlab, null: false
end
end
This diff is collapsed.
...@@ -163,8 +163,11 @@ module Gitlab ...@@ -163,8 +163,11 @@ module Gitlab
end end
def reference_issue(identifier) def reference_issue(identifier)
if issue = @project.issues.where(id: identifier).first if issue_exists? identifier
link_to("##{identifier}", project_issue_url(@project, issue), html_options.merge(title: "Issue: #{issue.title}", class: "gfm gfm-issue #{html_options[:class]}")) url = url_for_issue(identifier)
title = title_for_issue(identifier)
link_to("##{identifier}", url, html_options.merge(title: "Issue: #{title}", class: "gfm gfm-issue #{html_options[:class]}"))
end end
end end
......
...@@ -2,6 +2,7 @@ require "spec_helper" ...@@ -2,6 +2,7 @@ require "spec_helper"
describe GitlabMarkdownHelper do describe GitlabMarkdownHelper do
include ApplicationHelper include ApplicationHelper
include IssuesHelper
let!(:project) { create(:project) } let!(:project) { create(:project) }
......
require 'spec_helper'
describe IssuesTracker do
let(:project) { double('project') }
before do
@project = project
project.stub(repository: stub(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']))
project.stub(path_with_namespace: 'gitlab/gitlab-ci')
end
it 'returns url for issue' do
ololo
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment