Skip to content

Commit

Permalink
Add field for DB adapter #15
Browse files Browse the repository at this point in the history
  • Loading branch information
iiska committed Sep 10, 2012
1 parent 2f9a253 commit ebd72bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app/assets/javascripts/app/admin/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Ext.testia.BugtrackerDlg = function(config) {
this.dForm.add(new Ext.form.TextField({fieldLabel: 'Name', name: 'name'}));
this.dForm.add(new Ext.form.TextField({fieldLabel: 'Url',
name: 'base_url'}));
this.dForm.fieldset({legend:'MySQL configuration'},
this.dForm.fieldset({legend:'Database configuration'},
// Radiobutton fields for selecting
// type.
//
Expand All @@ -82,6 +82,11 @@ Ext.testia.BugtrackerDlg = function(config) {
width: 10,
inputValue: 1
}),
new Ext.form.TextField({
fieldLabel: 'DB adapter',
name: 'db_adapter',
value: 'mysql2'
}),
new Ext.form.TextField({
fieldLabel: 'DB host',
name: 'db_host'
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/bug_trackers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ def show

def create
if @data["type"] == "Bugzilla"
# FIXME: Bugzilla implementation is hard coded for mysql
@data.delete_if {|k,v| k.match(/adapter/)}
tracker = Bugzilla.create!(@data)
elsif @data["type"] == "Jira"
source = ImportSource.create!({
:adapter => 'mysql2',
:adapter => @data['db_adapter'],
:host => @data['db_host'],
:port => @data['db_port'],
:database => @data['db_name'],
Expand All @@ -49,6 +51,7 @@ def update

if bt[:type] == "Jira"
mapping = {
'db_adapter' => 'adapter',
'db_host' => 'host',
'db_port' => 'port',
'db_name' => 'database',
Expand All @@ -62,6 +65,8 @@ def update
bt.import_source.update_attributes!(src_data)
@data.delete_if {|k,v| k.match(/^db_/)}
else
# FIXME: Bugzilla implementation is hard coded for mysql
@data.delete_if {|k,v| k.match(/adapter/)}
# Set sync_project_with_classification setting to false if value
# is not given
@data['sync_project_with_classification'] ||= false
Expand Down
2 changes: 1 addition & 1 deletion app/models/import/import_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def attributes
private

def strip_whitespace
['host', 'port', 'database', 'username'].each do |i|
['adapter', 'host', 'port', 'database', 'username'].each do |i|
@attributes[i].strip! unless @attributes[i].nil?
end
end
Expand Down
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
Expand All @@ -10,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120612070020) do
ActiveRecord::Schema.define(:version => 20120905062740) do

create_table "attachment_sets", :force => true do |t|
t.datetime "created_at"
Expand Down

0 comments on commit ebd72bc

Please sign in to comment.