Renaming genre into gender & dateOfBirth into birthdate

This commit is contained in:
Marc Ducobu 2015-08-11 17:47:11 +02:00
parent 02193505be
commit 31e734f2c7
24 changed files with 189 additions and 111 deletions

View File

@ -194,8 +194,8 @@ class PersonController extends Controller
$person->setFirstName($form['firstName']->getData()) $person->setFirstName($form['firstName']->getData())
->setLastName($form['lastName']->getData()) ->setLastName($form['lastName']->getData())
->setGenre($form['genre']->getData()) ->setGender($form['gender']->getData())
->setDateOfBirth($form['dateOfBirth']->getData()) ->setBirthdate($form['birthdate']->getData())
->setCenter($form['center']->getData()) ->setCenter($form['center']->getData())
; ;
@ -301,8 +301,8 @@ class PersonController extends Controller
array('alternatePersons' => $alternatePersons, array('alternatePersons' => $alternatePersons,
'firstName' => $form['firstName']->getData(), 'firstName' => $form['firstName']->getData(),
'lastName' => $form['lastName']->getData(), 'lastName' => $form['lastName']->getData(),
'dateOfBirth' => $form['dateOfBirth']->getData(), 'birthdate' => $form['birthdate']->getData(),
'genre' => $form['genre']->getData(), 'gender' => $form['gender']->getData(),
'creation_date' => $form['creation_date']->getData(), 'creation_date' => $form['creation_date']->getData(),
'form' => $form->createView())); 'form' => $form->createView()));
} }

View File

@ -95,7 +95,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
do { do {
$i++; $i++;
$sex = $this->genres[array_rand($this->genres)]; $sex = $this->genders[array_rand($this->genders)];
if ($chooseLastNameOrTri[array_rand($chooseLastNameOrTri)] === 'tri' ) { if ($chooseLastNameOrTri[array_rand($chooseLastNameOrTri)] === 'tri' ) {
$length = rand(2, 3); $length = rand(2, 3);
@ -108,7 +108,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
$lastName = $this->lastNames[array_rand($this->lastNames)]; $lastName = $this->lastNames[array_rand($this->lastNames)];
} }
if ($sex === Person::GENRE_MAN) { if ($sex === Person::MALE_GENDER) {
$firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)]; $firstName = $this->firstNamesMale[array_rand($this->firstNamesMale)];
} else { } else {
$firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)]; $firstName = $this->firstNamesFemale[array_rand($this->firstNamesFemale)];
@ -117,7 +117,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
$person = array( $person = array(
'FirstName' => $firstName, 'FirstName' => $firstName,
'LastName' => $lastName, 'LastName' => $lastName,
'Genre' => $sex, 'Gender' => $sex,
'Nationality' => (rand(0,100) > 50) ? NULL: 'BE', 'Nationality' => (rand(0,100) > 50) ? NULL: 'BE',
'center' => (rand(0,1) == 0) ? 'centerA': 'centerB' 'center' => (rand(0,1) == 0) ? 'centerA': 'centerB'
); );
@ -135,9 +135,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
private function fillWithDefault(array $specific) private function fillWithDefault(array $specific)
{ {
return array_merge(array( return array_merge(array(
'DateOfBirth' => "1960-10-12", 'Birthdate' => "1960-10-12",
'PlaceOfBirth' => "Ottignies Louvain-La-Neuve", 'PlaceOfBirth' => "Ottignies Louvain-La-Neuve",
'Genre' => Person::GENRE_MAN, 'Gender' => Person::MALE_GENDER,
'Email' => "Email d'un ami: roger@tt.com", 'Email' => "Email d'un ami: roger@tt.com",
'CountryOfBirth' => 'BE', 'CountryOfBirth' => 'BE',
'Nationality' => 'BE', 'Nationality' => 'BE',
@ -157,7 +157,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
case 'Nationality': case 'Nationality':
$value = $this->getCountry($value); $value = $this->getCountry($value);
break; break;
case 'DateOfBirth': case 'Birthdate':
$value = new \DateTime($value); $value = new \DateTime($value);
break; break;
case 'center': case 'center':
@ -196,7 +196,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su", 'ma', 'gone', 'car',"fu", "ka", "lot", "no", "va", "du", "bu", "su",
"lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu'); "lo", 'to', "cho", "car", 'mo','zu', 'qi', 'mu');
private $genres = array(Person::GENRE_MAN, Person::GENRE_WOMAN); private $genders = array(Person::MALE_GENDER, Person::FEMALE_GENDER);
private $years = array(); private $years = array();
@ -208,9 +208,9 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
array( array(
'FirstName' => "Depardieu", 'FirstName' => "Depardieu",
'LastName' => "Gérard", 'LastName' => "Gérard",
'DateOfBirth' => "1948-12-27", 'Birthdate' => "1948-12-27",
'PlaceOfBirth' => "Châteauroux", 'PlaceOfBirth' => "Châteauroux",
'Genre' => Person::GENRE_MAN, 'Gender' => Person::MALE_GENDER,
'CountryOfBirth' => 'FR', 'CountryOfBirth' => 'FR',
'Nationality' => 'RU', 'Nationality' => 'RU',
'center' => 'centerA' 'center' => 'centerA'
@ -219,7 +219,7 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
//to have a person with same firstname as Gérard Depardieu //to have a person with same firstname as Gérard Depardieu
'FirstName' => "Depardieu", 'FirstName' => "Depardieu",
'LastName' => "Jean", 'LastName' => "Jean",
'DateOfBirth' => "1960-10-12", 'Birthdate' => "1960-10-12",
'CountryOfBirth' => 'FR', 'CountryOfBirth' => 'FR',
'Nationality' => 'FR', 'Nationality' => 'FR',
'center' => 'centerA' 'center' => 'centerA'
@ -228,14 +228,14 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
//to have a person with same birthdate of Gérard Depardieu //to have a person with same birthdate of Gérard Depardieu
'FirstName' => 'Van Snick', 'FirstName' => 'Van Snick',
'LastName' => 'Bart', 'LastName' => 'Bart',
'DateOfBirth' => '1948-12-27', 'Birthdate' => '1948-12-27',
'center' => 'centerA' 'center' => 'centerA'
), ),
array( array(
//to have a woman with Depardieu as FirstName //to have a woman with Depardieu as FirstName
'FirstName' => 'Depardieu', 'FirstName' => 'Depardieu',
'LastName' => 'Charline', 'LastName' => 'Charline',
'Genre' => Person::GENRE_WOMAN, 'Gender' => Person::FEMALE_GENDER,
'center' => 'centerA' 'center' => 'centerA'
), ),
array( array(

View File

@ -41,7 +41,7 @@ class Person implements HasCenterInterface {
private $lastName; private $lastName;
/** @var \DateTime The person's birthdate */ /** @var \DateTime The person's birthdate */
private $dateOfBirth; //to change in birthdate private $birthdate; //to change in birthdate
/** @var string The person's place of birth */ /** @var string The person's place of birth */
private $placeOfBirth = ''; private $placeOfBirth = '';
@ -53,43 +53,51 @@ class Person implements HasCenterInterface {
private $nationality; private $nationality;
/** @var string The person's gender */ /** @var string The person's gender */
private $genre; //to change in gender private $gender;
const GENRE_MAN = 'man'; const MALE_GENDER = 'man';
const GENRE_WOMAN = 'woman'; const FEMALE_GENDER = 'woman';
/** @var \Chill\MainBundle\Entity\Center The person's center */
private $center;
/** @var string A remark over the person */ //TO-ADD : maritalStatus
private $memo = ''; // to change in remark
//TO-ADD : address
/** @var string The person's email */ /** @var string The person's email */
private $email = ''; private $email = '';
/**
* @var \Doctrine\Common\Collections\ArrayCollection The person's
* accompanying periods (when the person was accompanied by the center)*/
private $accompanyingPeriods;
/**
* @var boolean
*/
private $proxyAccompanyingPeriodOpenState = false;
/** @var array Array where customfield's data are stored */
private $cFData;
/** @var string The person's phonenumber */ /** @var string The person's phonenumber */
private $phonenumber = ''; private $phonenumber = '';
//TO-ADD : caseOpeningDate
//TO-ADD nativeLanguag
/** /**
* @var \Doctrine\Common\Collections\ArrayCollection The person's spoken * @var \Doctrine\Common\Collections\ArrayCollection The person's spoken
* languages (ArrayCollection of Languages) * languages (ArrayCollection of Languages)
*/ */
private $spokenLanguages; private $spokenLanguages;
/** @var \Chill\MainBundle\Entity\Center The person's center */
private $center;
/**
* @var \Doctrine\Common\Collections\ArrayCollection The person's
* accompanying periods (when the person was accompanied by the center)*/
private $accompanyingPeriods; //TO-CHANGE in accompanyingHistory
/** @var string A remark over the person */
private $memo = ''; // TO-CHANGE in remark
/**
* @var boolean
*/
private $proxyAccompanyingPeriodOpenState = false; //TO-DELETE ?
/** @var array Array where customfield's data are stored */
private $cFData;
public function __construct(\DateTime $opening = null) { public function __construct(\DateTime $opening = null) {
$this->accompanyingPeriods = new ArrayCollection(); $this->accompanyingPeriods = new ArrayCollection();
$this->spokenLanguages = new ArrayCollection(); $this->spokenLanguages = new ArrayCollection();
@ -272,26 +280,26 @@ class Person implements HasCenterInterface {
} }
/** /**
* Set dateOfBirth * Set birthdate
* *
* @param \DateTime $dateOfBirth * @param \DateTime $birthdate
* @return Person * @return Person
*/ */
public function setDateOfBirth($dateOfBirth) public function setBirthdate($birthdate)
{ {
$this->dateOfBirth = $dateOfBirth; $this->birthdate = $birthdate;
return $this; return $this;
} }
/** /**
* Get dateOfBirth * Get birthdate
* *
* @return \DateTime * @return \DateTime
*/ */
public function getDateOfBirth() public function getBirthdate()
{ {
return $this->dateOfBirth; return $this->birthdate;
} }
@ -323,26 +331,26 @@ class Person implements HasCenterInterface {
} }
/** /**
* Set genre * Set gender
* *
* @param string $genre * @param string $gender
* @return Person * @return Person
*/ */
public function setGenre($genre) public function setGender($gender)
{ {
$this->genre = $genre; $this->gender = $gender;
return $this; return $this;
} }
/** /**
* Get genre * Get gender
* *
* @return string * @return string
*/ */
public function getGenre() public function getGender()
{ {
return $this->genre; return $this->gender;
} }
/** /**
@ -350,8 +358,8 @@ class Person implements HasCenterInterface {
* This is used for translations * This is used for translations
* @return int * @return int
*/ */
public function getGenreNumeric() { public function getGenderNumeric() {
if ($this->getGenre() == self::GENRE_WOMAN) { if ($this->getGender() == self::FEMALE_GENDER) {
return 1; return 1;
} else { } else {
return 0; return 0;

View File

@ -58,10 +58,10 @@ class CreationPersonType extends AbstractType
$builder->add('firstName', 'hidden') $builder->add('firstName', 'hidden')
->add('lastName', 'hidden') ->add('lastName', 'hidden')
->add( $builder->create('dateOfBirth', 'hidden') ->add( $builder->create('birthdate', 'hidden')
->addModelTransformer($dateToStringTransformer) ->addModelTransformer($dateToStringTransformer)
) )
->add('genre', 'hidden') ->add('gender', 'hidden')
->add( $builder->create('creation_date', 'hidden') ->add( $builder->create('creation_date', 'hidden')
->addModelTransformer($dateToStringTransformer) ->addModelTransformer($dateToStringTransformer)
) )
@ -72,9 +72,9 @@ class CreationPersonType extends AbstractType
$builder $builder
->add('firstName') ->add('firstName')
->add('lastName') ->add('lastName')
->add('dateOfBirth', 'date', array('required' => false, ->add('birthdate', 'date', array('required' => false,
'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('genre', new GenderType(), array( ->add('gender', new GenderType(), array(
'required' => true, 'empty_value' => null 'required' => true, 'empty_value' => null
)) ))
->add('creation_date', 'date', array('required' => true, ->add('creation_date', 'date', array('required' => true,

View File

@ -39,9 +39,9 @@ class PersonType extends AbstractType
$builder $builder
->add('firstName') ->add('firstName')
->add('lastName') ->add('lastName')
->add('dateOfBirth', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy')) ->add('birthdate', 'date', array('required' => false, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('placeOfBirth', 'text', array('required' => false)) ->add('placeOfBirth', 'text', array('required' => false))
->add('genre', new GenderType(), array( ->add('gender', new GenderType(), array(
'required' => true 'required' => true
)) ))
->add('memo', 'textarea', array('required' => false)) ->add('memo', 'textarea', array('required' => false))

View File

@ -25,8 +25,8 @@ class GenderType extends AbstractType {
public function setDefaultOptions(OptionsResolverInterface $resolver) { public function setDefaultOptions(OptionsResolverInterface $resolver) {
$a = array( $a = array(
Person::GENRE_MAN => Person::GENRE_MAN, Person::MALE_GENDER => Person::MALE_GENDER,
Person::GENRE_WOMAN => Person::GENRE_WOMAN Person::FEMALE_GENDER => Person::FEMALE_GENDER
); );
$resolver->setDefaults(array( $resolver->setDefaults(array(

View File

@ -17,16 +17,15 @@ Chill\PersonBundle\Entity\Person:
lastName: lastName:
type: string type: string
length: 255 length: 255
dateOfBirth: birthdate:
type: date type: date
column: date_of_birth
nullable: true nullable: true
placeOfBirth: placeOfBirth:
type: string type: string
length: 255 length: 255
column: place_of_birth column: place_of_birth
default: '' default: ''
genre: gender:
type: string type: string
length: 9 length: 9
memo: memo:

View File

@ -18,11 +18,11 @@ Chill\PersonBundle\Entity\Person:
minMessage: 'This name is too short. It must containt {{ limit }} chars' minMessage: 'This name is too short. It must containt {{ limit }} chars'
maxMessage: 'This name is too long. It must containt {{ limit }} chars' maxMessage: 'This name is too long. It must containt {{ limit }} chars'
groups: [general, creation] groups: [general, creation]
dateOfBirth: birthdate:
- Date: - Date:
message: 'Birthdate not valid' message: 'Birthdate not valid'
groups: [general, creation] groups: [general, creation]
genre: gender:
- NotNull: - NotNull:
groups: [general, creation] groups: [general, creation]
accompanyingPeriods: accompanyingPeriods:

View File

@ -0,0 +1,66 @@
<?php
/*
* Chill is a software for social workers
*
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
* <http://www.champs-libres.coop>, <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Migration for adapting the Person Bundle to the 'cahier de charge' :
* - RENAMING :
* - - date_of_birth TO birthdate
* - - genre to gender
*
*/
class Version20150811152608 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE person RENAME COLUMN date_of_birth TO birthdate');
$this->addSql('ALTER TABLE person RENAME COLUMN genre TO gender');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->abortIf(
$this->connection->getDatabasePlatform()->getName() != 'postgresql',
'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE person RENAME COLUMN birthdate TO date_of_birth');
$this->addSql('ALTER TABLE person RENAME COLUMN gender TO genre');
}
}

View File

@ -29,9 +29,9 @@
{{ form_row(form.lastName, { 'label' : 'Last name'|trans }) }} {{ form_row(form.lastName, { 'label' : 'Last name'|trans }) }}
{{ form_row(form.dateOfBirth, { 'label' : 'Date of birth'|trans }) }} {{ form_row(form.birthdate, { 'label' : 'Date of birth'|trans }) }}
{{ form_row(form.genre, { 'label' : 'Gender'|trans }) }} {{ form_row(form.gender, { 'label' : 'Gender'|trans }) }}
{{ form_row(form.creation_date, { 'label' : 'Creation date'|trans }) }} {{ form_row(form.creation_date, { 'label' : 'Creation date'|trans }) }}

View File

@ -38,7 +38,7 @@
{% endspaceless %} {% endspaceless %}
</a> </a>
</td> </td>
<td>{{ person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }}</td> <td>{{ person.birthdate|localizeddate('long', 'none', app.request.locale) }}</td>
<td>{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %} <td>{% if person.nationality is not null %}{{ person.nationality.name|localize_translatable_string }}{% else %}{{ 'Without nationality'|trans }}{% endif %}
</tr> </tr>
@ -61,10 +61,10 @@
<dd>{{ lastName }}</dd> <dd>{{ lastName }}</dd>
<dt>{{ 'Date of birth'|trans }}</dt> <dt>{{ 'Date of birth'|trans }}</dt>
<dd>{{ dateOfBirth|localizeddate('long', 'none', app.request.locale)|default( 'Unknown date of birth'|trans ) }}</dd> <dd>{{ birthdate|localizeddate('long', 'none', app.request.locale)|default( 'Unknown date of birth'|trans ) }}</dd>
<dt>{{ 'Gender'|trans }}</dt> <dt>{{ 'Gender'|trans }}</dt>
<dd>{{ genre|trans }}</dd> <dd>{{ gender|trans }}</dd>
<dt>{{ 'Creation date'|trans }}</dt> <dt>{{ 'Creation date'|trans }}</dt>
<dd>{{ creation_date|localizeddate('long', 'none', app.request.locale) }}</dd> <dd>{{ creation_date|localizeddate('long', 'none', app.request.locale) }}</dd>

View File

@ -30,12 +30,12 @@
<legend><h2>{{ 'General information'|trans }}</h2></legend> <legend><h2>{{ 'General information'|trans }}</h2></legend>
{{ form_row(form.firstName, {'label' : 'First name'}) }} {{ form_row(form.firstName, {'label' : 'First name'}) }}
{{ form_row(form.lastName, {'label' : 'Last name'}) }} {{ form_row(form.lastName, {'label' : 'Last name'}) }}
{{ form_row(form.genre, {'label' : 'Gender'}) }} {{ form_row(form.gender, {'label' : 'Gender'}) }}
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend><h2>{{ 'Birth information'|trans }}</h2></legend> <legend><h2>{{ 'Birth information'|trans }}</h2></legend>
{{ form_row(form.dateOfBirth, {'label': 'Date of birth'} ) }} {{ form_row(form.birthdate, {'label': 'Date of birth'} ) }}
{{ form_row(form.placeOfBirth, { 'label' : 'Place of birth'} ) }} {{ form_row(form.placeOfBirth, { 'label' : 'Place of birth'} ) }}
{{ form_row(form.countryOfBirth, { 'label' : 'Country of birth' } ) }} {{ form_row(form.countryOfBirth, { 'label' : 'Country of birth' } ) }}
</fieldset> </fieldset>

View File

@ -19,8 +19,8 @@
#}{{ person.id }},{# #}{{ person.id }},{#
#}"{{ person.firstName|csv_cell }}",{# #}"{{ person.firstName|csv_cell }}",{#
#}"{{ person.lastName|csv_cell }}",{# #}"{{ person.lastName|csv_cell }}",{#
#}"{{ person.genre|csv_cell }}",{# #}"{{ person.gender|csv_cell }}",{#
#}"{{ person.dateOfBirth|localizeddate('short', 'none') }}",{# #}"{{ person.birthdate|localizeddate('short', 'none') }}",{#
#}"{# countryOfBirth #}"{# countryOfBirth
#}{% if person.countryOfBirth is not null %}{# #}{% if person.countryOfBirth is not null %}{#
#}{{ person.countryOfBirth.name|localize_translatable_string }}{# #}{{ person.countryOfBirth.name|localize_translatable_string }}{#

View File

@ -42,11 +42,11 @@
</a> </a>
</td> </td>
<td> <td>
<span class="personDateOfBirth">{% if person.dateOfBirth is not null %}{{person.dateOfBirth|localizeddate('long', 'none', app.request.locale) }}{% else %}{{ 'Unknown date of birth'|trans }}{% endif %}</span> {% if person.birthdate is not null %}{{person.birthdate|localizeddate('long', 'none', app.request.locale) }}{% else %}{{ 'Unknown date of birth'|trans }}{% endif %}
</td> </td>
<td> <td>
{% if person.nationality is not null %} {% if person.nationality is not null %}
<span class="personNationality">{{person.nationality.name | localize_translatable_string }}</span> {{person.nationality.name | localize_translatable_string }}
{% else %} {% else %}
{{ 'Without nationality'|trans }} {{ 'Without nationality'|trans }}
{% endif %} {% endif %}

View File

@ -50,7 +50,7 @@ This view should receive those arguments:
<dd>{{ person.lastName }}</dd> <dd>{{ person.lastName }}</dd>
<dt class="inline">{{ 'Gender'|trans }}</dt> <dt class="inline">{{ 'Gender'|trans }}</dt>
<dd>{{ ( person.genre|default('Not given'))|trans }}</dd> <dd>{{ ( person.gender|default('Not given'))|trans }}</dd>
</dl> </dl>
</figure> </figure>
@ -60,8 +60,8 @@ This view should receive those arguments:
<dl> <dl>
<dt class="inline">{{ 'Date of birth'|trans }}</dt> <dt class="inline">{{ 'Date of birth'|trans }}</dt>
<dd> <dd>
{%- if person.dateOfBirth is not null -%} {%- if person.birthdate is not null -%}
{{ person.dateOfBirth|localizeddate('long', 'none') }} {{ person.birthdate|localizeddate('long', 'none') }}
{%- else -%} {%- else -%}
{{ 'Unknown date of birth'|trans }} {{ 'Unknown date of birth'|trans }}
{%- endif -%} {%- endif -%}

View File

@ -36,11 +36,11 @@
<div class="grid-10 push-1 parent"> <div class="grid-10 push-1 parent">
<div class="grid-4"> <div class="grid-4">
{{ 'Birthdate :'|trans|upper }} {{ 'Birthdate :'|trans|upper }}
{% if person.dateOfBirth == null %} {% if person.birthdate == null %}
{{ 'Unknown date of birth'|trans }}, {{ ('person.gender.' ~ {{ 'Unknown date of birth'|trans }}, {{ ('person.gender.' ~
person.genre)|trans }} person.gender)|trans }}
{% else %} {% else %}
{{ person.dateOfBirth|localizeddate('long', 'none') }} {{ person.birthdate|localizeddate('long', 'none') }}
{% endif %} {% endif %}
</div> </div>
<div class="grid-4"> <div class="grid-4">
@ -53,7 +53,7 @@
</div> </div>
<div class="grid-4"> <div class="grid-4">
{{ 'Gender:'|trans|upper}} {{ 'Gender:'|trans|upper}}
{{ person.genre }} {{ person.gender }}
</div> </div>
<!-- <!--
<div class="grid-4"> <div class="grid-4">

View File

@ -172,18 +172,18 @@ class PersonSearch extends AbstractSearch implements ContainerAwareInterface
. 'not parsable', 0, $ex); . 'not parsable', 0, $ex);
} }
$qb->andWhere($qb->expr()->eq('p.dateOfBirth', ':birthdate')) $qb->andWhere($qb->expr()->eq('p.birthdate', ':birthdate'))
->setParameter('birthdate', $date); ->setParameter('birthdate', $date);
} }
if (array_key_exists('gender', $terms)) { if (array_key_exists('gender', $terms)) {
if (!in_array($terms['gender'], array(Person::GENRE_MAN, Person::GENRE_WOMAN))) { if (!in_array($terms['gender'], array(Person::MALE_GENDER, Person::FEMALE_GENDER))) {
throw new ParsingException('The gender ' throw new ParsingException('The gender '
.$terms['gender'].' is not accepted. Should be "'.Person::GENRE_MAN .$terms['gender'].' is not accepted. Should be "'.Person::MALE_GENDER
.'" or "'.Person::GENRE_WOMAN.'"'); .'" or "'.Person::FEMALE_GENDER.'"');
} }
$qb->andWhere($qb->expr()->eq('p.genre', ':gender')) $qb->andWhere($qb->expr()->eq('p.gender', ':gender'))
->setParameter('gender', $terms['gender']); ->setParameter('gender', $terms['gender']);
} }

View File

@ -36,7 +36,7 @@ trait PreparePersonTrait
* Properties added are : * Properties added are :
* - firstname * - firstname
* - lastname * - lastname
* - genre * - gender
* *
* This person should not be persisted in a database * This person should not be persisted in a database
* *
@ -49,7 +49,7 @@ trait PreparePersonTrait
->setCenter($center) ->setCenter($center)
->setFirstName('test firstname') ->setFirstName('test firstname')
->setLastName('default lastname') ->setLastName('default lastname')
->setGenre(Person::GENRE_MAN) ->setGender(Person::MALE_GENDER)
; ;
} }

View File

@ -22,6 +22,8 @@
namespace Chill\PersonBundle\Tests\Controller; namespace Chill\PersonBundle\Tests\Controller;
ini_set('memory_limit', '-1');
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
@ -84,7 +86,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase
->setFirstName('Roland') ->setFirstName('Roland')
->setLastName('Gallorime') ->setLastName('Gallorime')
->setCenter($center) ->setCenter($center)
->setGenre(Person::GENRE_MAN); ->setGender(Person::MALE_GENDER);
static::$em->persist($this->person); static::$em->persist($this->person);
static::$em->flush(); static::$em->flush();

View File

@ -33,8 +33,8 @@ class PersonControllerCreateTest extends WebTestCase
const FIRSTNAME_INPUT = 'chill_personbundle_person_creation[firstName]'; const FIRSTNAME_INPUT = 'chill_personbundle_person_creation[firstName]';
const LASTNAME_INPUT = "chill_personbundle_person_creation[lastName]"; const LASTNAME_INPUT = "chill_personbundle_person_creation[lastName]";
const GENRE_INPUT = "chill_personbundle_person_creation[genre]"; const GENDER_INPUT = "chill_personbundle_person_creation[gender]";
const DATEOFBIRTH_INPUT = "chill_personbundle_person_creation[dateOfBirth]"; const BIRTHDATE_INPUT = "chill_personbundle_person_creation[birthdate]";
const CREATEDATE_INPUT = "chill_personbundle_person_creation[creation_date]"; const CREATEDATE_INPUT = "chill_personbundle_person_creation[creation_date]";
const CENTER_INPUT = "chill_personbundle_person_creation[center]"; const CENTER_INPUT = "chill_personbundle_person_creation[center]";
@ -62,9 +62,9 @@ class PersonControllerCreateTest extends WebTestCase
{ {
$creationForm->get(self::FIRSTNAME_INPUT)->setValue($firstname); $creationForm->get(self::FIRSTNAME_INPUT)->setValue($firstname);
$creationForm->get(self::LASTNAME_INPUT)->setValue($lastname); $creationForm->get(self::LASTNAME_INPUT)->setValue($lastname);
$creationForm->get(self::GENRE_INPUT)->select("man"); $creationForm->get(self::GENDER_INPUT)->select("man");
$date = new \DateTime('1947-02-01'); $date = new \DateTime('1947-02-01');
$creationForm->get(self::DATEOFBIRTH_INPUT)->setValue($date->format('d-m-Y')); $creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('d-m-Y'));
return $creationForm; return $creationForm;
} }
@ -90,14 +90,14 @@ class PersonControllerCreateTest extends WebTestCase
'The page contains a "firstname" input'); 'The page contains a "firstname" input');
$this->assertTrue($form->has(self::LASTNAME_INPUT), $this->assertTrue($form->has(self::LASTNAME_INPUT),
'The page contains a "lastname" input'); 'The page contains a "lastname" input');
$this->assertTrue($form->has(self::GENRE_INPUT), $this->assertTrue($form->has(self::GENDER_INPUT),
'The page contains a "gender" input'); 'The page contains a "gender" input');
$this->assertTrue($form->has(self::DATEOFBIRTH_INPUT), $this->assertTrue($form->has(self::BIRTHDATE_INPUT),
'The page has a "date of birth" input'); 'The page has a "date of birth" input');
$this->assertTrue($form->has(self::CREATEDATE_INPUT), $this->assertTrue($form->has(self::CREATEDATE_INPUT),
'The page contains a "creation date" input'); 'The page contains a "creation date" input');
$genderType = $form->get(self::GENRE_INPUT); $genderType = $form->get(self::GENDER_INPUT);
$this->assertEquals('radio', $genderType->getType(), $this->assertEquals('radio', $genderType->getType(),
'The gender input has two radio button: man and women'); 'The gender input has two radio button: man and women');
$this->assertEquals(2, count($genderType->availableOptionValues()), $this->assertEquals(2, count($genderType->availableOptionValues()),
@ -154,7 +154,7 @@ class PersonControllerCreateTest extends WebTestCase
public function testGenderIsNull(Form $form) public function testGenderIsNull(Form $form)
{ {
$this->fillAValidCreationForm($form); $this->fillAValidCreationForm($form);
$form->get(self::GENRE_INPUT)->disableValidation()->setValue(NULL); $form->get(self::GENDER_INPUT)->disableValidation()->setValue(NULL);
$crawler = $this->getAuthenticatedClient()->submit($form); $crawler = $this->getAuthenticatedClient()->submit($form);
$this->assertEquals(1, $crawler->filter('.error')->count(), $this->assertEquals(1, $crawler->filter('.error')->count(),

View File

@ -67,7 +67,7 @@ class PersonControllerUpdateTest extends WebTestCase
->setLastName("My Beloved") ->setLastName("My Beloved")
->setFirstName("Jesus") ->setFirstName("Jesus")
->setCenter($center) ->setCenter($center)
->setGenre(Person::GENRE_MAN); ->setGender(Person::MALE_GENDER);
$this->em->persist($this->person); $this->em->persist($this->person);
$this->em->flush(); $this->em->flush();
@ -229,18 +229,18 @@ class PersonControllerUpdateTest extends WebTestCase
['firstName', 'random Value', function(Person $person) { return $person->getFirstName(); } ], ['firstName', 'random Value', function(Person $person) { return $person->getFirstName(); } ],
['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ], ['lastName' , 'random Value', function(Person $person) { return $person->getLastName(); } ],
['placeOfBirth', 'none place', function(Person $person) { return $person->getPlaceOfBirth(); }], ['placeOfBirth', 'none place', function(Person $person) { return $person->getPlaceOfBirth(); }],
['dateOfBirth', '15-12-1980', function(Person $person) { return $person->getDateOfBirth()->format('d-m-Y'); }], ['birthdate', '15-12-1980', function(Person $person) { return $person->getBirthdate()->format('d-m-Y'); }],
['phonenumber', '0123456789', function(Person $person) { return $person->getPhonenumber(); }], ['phonenumber', '0123456789', function(Person $person) { return $person->getPhonenumber(); }],
['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }], ['memo', 'jfkdlmq jkfldmsq jkmfdsq', function(Person $person) { return $person->getMemo(); }],
['countryOfBirth', 'BE', function(Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }], ['countryOfBirth', 'BE', function(Person $person) { return $person->getCountryOfBirth()->getCountryCode(); }],
['nationality', 'FR', function(Person $person) { return $person->getNationality()->getCountryCode(); }], ['nationality', 'FR', function(Person $person) { return $person->getNationality()->getCountryCode(); }],
['placeOfBirth', '', function(Person $person) { return $person->getPlaceOfBirth(); }], ['placeOfBirth', '', function(Person $person) { return $person->getPlaceOfBirth(); }],
['dateOfBirth', '', function(Person $person) { return $person->getDateOfBirth(); }], ['birthdate', '', function(Person $person) { return $person->getBirthdate(); }],
['phonenumber', '', function(Person $person) { return $person->getPhonenumber(); }], ['phonenumber', '', function(Person $person) { return $person->getPhonenumber(); }],
['memo', '', function(Person $person) { return $person->getMemo(); }], ['memo', '', function(Person $person) { return $person->getMemo(); }],
['countryOfBirth', NULL, function(Person $person) { return $person->getCountryOfBirth(); }], ['countryOfBirth', NULL, function(Person $person) { return $person->getCountryOfBirth(); }],
['nationality', NULL, function(Person $person) { return $person->getNationality(); }], ['nationality', NULL, function(Person $person) { return $person->getNationality(); }],
['genre', Person::GENRE_WOMAN, function(Person $person) { return $person->getGenre(); }] ['gender', Person::FEMALE_GENDER, function(Person $person) { return $person->getGender(); }]
); );
} }
@ -251,7 +251,7 @@ class PersonControllerUpdateTest extends WebTestCase
['lastName', $this->getVeryLongText()], ['lastName', $this->getVeryLongText()],
['firstName', ''], ['firstName', ''],
['lastName', ''], ['lastName', ''],
['dateOfBirth', 'false date'] ['birthdate', 'false date']
); );
} }

View File

@ -56,7 +56,7 @@ class PersonControllerViewTest extends WebTestCase
->setLastName("Tested Person") ->setLastName("Tested Person")
->setFirstName("Réginald") ->setFirstName("Réginald")
->setCenter($center) ->setCenter($center)
->setGenre(Person::GENRE_MAN); ->setGender(Person::MALE_GENDER);
$this->em->persist($this->person); $this->em->persist($this->person);
$this->em->flush(); $this->em->flush();

View File

@ -1,6 +1,9 @@
imports: imports:
- { resource: parameters.yml } - { resource: parameters.yml }
parameters:
locale: en
framework: framework:
secret: Not very secret secret: Not very secret
router: { resource: "%kernel.root_dir%/config/routing.yml" } router: { resource: "%kernel.root_dir%/config/routing.yml" }

View File

@ -138,7 +138,7 @@ class PersonSearchTest extends WebTestCase
"assert clause firstname and nationality are AND"); "assert clause firstname and nationality are AND");
} }
public function testSearchDateOfBirth() public function testSearchBirthdate()
{ {
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27');
@ -146,7 +146,7 @@ class PersonSearchTest extends WebTestCase
$this->assertRegExp('/Bart/', $crawler->text()); $this->assertRegExp('/Bart/', $crawler->text());
} }
public function testSearchCombineDateOfBirthAndFirstName() public function testSearchCombineBirthdateAndFirstName()
{ {
$crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 firstname:(Van Snick)'); $crawler = $this->generateCrawlerForSearch('@person birthdate:1948-12-27 firstname:(Van Snick)');
@ -154,7 +154,7 @@ class PersonSearchTest extends WebTestCase
$this->assertNotRegExp('/Depardieu/', $crawler->text()); $this->assertNotRegExp('/Depardieu/', $crawler->text());
} }
public function testSearchCombineGenreAndFirstName() public function testSearchCombineGenderAndFirstName()
{ {
$crawler = $this->generateCrawlerForSearch('@person gender:woman firstname:(Depardieu)'); $crawler = $this->generateCrawlerForSearch('@person gender:woman firstname:(Depardieu)');