Commit 1c5c38b0 authored by Julien Fastré's avatar Julien Fastré
Browse files

Merge branch 'master' into 1.0

parents 092ec900 ef718fe9
Pipeline #279 passed with stage
......@@ -70,6 +70,21 @@ class ReportController extends Controller
*/
public function selectReportTypeAction($person_id, Request $request)
{
$em = $this->getDoctrine()->getManager();
$person = $em->getRepository('ChillPersonBundle:Person')
->find($person_id);
if ($person === NULL) {
throw $this->createNotFoundException('Person not found!');
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person, 'access denied for person view');
// check access on report creation for a dummy report
$this->denyAccessUnlessGranted('CHILL_REPORT_CREATE',
(new Report())->setPerson($person), 'access denied for report creation');
$cFGroupId = $request->query->get('cFGroup');
if($cFGroupId) {
......@@ -78,8 +93,6 @@ class ReportController extends Controller
array('person_id' => $person_id, 'cf_group_id' => $cFGroupId)));
}
$em = $this->getDoctrine()->getManager();
$cFGroups = $em->getRepository('ChillCustomFieldsBundle:CustomFieldsGroup')
->findByEntity('Chill\ReportBundle\Entity\Report');
......@@ -210,6 +223,9 @@ class ReportController extends Controller
}
$this->denyAccessUnlessGranted('CHILL_PERSON_SEE', $person);
// check access on report creation for a dummy report
$this->denyAccessUnlessGranted('CHILL_REPORT_CREATE',
(new Report())->setPerson($person), 'access denied for report creation');
if ($cFGroup === NULL){
throw $this->createNotFoundException("custom fields group not found");
......
......@@ -23,6 +23,11 @@
{% block personcontent %}
{{ form_start(edit_form) }}
{{ form_row(edit_form.user) }}
{{ form_row(edit_form.date) }}
{{ form_row(edit_form.scope) }}
{{ form_row(edit_form.cFData) }}
{{ form_widget(edit_form) }}
<div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Save report'|trans }}</button>
......
......@@ -26,7 +26,7 @@
<tr>
<th class="chill-red">{{ 'Date' | trans }}</th>
<th class="chill-green">{{ 'Report type' | trans }}</th>
<th class="chill-orange">{{ 'Report scope' | trans }}</th>
<th class="chill-orange">{{ 'Circle' | trans }}</th>
<th></th>
<th></th>
</tr>
......@@ -37,8 +37,20 @@
<td>{% if report.date %}{{ report.date|localizeddate('long', 'none') }}{% endif %}</td>
<td>{{ report.cFGroup.getName(app.request.locale) }}</td>
<td>{{ report.scope.name|localize_translatable_string }}</td>
<td><a href="{{ path('report_view', { 'person_id': report.person.id, 'report_id': report.id }) }}">{{ 'View the report' | trans }}</a></td>
<td><a href="{{ path('report_edit', { 'person_id': report.person.id, 'report_id': report.id }) }}">{{ 'Update the report' | trans }}</a></td>
<td>
<ul class="record_actions">
{% if is_granted('CHILL_REPORT_SEE', report) %}
<li>
<a href="{{ path('report_view', { 'person_id': report.person.id, 'report_id': report.id }) }}" class="sc-button black">{{ 'View the report' | trans | capitalize }}</a>
</li>
{% endif %}
{% if is_granted('CHILL_REPORT_UPDATE', report) %}
<li>
<a href="{{ path('report_edit', { 'person_id': report.person.id, 'report_id': report.id }) }}" class="sc-button bt-update">{{ 'Update' | trans }}</a>
</li>
{% endif %}
</ul>
</td>
</tr>
{% endfor %}
</tbody>
......
......@@ -23,7 +23,10 @@
{% block personcontent %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_row(form.user) }}
{{ form_row(form.date) }}
{{ form_row(form.scope) }}
{{ form_row(form.cFData) }}
<div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add report'|trans }}</button>
</div>
......
......@@ -22,26 +22,24 @@
{% block personcontent %}
<a href="{{ path('report_edit', { 'person_id': entity.person.id, 'report_id': entity.id }) }}"><i class="fa fa-pencil"></i> {{ 'Update the report'|trans }}</a>
<h2>{{ 'Details'|trans }}</h2>
<h2 class="chill-red">{{ 'Details'|trans }}</h2>
<dl>
<dt class="inline">{{ 'Person'|trans }}</dt>
<dt>{{ 'Person'|trans }}&nbsp;:</dt>
<dd>{{ entity.person }}</dd>
<dt class="inline">{{ 'Scope'|trans }}</dt>
<dd><span class="scope">{{ entity.scope.name|localize_translatable_string }}</span></dd>
<dt class="inline">{{ 'Date'|trans }}</dt>
<dt>{{ 'Circle'|trans }}&nbsp;:</dt>
<dd><span class="scope circle">{{ entity.scope.name|localize_translatable_string }}</span></dd>
<dt>{{ 'Date'|trans }}&nbsp;:</dt>
<dd>{{ entity.date|localizeddate('long', 'none') }}</dd>
<dt class="inline">{{ 'User'|trans }}</dt>
<dt>{{ 'User'|trans }}&nbsp;:</dt>
<dd>{{ entity.user }}</dd>
<dt class="inline">{{ 'Report type'|trans }}</dt>
<dt>{{ 'Report type'|trans }}&nbsp;:</dt>
<dd>{{ entity.cFGroup.getName(app.request.locale) }}</dd>
{{ chill_custom_fields_group_widget(entity.cFData, entity.cFGroup) }}
</dl>
<a href="{{ path('report_edit', { 'person_id': entity.person.id, 'report_id': entity.id }) }}"><i class="fa fa-pencil"></i> {{ 'Update the report' | trans }}</a>
{% if is_granted('CHILL_REPORT_UPDATE', entity) %}
<a class="sc-button bt-update" href="{{ path('report_edit', { 'person_id': entity.person.id, 'report_id': entity.id }) }}"><i class="fa fa-pencil"></i> {{ 'Update the report' | trans }}</a>
{% endif %}
{% endblock %}
......@@ -383,7 +383,7 @@ class ReportControllerTest extends WebTestCase
$this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/view$|',
static::$person->getId(), $reportId), $linkSee[0]->getUri());
$linkUpdate = $crawler->selectLink('Mettre à jour le rapport')->links();
$linkUpdate = $crawler->selectLink('Update')->links();
$this->assertGreaterThan(0, count($linkUpdate));
$this->assertRegExp(sprintf('|/fr/person/%s/report/[0-9]*/edit$|',
static::$person->getId(), $reportId), $linkUpdate[0]->getUri());
......
......@@ -61,7 +61,7 @@ security:
http_basic: ~
form_login:
csrf_parameter: _csrf_token
intention: authenticate
csrf_token_id: authenticate
csrf_provider: form.csrf_provider
logout: ~
......
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