Commit b7aaaddd authored by Laurent's avatar Laurent
Browse files

hotline #52364 : revert legacy training page

parent 232e925e
Pipeline #89 passed with stage
in 8 minutes and 54 seconds
- ticket #52364 : Restauration de l'ancienne page listant les formations
\ No newline at end of file
......@@ -68,7 +68,7 @@ class AbonneController extends ZendAfi_Controller_Action {
public function inscrireSessionAction() {
$this->_redirect('/formations');
$this->_redirectToReferer();
if ((!$session = Class_SessionFormation::find((int)$this->_getParam('id')))
|| $session->isInscriptionClosed())
......@@ -1183,4 +1183,22 @@ class AbonneController extends ZendAfi_Controller_Action {
$this->_redirectToReferer();
}
public function formationsAction() {
$this->view->titre = $this->_('S\'inscrire à une formation');
$this->view->sessions = Class_SessionFormation::findAllAvailable($this->_user);
}
public function formationsRegisteredAction() {
$this->view->titre = $this->_('Mes inscriptions en cours');
$this->view->sessions = Class_SessionFormation::findAllRegistered($this->_user);
}
public function formationsDoneAction() {
$this->view->titre = $this->_('Mes formations suivies');
$this->view->sessions = Class_SessionFormation::findAllDone($this->_user);
}
}
\ No newline at end of file
......@@ -28,16 +28,15 @@ class FormationsController extends ZendAfi_Controller_Action {
public function indexAction() {
$this->view->titre = $this->_('S\'inscrire à une formation');
$this->view->sessions = Class_SessionFormation::findAllAvailable($this->_user);
$this->sessions_inscrit = [];
$this->view->formations_by_year = Class_Formation::indexByYear(Class_Formation::findAll());
$this->view->user = $this->_user;
}
public function detailSessionAction() {
if (!$session = Class_SessionFormation::find((int)$this->_getParam('id'))) {
$this->_redirect('/formations/index');
return;
}
if (!$session = Class_SessionFormation::find((int)$this->_getParam('id')))
return $this->_redirectToReferer();
$this->view->url_retour = ($this->_getParam('retour'))
? $this->_getParam('retour')
......@@ -46,16 +45,4 @@ class FormationsController extends ZendAfi_Controller_Action {
null, true);
$this->view->session = $session;
}
public function registeredAction() {
$this->view->titre = $this->_('Mes inscriptions en cours');
$this->view->sessions = Class_SessionFormation::findAllRegistered($this->_user);
}
public function doneAction() {
$this->view->titre = $this->_('Mes formations suivies');
$this->view->sessions = Class_SessionFormation::findAllDone($this->_user);
}
}
\ No newline at end of file
<?php
$this->openBoite($this->titre);
$details_link = $this->url(['action' => 'detail-session',
$details_link = $this->url(['controller' => 'formations',
'action' => 'detail-session',
'id' => null]);
$current_link = $this->url();
......
<?php
$this->openBoite($this->titre);
$details_link = $this->url(['action' => 'detail-session',
$details_link = $this->url(['controller' => 'formations',
'action' => 'detail-session',
'id' => null]);
$unregister_link = $this->url(['controller' => 'abonne',
......
<?php
echo $this->openBoite($this->titre);
$details_link = $this->url(['controller' => 'formations',
'action' => 'detail-session',
'id' => null]);
$register_link = $this->url(['controller' => 'abonne',
'action' => 'inscrire-session',
'id' => null]);
$current_link = $this->url();
echo $this->tagModelTable(
$this->sessions,
[$this->_('Formation'),
$this->_('Date'),
$this->_('Lieu'),
$this->_('Informations')],
['libelle_formation',
'date_debut_texte',
'libelle_lieu',
'infos'],
[function($model) use($details_link, $register_link, $current_link) {
return $this->modelActions($model,
[['url' => $details_link . '/id/%s?retour=' . $current_link,
'icon' => 'view',
'label' => $this->_('Details de la session %s',
$model->getLabel())],
['url' => $register_link . '/id/%s',
'icon' => 'add_user',
'label' => $this->_('S\'inscrire à la session %s',
$model->getLabel())]]
);}],
'available_sessions',
null,
['infos' => function($model) {
return $this->_('Date limite d\'inscription : %s',
$model->getDateLimiteInscriptionHumanRead());
}]
);
$this->closeBoite();
echo $this->abonne_RetourFiche();
<?php
echo $this->openBoite($this->titre);
echo $this->openBoite('Formations');
$details_link = $this->url(['action' => 'detail-session',
'id' => null]);
if ($this->user && !$this->user->hasRightSuivreFormation())
echo sprintf('<p class="error">%s</p>',
$this->_("Vous n'avez pas les droits suffisants pour vous inscrire à une formation"));
$register_link = $this->url(['controller' => 'abonne',
'action' => 'inscrire-session',
'id' => null]);
foreach($this->formations_by_year as $year => $formations) {
echo '<div class="formations">';
echo $this->partialCycle('formations/_formation.phtml',
'formation',
$formations,
['first', 'second']);
echo '</div>';
}
$current_link = $this->url();
echo $this->closeBoite();
?>
echo $this->tagModelTable(
$this->sessions,
[$this->_('Formation'),
$this->_('Date'),
$this->_('Lieu'),
$this->_('Informations')],
['libelle_formation',
'date_debut_texte',
'libelle_lieu',
'infos'],
[function($model) use($details_link, $register_link, $current_link) {
return $this->modelActions($model,
[['url' => $details_link . '/id/%s?retour=' . $current_link,
'icon' => 'view',
'label' => $this->_('Details de la session %s',
$model->getLabel())],
['url' => $register_link . '/id/%s',
'icon' => 'add_user',
'label' => $this->_('S\'inscrire à la session %s',
$model->getLabel())]]
);}],
'available_sessions',
null,
['infos' => function($model) {
return $this->_('Date limite d\'inscription : %s',
$model->getDateLimiteInscriptionHumanRead());
}]
);
$this->closeBoite();
echo $this->abonne_RetourFiche();
<?php if ($this->user) echo $this->abonne_RetourFiche(); ?>
......@@ -20,7 +20,6 @@
*/
class SessionFormationLoader extends Storm_Model_Loader {
public function findAllAvailable($user) {
if(!$user)
return [];
......
......@@ -25,8 +25,8 @@ class ZendAfi_View_Helper_Abonne_Formations extends ZendAfi_View_Helper_Abonne_A
|| !$user->hasRightSuivreFormation())
return '';
$action_url = $this->view->url(['controller' => 'formations',
'action' => 'index'],
$action_url = $this->view->url(['controller' => 'abonne',
'action' => 'formations'],
null,
true);
......@@ -43,12 +43,12 @@ class ZendAfi_View_Helper_Abonne_Formations extends ZendAfi_View_Helper_Abonne_A
return $this
->_tag('ul',
$this->_tag('li',
$this->view->tagAnchor(['controller' => 'formations',
'action' => 'done'],
$this->view->tagAnchor(['controller' => 'abonne',
'action' => 'formations-done'],
$this->_('Mes formations suivies')))
. $this->_tag('li',
$this->view->tagAnchor(['controller' => 'formations',
'action' => 'registered'],
$this->view->tagAnchor(['controller' => 'abonne',
'action' => 'formations-registered'],
$this->_('Mes inscriptions en cours'))));
}
}
\ No newline at end of file
......@@ -42,6 +42,8 @@ abstract class AbstractAbonneControllerFormationsTestCase
public function setUp() {
parent::setUp();
$_SERVER['HTTP_REFERER'] = '/formations';
$test_time = new TimeSourceForTest('2014-05-01 14:00:00');
Class_Formation::setTimeSource($test_time);
......@@ -211,31 +213,28 @@ class AbonneControllerFormationsListWithLearnJavaNotVisibleTest extends Abstract
public function setUp() {
parent::setUp();
$this->_learn_java->hide()->save();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
}
/** @test */
function noH2ShouldContainsLearnJava() {
public function noH2ShouldContainsLearnJava() {
$this->assertNotXPathContentContains('//h2', 'Learn Java');
}
/** @test */
function sessionMarsShouldNotBeVisible() {
public function sessionMarsShouldNotBeVisible() {
$this->assertNotXPathContentContains('//tbody//tr//td', '1 mars 2014');
}
}
class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest extends AbstractAbonneControllerFormationsTestCase {
/** @test */
public function trainingJavaShouldBeDisplayed() {
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
$this->assertXPathContentContains('//td', 'Learn Java');
}
......@@ -243,7 +242,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte
/** @test */
function noH2ShouldContainsLearnSmalltalk() {
$this->_learn_smalltalk->hide()->save();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
$this->assertNotXPathContentContains('//h2', 'Learn Smalltalk');
}
......@@ -251,7 +250,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte
/** @test */
function sessionJuilletShouldNotBeVisibleIfParentTrainingIsHidden() {
$this->_learn_smalltalk->hide()->save();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
$this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014');
}
......@@ -260,7 +259,7 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte
function sessionJuilletShouldNotBeVisibleIfHidden() {
$this->_learn_smalltalk->show()->save();
$this->_session_smalltalk_juillet->hide()->save();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
$this->assertNotXPathContentContains('//tbody//tr//td', '11 juillet 2014');
}
......@@ -269,10 +268,9 @@ class AbonneControllerFormationsSessionListWithLearnSmalltalkNotVisibleTest exte
function sessionJuilletShouldBeVisibleIfShow() {
$this->_learn_smalltalk->show()->save();
$this->_session_smalltalk_juillet->show()->save();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
$this->assertXPathContentContains('//td', '11 juillet 2014');
}
}
......@@ -293,7 +291,7 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati
->show()
->assertSave();
$this->dispatch('/opac/formations', true);
$this->dispatch('/opac/abonne/formations', true);
}
......@@ -431,13 +429,13 @@ class AbonneControllerFormationsListTest extends AbstractAbonneControllerFormati
class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/abonne/fiche?retour=/opac/abonne/fiche', true);
$this->dispatch('/opac/abonne/fiche', true);
}
/** @test */
public function pageShouldContainsLinkToFormations() {
$this->assertXPathContentContains('//a[contains(@href, "/formations")]',
$this->assertXPathContentContains('//a[contains(@href, "/abonne/formations")]',
'S\'inscrire à une formation');
}
......@@ -450,14 +448,14 @@ class AbonneControllerFormationsFicheAbonneTest extends AbstractAbonneController
/** @test */
public function pageShouldContainsLinkToRegistrations() {
$this->assertXPathContentContains('//a[contains(@href, "/formations/registered")]',
$this->assertXPathContentContains('//a[contains(@href, "/abonne/formations-registered")]',
'Mes inscriptions en cours');
}
/** @test */
public function pageShouldContainsLinkToDone() {
$this->assertXPathContentContains('//a[contains(@href, "/formations/done")]',
$this->assertXPathContentContains('//a[contains(@href, "/abonne/formations-done")]',
'Mes formations suivies');
}
}
......@@ -470,7 +468,7 @@ class AbonneControllerFormationsRegisteredActionTest
public function setUp() {
parent::setUp();
$this->dispatch('/formations/registered', true);
$this->dispatch('/abonne/formations-registered', true);
}
......@@ -523,10 +521,9 @@ class AbonneControllerFormationsDoneActionTest
extends AbstractAbonneControllerFormationsTestCase {
public function setUp() {
parent::setUp();
$this->_session_python_juillet->setDateDebut('2006-09-09')->assertSave();
$this->dispatch('/formations/done', true);
$this->dispatch('/abonne/formations-done', true);
}
......@@ -588,7 +585,7 @@ class AbonneControllerFormationsListWithoutRightSuivreFormationTest extends Abst
public function setUp() {
parent::setUp();
$this->_amadou->setUserGroups([]);
$this->dispatch('/opac/formations');
$this->dispatch('/opac/abonne/formations');
}
......@@ -816,7 +813,7 @@ class AbonneControllerFormationsSessionJavaFevrierFullListTest extends AbonneCon
parent::setUp();
Class_AdminVar::newInstanceWithId('CHAMPS_FICHE_UTILISATEUR',
['valeur' => 'pseudo;nom;prenom;mail']);
$this->dispatch('/opac/formations');
$this->dispatch('/opac/abonne/formations');
}
......@@ -833,7 +830,7 @@ class AbonneControllerFormationsSessionJavaFevrierFullAndInscritListTest extends
public function pageShouldHaveLinkToDesinscrire() {
$this->_session_java_fevrier->addStagiaire($this->_amadou);
$this->_amadou->setSessionFormations(array($this->_session_java_fevrier));
$this->dispatch('/opac/formations/registered');
$this->dispatch('/opac/abonne/formations-registered');
$this->assertXPath('//a[contains(@href, "abonne/desinscrire-session/id/31")]');
}
}
......@@ -886,14 +883,10 @@ class AbonneControllerFormationsInscritSessionWithoutRightSuivreFormationTest ex
class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest
extends AbstractAbonneControllerFormationsTestCase {
protected $_mails, $_previous_referer;
protected $_mails;
public function setUp() {
parent::setUp();
$this->_previous_referer = isset($_SERVER['HTTP_REFERER'])
? $_SERVER['HTTP_REFERER']
: null;
$_SERVER['HTTP_REFERER'] = '/formations';
$this->dispatch('/opac/abonne/desinscrire-session/id/121', true);
......@@ -901,14 +894,6 @@ class AbonneControllerFormationsAmadouDesinscritSessionJuilletPythonTest
}
public function tearDown() {
if ($this->_previous_referer)
$_SERVER['HTTP_REFERER'] = $this->_previous_referer;
parent::tearDown();
}
/** @test */
function answerShouldRedirectToFormationList() {
$this->assertRedirectTo('/formations');
......@@ -1098,43 +1083,29 @@ class AbonneControllerFormationsSessionJuilletPythonDetailRetourFicheTest extend
class AbonneControllerFormationsWrongIdsTest extends AbstractAbonneControllerFormationsTestCase {
protected $_previous_referer;
public function setUp() {
parent::setUp();
$this->_previous_referer = isset($_SERVER['HTTP_REFERER'])
? $_SERVER['HTTP_REFERER']
: null;
$_SERVER['HTTP_REFERER'] = '/formations';
$_SERVER['HTTP_REFERER'] = '/abonne/formations';
}
public function tearDown() {
if ($this->_previous_referer)
$_SERVER['HTTP_REFERER'] = $this->_previous_referer;
parent::tearDown();
}
/** @test */
public function detailSessionShouldRedirectToFormations() {
$this->dispatch('/opac/formations/detail-session/id/9999');
$this->assertRedirectTo('/formations/index');
$this->assertRedirectTo('/abonne/formations');
}
/** @test */
public function inscrireSessionShouldRedirectToFormations() {
$this->dispatch('/opac/abonne/inscrire-session/id/9999');
$this->assertRedirectTo('/formations');
$this->assertRedirectTo('/abonne/formations');
}
/** @test */
public function desinscrireSessionShouldRedirectToFormations() {
$this->dispatch('/opac/abonne/desinscrire-session/id/9999');
$this->assertRedirectTo('/formations');
$this->assertRedirectTo('/abonne/formations');
}
}
\ No newline at end of file
......@@ -127,6 +127,24 @@ class FormationsControllerFormationsSessionFevrierJavaTest extends AbstractForma
class FormationsControllerAnonymousTest extends AbstractFormationsControllerTestCase {
public function setUp() {
parent::setUp();
$this->dispatch('/opac/formations', true);
}
/** @test */
public function sessionShouldDisplaySubscribeTime() {
$this->assertXPathContentContains('//tbody//tr/td/span',
'Date de limite d\'inscription:');
}
}
class FormationsControllerFormationsSessionJuilletPythonDetailRetourFicheTest extends AbstractFormationsControllerTestCase {
public function setUp() {
parent::setUp();
......@@ -137,5 +155,4 @@ class FormationsControllerFormationsSessionJuilletPythonDetailRetourFicheTest ex
public function pageShouldContainsAButtontoGoBackToFicheAbonne() {
$this->assertXPathContentContains('//a[contains(@href, "abonne/fiche")]', 'Retour', $this->_response->getBody());
}
}
\ No newline at end of file
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