Commit ee54071d authored by Matthieu FAURE's avatar Matthieu FAURE
Browse files

Comptoir v2.4.8

parents e5dff985 b8f5ab51
Pipeline #1610 failed with stage
in 17 minutes and 36 seconds
......@@ -7,6 +7,26 @@ et le projet suit [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## Unreleased yet
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## [2.4.8](https://gitlab.adullact.net/Comptoir/Comptoir-srv/tags/v2.4.8) - 2018-08-14
### Added
### Changed
### Deprecated
### Removed
### Fixed
* [#542](https://gitlab.adullact.net/Comptoir/Comptoir-srv/issues/542) Correction de l'affichage de tous les logiciels d'un tag
### Security
## [2.4.8-rc.2](https://gitlab.adullact.net/Comptoir/Comptoir-srv/tags/v2.4.8-rc.2) - 2018-08-14
### Added
......
......@@ -6,6 +6,7 @@
* On this branch:
* change the version in `config/bootstrap.php`
* update `CHANGELOG.md`
* create the upgrade doc in `Documentation/For_ops/UPGRADE`
* Eventually make other adjustments
## 2. Merge, tag and push
......
# How to upgrade from v2.4.8-rc.1 to v2.4.8
## Save `config/comptoir.php`
```shell
cd /home/comptoir/Comptoir-srv && \
cp config/comptoir.php config/comptoir.php-$(date +%Y-%m-%d_%kh%M)
```
## Grab source code
As user `comptoir`, do:
```shell
cd /home/comptoir/Comptoir-srv && \
git fetch -p && \
git checkout "v2.4.8-rc.2"
```
## Update `config/comptoir.php`
1. `cd /home/comptoir/Comptoir-srv/config && cp comptoir.default.php comptoir.php`
1. Re-add customized values from the old `comptoir.php` into the new one (like the Piwik stanza or Pick of the month)
## Remove temporary i18n files
```shell
sudo rm -f /home/comptoir/Comptoir-srv/tmp/cache/persistent/*
```
......@@ -270,7 +270,7 @@ Configure::write(
// Version of comptoir
Configure::write('VERSION',
[
"footer" => "v2.4.8-rc.2"
"footer" => "v2.4.8"
]
);
......
......@@ -100,10 +100,6 @@ $basicRoutes = function (RouteBuilder $routes) {
'action' => 'servicesProviders',
'method' => ['GET', 'POST']
],
'users-software/:id' => [
'action' => 'usersSoftware',
'method' => ['GET', 'POST']
],
'alternative-to/:id' => [
'action' => 'alternativeTo',
'method' => 'GET'
......@@ -165,7 +161,7 @@ $basicRoutes = function (RouteBuilder $routes) {
/**
* Softwares routing
* Software routing
*/
$routes->resources('Softwares', function (RouteBuilder $routes) {
$routes->resources('Reviews', ["prefix" => Configure::read("DEFAULT_PREFIX")]);
......@@ -249,6 +245,10 @@ $basicRoutes = function (RouteBuilder $routes) {
'action' => 'view',
'method' => ['GET']
],
':id/software' => [
'action' => 'listAllSoftwareForAGivenTag',
'method' => ['GET']
],
]
]);
......
......@@ -3,8 +3,8 @@
namespace App\Controller\Api\V1;
use App\Controller\AppController;
use Cake\ORM\TableRegistry;
use Cake\Core\Configure;
use Cake\ORM\TableRegistry;
/**
* Softwares Controller
......@@ -157,7 +157,7 @@ class SoftwaresController extends AppController
[
'search' => $this->request->data,
"contain" => ["Reviews"],
])->select(['average_review' => $this->Softwares->query()->func()->coalesce([$this->Softwares->query()->func()->avg('Reviews.evaluation'), 0])]) // allow to sort by the virtual property "Average"
])->select(['average_review' => $this->Softwares->query()->func()->coalesce([$this->Softwares->query()->func()->avg('Reviews.evaluation'), 0])])// allow to sort by the virtual property "Average"
->leftJoinWith('Reviews')
->group(['Softwares.id'])
->autoFields(true);
......@@ -387,6 +387,12 @@ class SoftwaresController extends AppController
return $this->redirect(["prefix" => false, 'action' => 'index']);
}
/**
* Returns list of users of a given software (GET method)
* Adds current user in the list of users declared for the current software (POST method)
*
* @param null $id Id of a given software
*/
public function usersSoftware($id = null)
{
......
<?php
namespace App\Controller\Api\V1;
use App\Controller\AppController;
use Cake\Event\Event;
use Cake\Core\Configure;
use Cake\Event\Event;
/**
* Tags Controller
......@@ -27,9 +28,9 @@ class TagsController extends AppController
parent::initialize();
$this->paginate = [
'sortWhitelist'=>[
'used_tag_number',
'name'
'sortWhitelist' => [
'used_tag_number',
'name'
],
'limit' => Configure::read('LIMIT'),
'contain' => ['Softwares'],
......@@ -46,31 +47,29 @@ class TagsController extends AppController
{
if (!empty($this->request->data) && isset($this->request->data["order"])) {
$sort=explode(".",$this->request->data["order"]);
$sort = explode(".", $this->request->data["order"]);
$this->request->query["sort"] = $sort[0];
$this->request->query["direction"] = $sort[1];
}
$order = [
"name.asc"=>__d("Forms","Search.Sort.tagNameAsc"),
"name.desc"=>__d("Forms","Search.Sort.tagNameDesc"),
"used_tag_number.asc"=>__d("Forms","Search.Sort.usedTagNumberAsc"),
"used_tag_number.desc"=>__d("Forms","Search.Sort.usedTagNumberDesc"),
"name.asc" => __d("Forms", "Search.Sort.tagNameAsc"),
"name.desc" => __d("Forms", "Search.Sort.tagNameDesc"),
"used_tag_number.asc" => __d("Forms", "Search.Sort.usedTagNumberAsc"),
"used_tag_number.desc" => __d("Forms", "Search.Sort.usedTagNumberDesc"),
];
$tags = $this->Tags->find("all",['Softwares'])
->select(['used_tag_number'=>$this->Tags->query()->func()->count('SoftwaresTags.tag_id')])
$tags = $this->Tags->find("all", ['Softwares'])
->select(['used_tag_number' => $this->Tags->query()->func()->count('SoftwaresTags.tag_id')])
->innerJoinWith('Softwares')
->group(['Tags.id','SoftwaresTags.tag_id'])
->group(['Tags.id', 'SoftwaresTags.tag_id'])
->autoFields(true);
$this->paginate($tags);
$this->set(compact('tags'));
$this->set('order',$order);
$this->set('order', $order);
$this->set('_serialize', ['tags']);
}
......@@ -79,13 +78,15 @@ class TagsController extends AppController
$this->Auth->allow([
'add',
'edit',
'delete'
'delete',
'view',
'listAllSoftwareForAGivenTag'
]);
parent::beforeFilter($event);
}
/**
* View method
* View method of a given tag
*
* @param string|null $id Tag id.
* @return \Cake\Network\Response|null
......@@ -93,10 +94,26 @@ class TagsController extends AppController
*/
public function view($id = null)
{
$tag = $this->Tags->get($id);
$tag = $this->Tags->get($id,
['contain' => ['Softwares']]);
$this->set('tag', $tag);
$this->set('_serialize', ['tag']);
}
/**
* Returns a list of software associated to a given tag
*
* @param $id id of a given tag
*/
public function listAllSoftwareForAGivenTag($id)
{
$tag = $this->Tags->get($id,
['contain' => ['Softwares']]);
$this->set('tag', $tag);
$this->set('_serialize',['tag']);
$this->set('_serialize', ['tag']);
}
/**
......@@ -113,7 +130,7 @@ class TagsController extends AppController
if ($this->Tags->save($tag)) {
$message = "Success";
} else {
$this->Flash->error(__d('Tags',"error"));
$this->Flash->error(__d('Tags', "error"));
$message = "Error";
$tag = $tag->errors();
......@@ -121,7 +138,7 @@ class TagsController extends AppController
}
$softwares = $this->Tags->Softwares->find('list', ['limit' => 125]);
$this->set(compact('tag', 'softwares', 'message'));
$this->set('_serialize', ['tag','message']);
$this->set('_serialize', ['tag', 'message']);
}
/**
......@@ -133,7 +150,7 @@ class TagsController extends AppController
*/
public function edit($id = null)
{
$tag = $this->Tags->get($id);
$tag = $this->Tags->get($id);
if ($this->request->is(['patch', 'post', 'put'])) {
$tag = $this->Tags->patchEntity($tag, $this->request->data);
......@@ -168,4 +185,5 @@ class TagsController extends AppController
}
return $this->redirect(['action' => 'index']);
}
}
......@@ -3,8 +3,8 @@
namespace App\Controller\Api\V1;
use App\Controller\AppController;
use Cake\Core\Configure;
use App\Controller\Component\RulesComponent;
use Cake\Core\Configure;
use Cake\Event\Event;
use Cake\Mailer\MailerAwareTrait;
use Cake\ORM\Query;
......@@ -120,7 +120,7 @@ class UsersController extends AppController
'search' => $this->request->query,
'contain' => ['UserTypes'],
'order' => isset ($this->request->query["sort"]) && isset($this->request->query["direction"]) ?
['Users.'.$this->request->query["sort"] => $this->request->query["direction"]] :
['Users.' . $this->request->query["sort"] => $this->request->query["direction"]] :
['Users.username' => Configure::read('ORDER')]
,
]);
......@@ -358,8 +358,7 @@ class UsersController extends AppController
{
// Generate an 'token'
$user->token_plain =
Text::uuid()
;
Text::uuid();
$user->token = $user->token_plain;
return $user;
}
......
......@@ -17,7 +17,7 @@ $this->layout('base');
$software->userssoftwares,
[
"type" => "user",
"title" =>"<h1>" . __d("Softwares", "Users of {0}", $software->softwarename) . "</h1>",
"title" => "<h1>" . __d("Softwares", "Users of {0}", $software->softwarename) . "</h1>",
"linkParticipate" => [
"id" => $software->id,
"action" => "usersSoftware",
......
<?php
$this->layout = 'base';
$this->assign('title', __d("Tags","TitleTagsIndex"));
$this->assign('title', __d("Tags", "TitleTagsIndex"));
?>
<section class="row">
<h1><?= __d("Tags","TitleTagsIndexh1",count($tags)) ?></h1>
<h1><?= __d("Tags", "TitleTagsIndexh1", count($tags)) ?></h1>
</section>
<?= $this->Form->create(null, ['class' => "form-inline", 'title' => __d("Forms", "Search for softwares and users"),'method'=>"GET"]) ?>
<?= $this->Form->create(null, ['class' => "form-inline", 'title' => __d("Forms", "Search for softwares and users"), 'method' => "GET"]) ?>
<?php
......@@ -34,7 +34,6 @@ echo '</div>';
<?= $this->Form->end() ?>
<section class="row">
<ul class="list-inline">
<?php
......@@ -42,7 +41,7 @@ echo '</div>';
$tags,
[
"displayNumber" => true,
"class"=>"col-xs-12 col-sm-4 col-md-3 col-lg-2 tagCell",
"class" => "col-xs-12 col-sm-4 col-md-3 col-lg-2 tagCell",
]
);
......
<?php
$this->layout('base');
$this->assign('title', $tag->name);
?>
<section class="clearfix row">
<ul class="list-unstyled col-xs-12">
<li>
<h1><?= __d("Tags", "Tag") . " " . $tag->name ?></h1>
</li>
</ul>
</section>
<section class="clearfix">
<?php
echo $this->Lists->block(
$tag->softwares,
[
"type" => "software",
"title" => "<h2>" . __d("Tags", "SoftwareListTag") . $tag->name . " (" . count($tag->softwares) . ")" . "</h2>",
"titleAddMore" => "",
"titleSeeAll" => "",
"emptyMsg" => __d("Tags", "tags.view.error", $tag->name),
],
false
); ?>
</section>
......@@ -21,8 +21,8 @@ $this->assign('title', $tag->name);
"type" => "software",
"title" => "<h2>" . __d("Tags", "SoftwareListTag") . $tag->name . " (" . count($tag->softwares) . ")" . "</h2>",
"titleAddMore" => "",
"titleSeeAll" => "",
"emptyMsg" => __d("Tags", "tags.view.error", $tag->name),
],
false
......
......@@ -56,7 +56,7 @@ class TagHelper extends ListItemHelper
'href' => $this->Url->build([
'prefix'=>false,
'controller' => 'Tags',
'action' => 'view', $tag->id])]),
'action' => $tag->id, 'software'])]),
"tagName" => $tag->name,
"tagNumber" => (isset($options["displayNumber"]) && $options["displayNumber"] == true) ? ("x ") . $tag->usedTagNumber : null,
"attribsListItem" => $this->templater()->formatAttributes(['class' => isset($options["class"]) ? $options["class"] : ['class' => 'tagsContainer']]),
......
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