mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix error in user loading and validate scope/user consistency
This commit is contained in:
parent
7b7d30797f
commit
6e8f72f5cc
@ -295,18 +295,19 @@ class ActivityController extends Controller
|
||||
$this->get('translator')
|
||||
->trans('Success : activity updated!')
|
||||
);
|
||||
//die();
|
||||
|
||||
return $this->redirect($this->generateUrl('chill_activity_activity_show', array('id' => $id, 'person_id' => $person_id)));
|
||||
}
|
||||
|
||||
$this->get('session')
|
||||
->getFlashBag()
|
||||
->add('danger',
|
||||
->add('error',
|
||||
$this->get('translator')
|
||||
->trans('The form is not valid. The activity has not been updated !')
|
||||
->trans('This form contains errors')
|
||||
);
|
||||
|
||||
return $this->render('ChillActivityBundle:Activity:edit.html.twig', array(
|
||||
'person' => $entity->getPerson(),
|
||||
'entity' => $entity,
|
||||
'edit_form' => $editForm->createView(),
|
||||
'delete_form' => $deleteForm->createView(),
|
||||
|
@ -28,9 +28,15 @@ use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency;
|
||||
|
||||
/**
|
||||
* Activity
|
||||
* @UserCircleConsistency(
|
||||
* "CHILL_ACTIVITY_SEE_DETAILS",
|
||||
* getUserFunction="getUser",
|
||||
* path="scope"
|
||||
* )
|
||||
*/
|
||||
class Activity implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ namespace Chill\ActivityBundle\Form;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
@ -16,16 +15,15 @@ use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
|
||||
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
|
||||
use Chill\MainBundle\Form\Type\UserPickerType;
|
||||
use Chill\MainBundle\Form\Type\ScopePickerType;
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
|
||||
class ActivityType extends AbstractType
|
||||
{
|
||||
|
||||
use AppendScopeChoiceTypeTrait;
|
||||
|
||||
/**
|
||||
* the user running this form
|
||||
*
|
||||
@ -91,11 +89,9 @@ class ActivityType extends AbstractType
|
||||
);
|
||||
|
||||
$builder
|
||||
->add('date', DateType::class, array(
|
||||
'required' => true,
|
||||
'widget' => 'single_text',
|
||||
'format' => 'dd-MM-yyyy')
|
||||
)
|
||||
->add('date', ChillDateType::class, array(
|
||||
'required' => true
|
||||
))
|
||||
->add('durationTime', ChoiceType::class, $durationTimeOptions)
|
||||
->add('remark', TextareaType::class, array(
|
||||
'required' => false,
|
||||
@ -110,8 +106,14 @@ class ActivityType extends AbstractType
|
||||
'not present' => false
|
||||
)
|
||||
))
|
||||
->add('user')
|
||||
->add('scope')
|
||||
->add('user', UserPickerType::class, [
|
||||
'center' => $options['center'],
|
||||
'role' => $options['role']
|
||||
])
|
||||
->add('scope', ScopePickerType::class, [
|
||||
'center' => $options['center'],
|
||||
'role' => $options['role']
|
||||
])
|
||||
->add('reasons', TranslatableActivityReason::class, array(
|
||||
'multiple' => true,
|
||||
'required' => false
|
||||
@ -122,10 +124,6 @@ class ActivityType extends AbstractType
|
||||
))
|
||||
;
|
||||
|
||||
$this->appendScopeChoices($builder, $options['role'],
|
||||
$options['center'], $this->user, $this->authorizationHelper,
|
||||
$this->translatableStringHelper, $this->om);
|
||||
|
||||
$builder->get('durationTime')
|
||||
->addModelTransformer($durationTimeTransformer);
|
||||
|
||||
@ -181,7 +179,11 @@ class ActivityType extends AbstractType
|
||||
'data_class' => 'Chill\ActivityBundle\Entity\Activity'
|
||||
));
|
||||
|
||||
$this->appendScopeChoicesOptions($resolver);
|
||||
$resolver
|
||||
->setRequired(array('center', 'role'))
|
||||
->setAllowedTypes('center', 'Chill\MainBundle\Entity\Center')
|
||||
->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role')
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@ list_reasons: liste des sujets
|
||||
user_username: nom de l'utilisateur
|
||||
circle_name: nom du cercle
|
||||
Remark: Notes
|
||||
No remarks: Aucune note
|
||||
Add a new activity: Ajouter une nouvelle activité
|
||||
Activity list: Liste des activités
|
||||
present: présent
|
||||
|
@ -26,7 +26,7 @@
|
||||
<dt class="inline">{{ 'Type'|trans }}</dt>
|
||||
<dd>{{ entity.type.name | localize_translatable_string }}</dd>
|
||||
<dt class="inline">{{ 'Remark'|trans }}</dt>
|
||||
<dd>{% if entity.remark is empty %}{{ 'No remarks'|trans }}{% else %}<blockquote class="chill-user-quote">{{ entity.remark|nl2br }}</blockquote>{% endif %}</dd>
|
||||
<dd>{% if entity.remark is empty %}<span class="chill-no-data-statement">{{ 'No remarks'|trans }}</span>{% else %}<blockquote class="chill-user-quote">{{ entity.remark|nl2br }}</blockquote>{% endif %}</dd>
|
||||
|
||||
<dt class="inline">{{ 'Attendee'|trans }}</dt>
|
||||
<dd>{% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}</dd>
|
||||
|
Loading…
x
Reference in New Issue
Block a user