Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split procuration manager in five tabs. #876

Merged
merged 1 commit into from
Apr 18, 2017

Conversation

hhamon
Copy link
Contributor

@hhamon hhamon commented Apr 11, 2017

No description provided.

@hhamon hhamon self-assigned this Apr 11, 2017
@hhamon hhamon force-pushed the feat-procuration-manager-split branch 7 times, most recently from 2890c88 to 33670e7 Compare April 11, 2017 15:37
@tgalopin
Copy link
Contributor

This probably need more work as we introduced filters in #881

@hhamon
Copy link
Contributor Author

hhamon commented Apr 12, 2017

I'll finish this PR tomorrow morning ;)

$requestsRepository = $this->getDoctrine()->getRepository(ProcurationRequest::class);
$requests = $requestsRepository->findManagedBy($this->getUser(), (int) $page, self::PER_PAGE);
try {
$requests = $this->get('app.procuration.manager')->getProcurationRequests(strtolower($request->query->get('type', 'unprocessed')), self::PER_PAGE, (int) $page);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The int casting should be a parameter type hint in the signature (it will also cast).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes right!

@@ -157,29 +161,25 @@ public function requestAction(ProcurationRequest $request): Response
* )
* @Method("GET")
*/
public function requestTransformAction(ProcurationRequest $request, $action, $token): Response
public function requestTransformAction($id, $action, $token): Response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add parameters type hint.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

{
if (!$this->get('security.csrf.token_manager')->isTokenValid(new CsrfToken('request_action', $token))) {
if (!$this->isCsrfTokenValid('request_action', $token)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request_action should better be a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's only used here as far as I know

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And twig


private static function ensureProcessingType(string $type): void
{
if (!in_array($type, ['processed', 'unprocessed'])) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use constants for types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep I thought about that.

@hhamon hhamon force-pushed the feat-procuration-manager-split branch 15 times, most recently from e1a45e9 to 98555e7 Compare April 14, 2017 14:02
@hhamon hhamon dismissed HeahDude’s stale review April 14, 2017 14:05

All problems have been fixed

@hhamon hhamon requested review from mykiwi, rpg600 and tgalopin April 14, 2017 14:06
@hhamon hhamon force-pushed the feat-procuration-manager-split branch 2 times, most recently from 94fb261 to 338ef45 Compare April 14, 2017 14:35
--
<a href="{{ path('app_procuration_manager_index', {'status': 'processed'}) }}">Mandants traités</a>
--
<a href="{{ path('app_procuration_manager_proposals') }}">Mandataires traités</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same path for the processed and unprocessed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oups I forgot to implement the status filtering for proxy proposals.

return;
}

if (!in_array($country, array_keys($this->getCountries()))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing third parameter ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes good catch.

parent::apply($qb, $alias);

$qb
->addOrderBy('pp.createdAt', 'DESC')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can use $alias (if it contains 'pp') ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to! Thanks!

'total_count' => $manager->countProcurationProxyProposals($this->getUser(), $filters),
'filters' => $filters,
]);
} catch (ProcurationException $e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole try block is necessary ? (I know it's changes nothing)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes to convert ProcurationException  exceptions into BadRequestHttpException exceptions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant ProcurationException is only throw from the method fromQueryString right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes right.


private $status = self::UNPROCESSED;

public static function fromQueryString(Request $request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing return type hint

Copy link
Contributor Author

@hhamon hhamon Apr 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impossible here. Because of the new static() in the parent class. We can't typehint against static.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@hhamon hhamon force-pushed the feat-procuration-manager-split branch from 338ef45 to 9a3f8d1 Compare April 14, 2017 15:38
@hhamon hhamon changed the title Split procuration manager in 4 tabs. Split procuration manager in five tabs. Apr 14, 2017
@hhamon hhamon force-pushed the feat-procuration-manager-split branch 2 times, most recently from 8d25293 to ec7a9d3 Compare April 14, 2017 15:56
{% endif %}
{% if 0 == proxies|length %}
<div class="text--body text--center">
{% if constant('AppBundle\\Procuration\\Filter\\ProcurationProxyProposalFilters::UNASSOCIATED') == filters.status %}
Copy link
Contributor

@mykiwi mykiwi Apr 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the variable filters is an instance of ProcurationProxyProposalFilters you can use it to do constant('UNASSOCIATED', filters)

And all constant in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes excellent thanks.


{% if 0 == requests|length %}
<div class="text--body text--center">
{% if constant('AppBundle\\Procuration\\Filter\\ProcurationRequestFilters::PROCESSED') == filters.status %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use filters here too I guess.

}

$qb
->setFirstResult(($this->currentPage - 1) * $this->getLimit())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO the method getLimit is useless. You should use the constant directly here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True!

@hhamon hhamon force-pushed the feat-procuration-manager-split branch from ec7a9d3 to e54f13e Compare April 15, 2017 17:51
@hhamon
Copy link
Contributor Author

hhamon commented Apr 15, 2017

@mykiwi all requested changes have been applied ;)

@hhamon hhamon force-pushed the feat-procuration-manager-split branch from e54f13e to 1ca33e3 Compare April 18, 2017 07:27
@hhamon hhamon force-pushed the feat-procuration-manager-split branch from 1ca33e3 to af4909a Compare April 18, 2017 08:01
@hhamon hhamon merged commit 75d1dab into master Apr 18, 2017
@hhamon hhamon deleted the feat-procuration-manager-split branch April 18, 2017 09:36
throw new ProcurationException(sprintf('Invalid country filter value given ("%s").', $country));
}

$this->country = trim($country);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a second trim?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be truly sure it's trimmed ^^
It must be removed for sure.

{
parent::apply($qb, $alias);

$status = $this->getStatus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use a switch to evaluate only once without storing it in a variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate switch() statements, they make the code less readable IMO.

{
parent::apply($qb, $alias);

if (self::UNPROCESSED === $this->getStatus()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, it would be more readable with both cases explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants