jenkins-bot has submitted this change and it was merged.
Change subject: Make review settings configurable
......................................................................
Make review settings configurable
This commit adds Settings subclass for accessing review settings from database.
Bug: 58071
Change-Id: Ib37d14a069d56d32eaec86e11d17c5c5bc71b608
---
A data/db/migrations/20140411-01-congifurable-settings.mysql
M data/db/schema.mysql
M src/Wikimania/Scholarship/App.php
M src/Wikimania/Scholarship/Dao/Apply.php
A src/Wikimania/Scholarship/Dao/Settings.php
5 files changed, 83 insertions(+), 3 deletions(-)
Approvals:
BryanDavis: Looks good to me, approved
jenkins-bot: Verified
diff --git a/data/db/migrations/20140411-01-congifurable-settings.mysql
b/data/db/migrations/20140411-01-congifurable-settings.mysql
new file mode 100644
index 0000000..fbfc2e0
--- /dev/null
+++ b/data/db/migrations/20140411-01-congifurable-settings.mysql
@@ -0,0 +1,18 @@
+-- Bug: 58071
+-- Add settings table
+
+DROP TABLE IF EXISTS settings;
+CREATE TABLE IF NOT EXISTS settings (
+ id INT(11) NOT NULL AUTO_INCREMENT
+ , setting_name VARCHAR(255) NOT NULL
+ , value VARCHAR(255) NOT NULL DEFAULT '0'
+ , entered_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+ , PRIMARY KEY (id)
+ , UNIQUE (setting_name)
+) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
+
+INSERT IGNORE INTO settings (setting_name, value) VALUES
+ ('phase1pass',3)
+,('weightonwiki',0.5)
+,('weightoffwiki',0.2)
+,('weightinterest',0.3);
\ No newline at end of file
diff --git a/data/db/schema.mysql b/data/db/schema.mysql
index 95371ef..e9fa898 100644
--- a/data/db/schema.mysql
+++ b/data/db/schema.mysql
@@ -330,3 +330,18 @@
,('ZA','South Africa','Sub-Saharan Africa')
,('ZM','Zambia','Sub-Saharan Africa')
,('ZW','Zimbabwe','Sub-Saharan Africa');
+
+CREATE TABLE IF NOT EXISTS settings (
+ id INT(11) NOT NULL AUTO_INCREMENT
+ , setting_name VARCHAR(255) NOT NULL
+ , value VARCHAR(255) NOT NULL DEFAULT '0'
+ , entered_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
+ , PRIMARY KEY (id)
+ , UNIQUE (setting_name)
+) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8;
+
+INSERT IGNORE INTO settings (setting_name, value) VALUES
+ ('phase1pass',3)
+,('weightonwiki',0.5)
+,('weightoffwiki',0.2)
+,('weightinterest',0.3);
\ No newline at end of file
diff --git a/src/Wikimania/Scholarship/App.php
b/src/Wikimania/Scholarship/App.php
index 4f739b6..af4b18d 100644
--- a/src/Wikimania/Scholarship/App.php
+++ b/src/Wikimania/Scholarship/App.php
@@ -142,17 +142,24 @@
$c->log );
});
+ $container->singleton( 'settingsDao', function ( $c ) {
+ return new \Wikimania\Scholarship\Dao\Settings(
+ $c->settings['db.dsn'],
+ $c->settings['db.user'],
$c->settings['db.pass'],
+ $c->log );
+ });
+
$container->singleton( 'authManager', function ( $c ) {
return new \Wikimania\Scholarship\AuthManager(
$c->userDao );
});
$container->singleton( 'applyDao', function ( $c ) {
$uid = $c->authManager->getUserId();
- // FIXME: pass in settings
+ $settings = $c->settingsDao->getSettings();
return new \Wikimania\Scholarship\Dao\Apply(
$c->settings['db.dsn'],
$c->settings['db.user'],
$c->settings['db.pass'],
- $uid, null, $c->log );
+ $uid, $settings, $c->log );
});
$container->singleton( 'wgLang', function ( $c ) {
diff --git a/src/Wikimania/Scholarship/Dao/Apply.php
b/src/Wikimania/Scholarship/Dao/Apply.php
index f3456ee..26e3c5e 100644
--- a/src/Wikimania/Scholarship/Dao/Apply.php
+++ b/src/Wikimania/Scholarship/Dao/Apply.php
@@ -48,7 +48,6 @@
'weightinterest' => 0.3, // contribution of interest to final
score
);
-
/**
* @param string $dsn PDO data source name
* @param string $user Database user
diff --git a/src/Wikimania/Scholarship/Dao/Settings.php
b/src/Wikimania/Scholarship/Dao/Settings.php
new file mode 100644
index 0000000..4da3bdf
--- /dev/null
+++ b/src/Wikimania/Scholarship/Dao/Settings.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * @section LICENSE
+ * This file is part of Wikimania Scholarship Application.
+ *
+ * Wikimania Scholarship Application is free software: you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
+ *
+ * Wikimania Scholarship Application is distributed in the hope that it will
+ * be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Wikimania Scholarship Application. If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * @file
+ */
+
+namespace Wikimania\Scholarship\Dao;
+
+/**
+ * Data access object for Admin Settings in scholarship applications.
+ */
+class Settings extends AbstractDao {
+ /**
+ * @return array Settings from DB
+ */
+ public function getSettings(){
+ $settings = array();
+ $records = $this->fetchAll( 'SELECT setting_name,value FROM
settings' );
+ foreach ( $records as $idx => $row ) {
+ $settings[ $row[ 'setting_name' ] ] = $row[ 'value' ];
+ }
+ return $settings;
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/125372
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib37d14a069d56d32eaec86e11d17c5c5bc71b608
Gerrit-PatchSet: 13
Gerrit-Project: wikimedia/wikimania-scholarships
Gerrit-Branch: master
Gerrit-Owner: Kushal124 <[email protected]>
Gerrit-Reviewer: BryanDavis <[email protected]>
Gerrit-Reviewer: Kushal124 <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits