Commit f152436b authored by Ghislain Loas's avatar Ghislain Loas

Merge branch 'hotline' into 'master'

Hotline

See merge request afi/opacce!2683
parents 9f22eb1e bea83329
- ticket #72286 : Boite Kiosque : correction de la mise en cache en affichage aléatoire.
\ No newline at end of file
- ticket #75544 : Boite article : amélioration du chargement du diaporama avec navigation.
\ No newline at end of file
- ticket #75730 : MyBibApp: correction de la récupération des prêts PNB.
\ No newline at end of file
......@@ -23,7 +23,8 @@
class Api_UserController extends ZendAfi_Controller_Action {
public function preDispatch() {
parent::preDispatch();
$this->_authenticate();
if (!Class_Users::hasIdentity())
$this->_authenticate();
}
......
......@@ -293,8 +293,15 @@ class CatalogueLoader extends Storm_Model_Loader {
if (!array_key_exists("req_liste", $requetes))
return [];
$nb_par_page = (array_key_exists('aleatoire', $preferences)
&& array_key_exists('nb_analyse', $preferences)
&& $preferences['aleatoire']
&& $preferences['nb_analyse'])
? $preferences['nb_analyse']
: $preferences['nb_notices'];
return Class_Notice::findAllByRequeteRecherche($requetes['req_ids'],
$preferences['nb_notices'],
$nb_par_page,
1);
}
......@@ -454,9 +461,14 @@ class CatalogueLoader extends Storm_Model_Loader {
public function getNoticesFromCacheByPreferences($preferences) {
return (new Storm_Cache())
->memoize([$preferences, __CLASS__, __FUNCTION__],
function() use ($preferences) { return Class_Catalogue::getLoader()->fetchAllNoticesByPreferences($preferences);});
$callback = function() use ($preferences) {
return Class_Catalogue::getLoader()->fetchAllNoticesByPreferences($preferences);
};
return (array_key_exists('aleatoire', $preferences)
&& $preferences['aleatoire'])
? $callback()
: (new Storm_Cache())->memoize([$preferences, __CLASS__, __FUNCTION__], $callback);
}
......
......@@ -104,6 +104,13 @@ class Class_Loan_Pnb extends Storm_Model_Abstract {
}
public function getNoticeOPAC() {
return ($album = $this->getAlbum())
? $album->getNotice()
: null;
}
public function setAlbum($album) {
return $this->setRecordOriginId($album->getIdOrigine());
}
......@@ -144,6 +151,12 @@ class Class_Loan_Pnb extends Storm_Model_Abstract {
}
public function getDateRetourISO8601() {
return substr($this->getDateRetour(), 0, 10);
}
public function isRenewable() {
return false;
}
......
......@@ -408,7 +408,9 @@ class ZendAfi_View_Helper_Accueil_Base extends ZendAfi_View_Helper_ModuleAbstrac
Class_ScriptLoader::getInstance()
->addScript(URL_JAVA . 'slider_navigation/slider_navigation.js')
->addJQueryReady('$("#boite_'.$this->getIdModule().'").slider_navigation('. json_encode($options) .');');
->addInlineStyle(sprintf('#boite_%s article, .preview_button img {height: 0; width: 0;}',
$this->getIdModule()))
->addJQueryReady('$("#boite_' . $this->getIdModule() . '").slider_navigation('. json_encode($options) .');');
}
......
......@@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Holds extends Zend_View_Helper_Abstract {
public function holdToArray($hold) {
$datas = [
'id' => $hold->getId(),
'title' => $hold->getTitre(),
'title' => strip_tags($hold->getTitre()),
'author' => $hold->getAuteur(),
'status' => $hold->getEtat(),
'held_by' => $hold->getUserFullName(),
......
......@@ -32,7 +32,7 @@ class ZendAfi_View_Helper_Api_Loans extends Zend_View_Helper_Abstract {
public function loanToArray($loan) {
$datas = [
'id' => $loan->getId(),
'title' => $loan->getTitre(),
'title' => strip_tags($loan->getTitre()),
'author' => $loan->getAuteur(),
'date_due' => $loan->getDateRetourISO8601(),
'loaned_by' => $loan->getUserFullName(),
......
......@@ -36,7 +36,6 @@
background: url('../../images/buttons/2rightarrow.png') no-repeat 0px 0px;
}
.preview_button {
border: 1px solid black;
cursor: pointer;
......
......@@ -537,7 +537,7 @@ class CatalogueTestOAISpec extends ModelTestCase {
class CatalogueTestGetNoticesByPreferences extends ModelTestCase {
class CatalogueGetNoticesByPreferencesNotRandomTest extends ModelTestCase {
public function setUp() {
parent::setUp();
......@@ -569,31 +569,20 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase {
'unimarc' => "01328ngm0 2200265 450 0010007000001000041000071010013000481020007000611150025000682000071000932100022001642150053001863000035002393000045002743300454003193450027007735100018008006060027008186060039008457000042008847020043009267020033009697020032010028010028010342247456 a20021213i20041975u y0frey0103 ba0 abamjfre aFR ac086baz|zba zz c1 aLa jeune fillebDVDdDen MusofSouleymane Cisse, réal., scénario cPathédcop. 2004 a1 DVD vidéo monoface zone 2 (1 h 26 min)ccoul. aDate de sortie du film : 1975. aFilm en bambara sous-titré en français aSékou est renvoyé de l'usine parce qu'il a osé demander une augmentation. Chômeur, il sort avec Ténin, une jeune fille muette ; il ignore qu'elle est la fille de son ancien patron. Ténin, qui sera violée par Sékou lors d'une sortie entre jeunes, se retrouve enceinte et subit la colère de ses parents. Elle se trouve alors confrontée brutalement à la morale de sa famille et à la lâcheté de Sékou, qui refuse de reconnaiîre l'enfant. b3388334509824d14.00 ?1 aDen Musozbam| 31070135aCinémayMali| 32243367aCinéma30076549yAfrique 131070144aCissébSouleymane43704690 132247457aCoulibalibDounamba Dani4590 132247458aDiabatebFanta4590 132247459aDiarrabOumou4590 0aFRbBNc20011120gAFNOR"]);
$this->old_sql = Zend_Registry::get('sql');
$this->mock_sql = Storm_Test_ObjectWrapper::mock();
Zend_Registry::set('sql', $this->mock_sql);
Zend_Registry::set('sql',
$this->mock()
->whenCalled('fetchAllByColumn')
->with("select notices.id_notice from notices Where notices.type_doc='1' order by alpha_titre LIMIT 0,40")
->answers([23])
$this->mock_sql
->whenCalled('fetchAllByColumn')
->with("select notices.id_notice from notices Where notices.type_doc='1' order by alpha_titre LIMIT 0,25")
->answers([23])
->beStrict());
->whenCalled('query')
->with([0 => 'update notices set facettes = clean_spaces(replace(facettes,"HCCCC0030","")) where notices.type_doc not in (\'8\',\'9\',\'10\') and match(facettes) against("+HCCCC0030" in boolean mode)'])
->answers(true)
->beStrict();
$prefs = ['id_catalogue' => 666,
'aleatoire' => '0',
'nb_analyse' => 25,
'nb_notices' => 40];
$this->_notices = Class_Catalogue::getNoticesByPreferences(['id_catalogue' => 666,
'aleatoire' => '1',
'nb_analyse' => 25,
'nb_notices' => 40]);
}
public function tearDown() {
Zend_Registry::set('sql', $this->old_sql);
parent::tearDown();
$this->_notices = Class_Catalogue::getNoticesByPreferences($prefs);
}
......@@ -617,7 +606,7 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase {
/** @test */
public function saveInCacheShouldHaveBeenCalledWithSerializedNotices() {
$cached_record = unserialize($this->_cache->load('d7c046ce443b5097ce0cd3ec7023ca72'))[0];
$cached_record = unserialize($this->_cache->load('535ea089525b59be7f5c7b0eebcd52b0'))[0];
$this->assertEquals('La jeune fille', $cached_record->getTitrePrincipal());
}
......@@ -625,12 +614,12 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase {
/** @test */
public function getNoticesWithCachePresentShouldNotCallThem() {
$preferences = ['id_catalogue' => 666,
'aleatoire' => 1,
'aleatoire' => '0',
'nb_analyse' => 25,
'nb_notices' => 40];
/* this test will fail when Class_Catalogue::_default_attribute_values change */
$this->_cache->save(serialize(['test']), '6e2593bad86780aeba3c5b5b6cd4d5b5');
$this->_cache->save(serialize(['test']), '535ea089525b59be7f5c7b0eebcd52b0');
$notices = Class_Catalogue::getNoticesByPreferences($preferences);
......@@ -651,7 +640,7 @@ class CatalogueTestGetNoticesByPreferences extends ModelTestCase {
Class_Users::getLoader()->newInstanceWithId($account->ID_USER)->setRoleLevel($account->ROLE_LEVEL);
$notices = Class_Catalogue::getNoticesByPreferences(['id_catalogue' => 666,
'aleatoire' => 1,
'aleatoire' => '0',
'nb_analyse' => 25,
'nb_notices' => 40]);
$this->assertEquals(23, $notices[0]->getId());
......@@ -1186,4 +1175,33 @@ class CatalogueWithNoveltyTest extends ModelTestCase {
$this->assertSame('select * from notices Where MATCH(facettes) AGAINST(\' +(B10 B11) +(YROUB YISTR) +(HNNNN0001 HNNNN0002 HNANA0001 HNANA0002)\' IN BOOLEAN MODE) and date_creation >= \'2016-05-11\' order by alpha_titre LIMIT 5000',
$this->_domain_request['req_liste']);
}
}
/** @see #72286 */
class CatalogueFetchAllNoticeByPrefWithRandomTest extends ModelTestCase {
protected $_storm_default_to_volatile = true;
/** @test */
public function withRandomShouldUseNbAnalyseAsLimit() {
$this->fixture('Class_Catalogue',
['id' => 42,
'libelle' => 'Super domain',
'auteur' => '344']);
$this->onLoaderOfModel('Class_Notice')
->whenCalled('findAllByRequeteRecherche')
->with("select notices.id_notice from notices Where MATCH(facettes) AGAINST(' +( A344)' IN BOOLEAN MODE) order by alpha_titre LIMIT 0,1000",
1000,
1)
->beStrict();
$preferences = ['id_catalogue' => 42,
'nb_notices' => 10,
'nb_analyse' => 1000,
'aleatoire' => 1];
Class_Catalogue::fetchAllNoticesByPreferences($preferences);
}
}
\ No newline at end of file
......@@ -55,7 +55,7 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo
->setNoticeOPAC($this->fixture('Class_Notice',
['id' => 34,
'url_vignette' => 'http://img.com/potter.jpg',
'titre_principal' => 'Potter',
'titre_principal' => 'Harry Potter<br /> La chambre des secrets',
'auteur_principal' => 'J.K.R' ]));
$alice = new Class_WebService_SIGB_Emprunt('13', new Class_WebService_SIGB_Exemplaire(456));
......@@ -82,12 +82,32 @@ abstract class Scenario_MobileApplication_UserAccountTestCase extends AbstractCo
->reservationsAddAll([$afrodeezia])])
->assertSave();
Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient($this->mock()
->whenCalled('open_url')
->answers(''));
$this->fixture('Class_Loan_Pnb',
['id' => 5,
'subscriber_id' => $puppy->getIdabon(),
'ongoing' => true,
'expected_return_date' => '2022-05-02T18:14:14+02:00',
'loan_date' => '2016-06-13T15:10:02+02:00',
'album' => $this->fixture('Class_Album',
['id' => 4,
'notice_id' => 5,
'id_origine' => 'Dilicom-88817216',
'titre' => 'Pinocchio'])->addAuthor('Collodi')
]);
ZendAfi_Auth::getInstance()->clearIdentity();
}
public function tearDown() {
unset($_SERVER['HTTPS']);
Class_WebService_BibNumerique_Dilicom_Hub::setDefaultHttpClient(null);
parent::tearDown();
}
}
......@@ -114,7 +134,7 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_
/** @test */
public function responseShouldContainsPotterLoan() {
$this->assertEquals(['id' => '345_12',
'title' => 'Potter',
'title' => 'Harry Potter La chambre des secrets',
'author' => 'J.K.R',
'date_due' => '1974-01-01',
'loaned_by' => 'puppy',
......@@ -126,6 +146,19 @@ class Scenario_MobileApplication_UserAccountLoansWithTokenTest extends Scenario_
}
/** @test */
public function responseShouldContainsPinocchioPnbLoan() {
$this->assertEquals(['id' => '345_5',
'title' => 'Pinocchio',
'author' => 'Collodi',
'date_due' => '2022-05-02',
'loaned_by' => 'puppy',
'library' => ''
],
$this->_json['loans'][2]);
}
/** @test */
public function responseHeaderContentTypeShouldBeApplicationJson() {
$this->assertArraySubset(['name' => 'Content-Type',
......@@ -280,7 +313,25 @@ class Scenario_MobileApplication_UserAccountLoansWithoutTokenTest extends Scenar
"Content-Type" => "application/json"]);
$loans = json_decode($this->_response->getBody(), true);
$this->assertArraySubset(['title' => 'Potter',
$this->assertArraySubset(['title' => 'Harry Potter La chambre des secrets',
'author' => 'J.K.R',
'date_due' => '1974-01-01',
'loaned_by' => 'puppy',
'library' => 'Annecy'
],
$loans['loans'][0]);
}
/** @test */
public function withSessionOpenedShouldAnswerLoans() {
ZendAfi_Auth::getInstance()->logUser(Class_Users::find(345));
$this->dispatch('/api/user/loans',
true,
["Content-Type" => "application/json"]);
$loans = json_decode($this->_response->getBody(), true);
$this->assertArraySubset(['title' => 'Harry Potter La chambre des secrets',
'author' => 'J.K.R',
'date_due' => '1974-01-01',
'loaned_by' => 'puppy',
......
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