From 8272c76d2b4a5323dce7540658b09357ad34f7e0 Mon Sep 17 00:00:00 2001 From: llaffont <llaffont@git-test.afi-sa.fr> Date: Tue, 31 Jul 2012 17:22:15 +0000 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20gestion=20des=20plages=20d'ouvertu?= =?UTF-8?q?re?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitattributes | 6 ++ .../controllers/OuverturesController.php | 50 +++++++++++ .../admin/views/scripts/ouvertures/add.phtml | 1 + .../admin/views/scripts/ouvertures/edit.phtml | 1 + .../views/scripts/ouvertures/index.phtml | 8 ++ categories.org | 5 +- library/Class/Multimedia/Location.php | 4 - library/Class/Ouverture.php | 30 +++++++ library/Class/Profil.php | 5 -- .../Action/RessourceDefinitions.php | 10 ++- .../controllers/OuverturesControllerTest.php | 83 +++++++++++++++++++ 11 files changed, 191 insertions(+), 12 deletions(-) create mode 100644 application/modules/admin/controllers/OuverturesController.php create mode 100644 application/modules/admin/views/scripts/ouvertures/add.phtml create mode 100644 application/modules/admin/views/scripts/ouvertures/edit.phtml create mode 100644 application/modules/admin/views/scripts/ouvertures/index.phtml create mode 100644 library/Class/Ouverture.php create mode 100644 tests/application/modules/admin/controllers/OuverturesControllerTest.php diff --git a/.gitattributes b/.gitattributes index 02af0bba9ac..4e43514d167 100644 --- a/.gitattributes +++ b/.gitattributes @@ -296,6 +296,7 @@ application/modules/admin/controllers/MultimediaController.php -text application/modules/admin/controllers/NewsletterController.php -text application/modules/admin/controllers/OaiController.php -text application/modules/admin/controllers/OpdsController.php -text +application/modules/admin/controllers/OuverturesController.php -text application/modules/admin/controllers/ProfilController.php -text application/modules/admin/controllers/RssController.php -text application/modules/admin/controllers/SitoController.php -text @@ -460,6 +461,9 @@ application/modules/admin/views/scripts/opds/add.phtml -text application/modules/admin/views/scripts/opds/browse.phtml -text application/modules/admin/views/scripts/opds/edit.phtml -text application/modules/admin/views/scripts/opds/index.phtml -text +application/modules/admin/views/scripts/ouvertures/add.phtml -text +application/modules/admin/views/scripts/ouvertures/edit.phtml -text +application/modules/admin/views/scripts/ouvertures/index.phtml -text application/modules/admin/views/scripts/profil/_erreur_profil.phtml -text application/modules/admin/views/scripts/profil/_formProfil.phtml -text application/modules/admin/views/scripts/profil/_page_row.phtml -text @@ -1741,6 +1745,7 @@ library/Class/NoticeHtml.php -text library/Class/NoticeOAI.php -text library/Class/NoticeUnimarc.php -text library/Class/OpdsCatalog.php -text +library/Class/Ouverture.php -text library/Class/PanierNotice.php -text library/Class/Pcdm4.php -text library/Class/Pdf/font/courier.php -text @@ -3580,6 +3585,7 @@ tests/application/modules/admin/controllers/MultimediaControllerTest.php -text tests/application/modules/admin/controllers/NewsletterControllerTest.php -text tests/application/modules/admin/controllers/OaiControllerTest.php -text tests/application/modules/admin/controllers/OpdsControllerTest.php -text +tests/application/modules/admin/controllers/OuverturesControllerTest.php -text tests/application/modules/admin/controllers/ProfilControllerIndexTest.php -text tests/application/modules/admin/controllers/ProfilControllerPageAccueilTest.php -text tests/application/modules/admin/controllers/ProfilControllerProfilJeunesseAndAdultesWithMenusTest.php -text diff --git a/application/modules/admin/controllers/OuverturesController.php b/application/modules/admin/controllers/OuverturesController.php new file mode 100644 index 00000000000..3a383fc69d8 --- /dev/null +++ b/application/modules/admin/controllers/OuverturesController.php @@ -0,0 +1,50 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 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 AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class Admin_OuverturesController extends ZendAfi_Controller_Action { + public function getRessourceDefinitions() { + return array( + 'model' => array('class' => 'Class_Ouverture', + 'name' => 'ouverture', + 'order' => 'debut_matin'), + 'messages' => array('successful_add' => 'Plage d\'ouverture %s ajoutée', + 'successful_save' => 'Plage d\'ouverture %s sauvegardée', + 'successful_delete' => 'Plage d\'ouverture %s supprimée'), + + 'actions' => array('edit' => array('title' => 'Modifier une plage d\'ouverture'), + 'add' => array('title' => 'Ajouter une plage d\'ouverture'), + 'index' => array('title' => 'Plages d\'ouverture')), + + 'display_groups' => array('plage_ouverture' => array('legend' => 'Plage d\'ouverture', + 'elements' => array( + 'debut_matin' => array('element' => 'select', + 'options' => array('label' => 'Début matinée', + 'multiOptions' => Class_Multimedia_Location::getLoader()->getPossibleHours(30)) + ) + ) + ) + ) + ); + } + +} + +?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/ouvertures/add.phtml b/application/modules/admin/views/scripts/ouvertures/add.phtml new file mode 100644 index 00000000000..dc46f2831c7 --- /dev/null +++ b/application/modules/admin/views/scripts/ouvertures/add.phtml @@ -0,0 +1 @@ +<?php echo $this->renderForm($this->form); ?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/ouvertures/edit.phtml b/application/modules/admin/views/scripts/ouvertures/edit.phtml new file mode 100644 index 00000000000..dc46f2831c7 --- /dev/null +++ b/application/modules/admin/views/scripts/ouvertures/edit.phtml @@ -0,0 +1 @@ +<?php echo $this->renderForm($this->form); ?> \ No newline at end of file diff --git a/application/modules/admin/views/scripts/ouvertures/index.phtml b/application/modules/admin/views/scripts/ouvertures/index.phtml new file mode 100644 index 00000000000..52d3eff9666 --- /dev/null +++ b/application/modules/admin/views/scripts/ouvertures/index.phtml @@ -0,0 +1,8 @@ +<?php + echo $this->tagModelTable($this->ouvertures, + array($this->_('Début matin')), + array('debut_matin'), + array(array('action' => 'edit', 'content' => $this->boutonIco('type=edit')), + array('action' => 'delete', 'content' => $this->boutonIco('type=del'))), + 'ouvertures'); +?> \ No newline at end of file diff --git a/categories.org b/categories.org index 95ed4175167..45f7a604322 100644 --- a/categories.org +++ b/categories.org @@ -2,9 +2,10 @@ * AFI Multimedia ** Planning des ouvertures + [[file:library/Class/Ouverture.php::class%20Class_Ouverture%20extends%20Storm_Model_Abstract%20{][Modele Ouverture]] [[file:tests/application/modules/admin/controllers/OuverturesControllerTest.php::abstract%20class%20OuverturesControllerTestCase%20extends%20Admin_AbstractControllerTestCase%20{][Tests Controller Ouvertures]] - [[file:application/modules/admin/controllers/OuverturesController.php::class%20Admin_OuverturesController%20extends%20Zend_Controller_Action%20{][Controller Ouvertures]] - [[file:application/modules/admin/views/scripts/ouvertures/edit.phtml::<?php%20?][Vue edit ouverture]] + [[file:application/modules/admin/controllers/OuverturesController.php::class%20Admin_OuverturesController%20extends%20ZendAfi_Controller_Action%20{][Controller Ouvertures]] + [[file:application/modules/admin/views/scripts/ouvertures/edit.phtml::<?php%20echo%20$this->renderForm($this->form)%3B%20?][Vue edit ouverture]] - [[http://localhost/afi-opac3/admin/ouvertures/edit/site_id/1/id/2][Page édition d'une ouverture]] ** Skin réservation timeline [[http://localhost/afi-opac3/abonne/multimedia-hold-location][url page réservation]] [[file:public/opac/css/global.css::.timeline%20{][CSS .timeline]] diff --git a/library/Class/Multimedia/Location.php b/library/Class/Multimedia/Location.php index 565d7796f33..afd971c0d9b 100644 --- a/library/Class/Multimedia/Location.php +++ b/library/Class/Multimedia/Location.php @@ -111,10 +111,6 @@ class Class_Multimedia_Location extends Storm_Model_Abstract { protected $_default_attribute_values = array('days' => ''); - public static function getLoader() { - return self::getLoaderFor(__CLASS__); - } - /** * @param $date string (YYYY-MM-DD) diff --git a/library/Class/Ouverture.php b/library/Class/Ouverture.php new file mode 100644 index 00000000000..2cfc2c98956 --- /dev/null +++ b/library/Class/Ouverture.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 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 AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +class Class_Ouverture extends Storm_Model_Abstract { + protected $_table_name = 'ouvertures'; + + public function getLibelle() { + return ''; + } +} + +?> \ No newline at end of file diff --git a/library/Class/Profil.php b/library/Class/Profil.php index 8d83c2b6233..c345da63f9e 100644 --- a/library/Class/Profil.php +++ b/library/Class/Profil.php @@ -83,11 +83,6 @@ class Class_Profil extends Storm_Model_Abstract { protected $_translator; - public static function getLoader() { - return self::getLoaderFor(__CLASS__); - } - - /** * @return Class_Profil */ diff --git a/library/ZendAfi/Controller/Action/RessourceDefinitions.php b/library/ZendAfi/Controller/Action/RessourceDefinitions.php index 3b72b2a9fe5..25d2977e5af 100644 --- a/library/ZendAfi/Controller/Action/RessourceDefinitions.php +++ b/library/ZendAfi/Controller/Action/RessourceDefinitions.php @@ -38,7 +38,8 @@ class ZendAfi_Controller_Action_RessourceDefinitions { public function findAll() { - return $this->getModelLoader()->findAllBy(array('order' => 'libelle')); + + return $this->getModelLoader()->findAllBy(array('order' => $this->getOrder())); } @@ -84,6 +85,13 @@ class ZendAfi_Controller_Action_RessourceDefinitions { return $this->_definitions['model']['class']; } + + public function getOrder() { + if (isset($this->_definitions['model']['order'])) + return $this->_definitions['model']['order']; + return 'libelle'; + } + public function getModelName() { return $this->_definitions['model']['name']; diff --git a/tests/application/modules/admin/controllers/OuverturesControllerTest.php b/tests/application/modules/admin/controllers/OuverturesControllerTest.php new file mode 100644 index 00000000000..8762676522e --- /dev/null +++ b/tests/application/modules/admin/controllers/OuverturesControllerTest.php @@ -0,0 +1,83 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 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 AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +require_once 'AdminAbstractControllerTestCase.php'; + +abstract class OuverturesControllerTestCase extends Admin_AbstractControllerTestCase { + public function setUp() { + parent::setUp(); + Storm_Test_ObjectWrapper::onLoaderOfModel('Class_Ouverture') + ->whenCalled('findAll') + ->answers(array( + Class_Ouverture::getLoader() + ->newInstanceWithId(2) + ->setDebutMatin('08h00'))); + } +} + + + +class OuverturesControllerIndexActionTest extends OuverturesControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/ouvertures', true); + } + + /** @test */ + public function ouvertureAtHeightShouldBeVisible() { + $this->assertXPath('//td', '08h00'); + } +} + + + + +class OuverturesControllerEditOuvertureMardiTest extends OuverturesControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/ouvertures/edit/site_id/1/id/2', true); + } + + + /** @test */ + public function formShouldContainsSelectForDebutMatin() { + $this->assertXPath('//form//select'); + } +} + + + + +class OuverturesControllerAddOuvertureTest extends OuverturesControllerTestCase { + public function setUp() { + parent::setUp(); + $this->dispatch('/admin/ouvertures/add/site_id/1', true); + } + + + /** @test */ + public function formShouldContainsSelectForDebutMatin() { + $this->assertXPath('//form//select'); + } +} + + + +?> \ No newline at end of file -- GitLab