Niharika29 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/192199

Change subject: Add button to end campaign on Update page
......................................................................

Add button to end campaign on Update page

Bug: T90388
Change-Id: I2f3faca5498bdd3a62c7d97fda56bc9a691fa673
---
M data/i18n/en.json
M data/i18n/qqq.json
M data/templates/admin/campaign.html
M src/App.php
A src/Controllers/Admin/CampaignEnd.php
M src/Dao/Campaigns.php
6 files changed, 66 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/iegreview 
refs/changes/99/192199/1

diff --git a/data/i18n/en.json b/data/i18n/en.json
index d329907..33765eb 100644
--- a/data/i18n/en.json
+++ b/data/i18n/en.json
@@ -105,6 +105,8 @@
        "admin-campaign-create-fail": "Campaign creation failed. Check logs.",
        "admin-campaign-update-success": "Campaign updated.",
        "admin-campaign-update-fail": "Error. Check logs.",
+       "admin-campaign-end-button": "End Campaign",
+       "admin-campaign-end-success": "Campaign succesfully ended",
 
        "page-of-pages": "Page $1 of $2",
        "no-results": "No results found",
diff --git a/data/i18n/qqq.json b/data/i18n/qqq.json
index 86ebc0a..35e943a 100644
--- a/data/i18n/qqq.json
+++ b/data/i18n/qqq.json
@@ -41,6 +41,8 @@
        "admin-campaigns-start": "Input label, followed by textbox",
        "admin-campaigns-end": "Input label, followed by textbox",
        "admin-campaigns-id": "Table column header, ID of 
campaign.\n{{Identical|ID}}",
+       "admin-campaign-end-button": "Button label",
+       "admin-campaign-end-success": "Message string for succesful campaign 
end",
 
        "change-password": "Navigation menu item, links to password change 
page.\n{{Identical|Change password}}",
        "credits": "Credits page heading",
diff --git a/data/templates/admin/campaign.html 
b/data/templates/admin/campaign.html
index 5d7d92a..e902150 100644
--- a/data/templates/admin/campaign.html
+++ b/data/templates/admin/campaign.html
@@ -46,10 +46,15 @@
     </div>
   </div>
 
+</form>
+
   <div class="col-sm-10 col-sm-offset-2">
     <input type="submit" class="btn btn-default" id="save" name="save" 
value="{{ 'admin-campaign-save'|message }}"/>
+    &nbsp;
+    {% if id != 'new' %}
+    <a class="btn btn-danger" href="{{ urlFor( 'admin_campaign_end', { 'id': 
id } ) }}">{{ 'admin-campaign-end-button'|message }}</a>
+    {% endif %}
   </div>
 
 {% endspaceless %}
 {% endblock content %}
-
diff --git a/src/App.php b/src/App.php
index 0181ce4..d4a9723 100644
--- a/src/App.php
+++ b/src/App.php
@@ -562,6 +562,12 @@
                                        $page->setDao( $slim->campaignsDao );
                                        $page();
                                } )->name( 'admin_campaign_post' );
+
+                               $slim->get( 'campaign/end/:id', function ( $id 
) use ( $slim ) {
+                                       $page = new 
Controllers\Admin\CampaignEnd( $slim );
+                                       $page->setDao( $slim->campaignsDao );
+                                       $page( $id );
+                               } )->name( 'admin_campaign_end' );
                } );
 
                $slim->notFound( function () use ( $slim, $middleware ) {
diff --git a/src/Controllers/Admin/CampaignEnd.php 
b/src/Controllers/Admin/CampaignEnd.php
new file mode 100644
index 0000000..78b7030
--- /dev/null
+++ b/src/Controllers/Admin/CampaignEnd.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * @section LICENSE
+ * This file is part of Wikimedia IEG Grant Review application.
+ *
+ * Wikimedia IEG Grant Review 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.
+ *
+ * Wikimedia IEG Grant Review 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 Wikimedia IEG Grant Review application.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * @file
+ * @copyright © 2015 Niharika Kohli, Wikimedia Foundation and contributors.
+ */
+
+namespace Wikimedia\IEGReview\Controllers\Admin;
+
+use Wikimedia\IEGReview\Controller;
+
+/**
+ * End a campaign.
+ *
+ * @author Niharika Kohli <nko...@wikimedia.org>
+ * @copyright © 2014 Niharika Kohli, Wikimedia Foundation and contributors.
+ */
+class CampaignEnd extends Controller {
+
+       protected function handleGet( $id ) {
+               if ( $this->dao->endCampaign( $id ) !== false ) {
+                       $this->flash( 'info',
+                               $this->i18nContext->message( 
'admin-campaign-end-success' )
+                       );
+               } else {
+                       $this->flash( 'error',
+                               $this->i18nContext->message( 
'admin-campaign-update-fail' )
+                       );
+               }
+               $this->redirect( $this->urlFor( 'admin_campaign', array( 'id' 
=> $id ) ) );
+       }
+
+}
diff --git a/src/Dao/Campaigns.php b/src/Dao/Campaigns.php
index dc1d08a..cd70e40 100644
--- a/src/Dao/Campaigns.php
+++ b/src/Dao/Campaigns.php
@@ -76,7 +76,7 @@
                        'UPDATE campaigns SET',
                        'end_date = now()',
                        ',status = 0',
-                       'WHERE id = :id'
+                       'WHERE id = ?'
                );
 
                return $this->update( $sql, array( $id ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/192199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f3faca5498bdd3a62c7d97fda56bc9a691fa673
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/iegreview
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <niharikakohl...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to