Skip to content

Commit

Permalink
[LPN-1422] change columns configuration (#8185)
Browse files Browse the repository at this point in the history
  • Loading branch information
elvino29 authored Feb 15, 2023
1 parent 58178b8 commit c46d3e0
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 133 deletions.
150 changes: 70 additions & 80 deletions features/api/adherents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -307,27 +307,55 @@ Feature:
{
"key": "renaissance_membership",
"label": "Renaissance",
"type": "trans",
"messages": {
"adherent_re": "Adhérent",
"sympathizer_re": "Sympathisant"
},
"type": "trans"
"adherent_re": "Adhérent",
"sympathizer_re": "Sympathisant"
}
},
{
"key": "email_subscription",
"label": "Abonné email",
"type": "boolean"
},
{
"key": "email",
"label": "Email",
"dependency": {
"fields": [
{
"code": "email_subscription",
"valid_values": [
true
]
}
],
"mode": "color_invalid"
}
},
{
"key": "sms_subscription",
"label": "Abonné tel",
"type": "boolean"
},
{
"key": "phone_number",
"label": "Téléphone",
"type": "trans",
"messages": {
"not_applicable": "Non applicable",
"not_indicated": "Non renseigné",
"unsubscribed": "Non abonné"
"not_available": "Non disponible"
},
"type": "trans"
"dependency": {
"fields": [
{
"code": "sms_subscription",
"valid_values": [
true
]
}
],
"mode": "color_invalid"
}
},
{
"key": "postal_code",
Expand All @@ -341,22 +369,6 @@ Feature:
"key": "city",
"label": "Commune"
},
{
"key": "department_code",
"label": "Code département"
},
{
"key": "department",
"label": "Département"
},
{
"key": "region_code",
"label": "Code région"
},
{
"key": "region",
"label": "Région"
},
{
"key": "interests",
"label": "Intérêts",
Expand Down Expand Up @@ -420,11 +432,9 @@ Feature:
"gender": "male",
"interests": [],
"city_code": "77288",
"department_code": "77",
"department": "Seine-et-Marne",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "unsubscribed",
"phone_number": "not_available",
"sms_subscription": false,
"email": "[email protected]",
"email_subscription": false,
"renaissance_membership": null
},
Expand All @@ -437,29 +447,25 @@ Feature:
"gender": "female",
"interests": [],
"city_code": "92024",
"department_code": "92",
"department": "Hauts-de-Seine",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "not_applicable",
"phone_number": "+33 6 66 66 66 66",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": true,
"renaissance_membership": null
},
{
"city": "Melun",
"city_code": null,
"country": "FR",
"department": "Hauts-de-Seine",
"department_code": "92",
"email": "[email protected]",
"email_subscription": false,
"first_name": "Jules",
"gender": "male",
"interests": [],
"last_name": "Fullstack",
"postal_code": "77000",
"region": "Île-de-France",
"region_code": "11",
"phone_number": "unsubscribed",
"phone_number": "not_available",
"sms_subscription": false,
"renaissance_membership": null
},
{
Expand All @@ -473,12 +479,10 @@ Feature:
"numerique"
],
"city_code": null,
"department_code": null,
"department": null,
"region_code": null,
"region": null,
"phone_number": "not_applicable",
"phone_number": "+33 6 66 66 66 66",
"email": "[email protected]",
"email_subscription": true,
"sms_subscription": true,
"renaissance_membership": null
},
{
Expand All @@ -494,11 +498,9 @@ Feature:
"sante"
],
"city_code": null,
"department_code": null,
"department": null,
"region_code": null,
"region": null,
"phone_number": "not_applicable",
"phone_number": "+33 6 66 66 66 66",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": false,
"renaissance_membership": null
}
Expand Down Expand Up @@ -527,11 +529,9 @@ Feature:
"gender": "male",
"interests": [],
"city_code": "77288",
"department_code": "77",
"department": "Seine-et-Marne",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "unsubscribed",
"phone_number": "not_available",
"sms_subscription": false,
"email": "[email protected]",
"email_subscription": false,
"renaissance_membership": null
}
Expand Down Expand Up @@ -567,11 +567,9 @@ Feature:
"gender": "male",
"interests": [],
"city_code": null,
"department_code": "92",
"department": "Hauts-de-Seine",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "unsubscribed",
"phone_number": "not_available",
"sms_subscription": false,
"email": "[email protected]",
"email_subscription": false,
"renaissance_membership": null
},
Expand All @@ -584,11 +582,9 @@ Feature:
"gender": "female",
"interests": [],
"city_code": "92024",
"department_code": "92",
"department": "Hauts-de-Seine",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "not_applicable",
"phone_number": "+33 6 66 66 66 66",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": true,
"renaissance_membership": null
}
Expand Down Expand Up @@ -756,11 +752,9 @@ Feature:
"numerique"
],
"city_code": "75056",
"department_code": "75",
"department": "Paris",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "not_applicable",
"phone_number": "not_available",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": true,
"renaissance_membership": null
},
Expand All @@ -777,11 +771,9 @@ Feature:
"sante"
],
"city_code": "75056",
"department_code": "75",
"department": "Paris",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "not_applicable",
"phone_number": "+33 1 87 26 42 36",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": true,
"renaissance_membership": null
}
Expand Down Expand Up @@ -814,11 +806,9 @@ Feature:
"sante"
],
"city_code": "75056",
"department_code": "75",
"department": "Paris",
"region_code": "11",
"region": "Île-de-France",
"phone_number": "not_applicable",
"phone_number": "+33 1 87 26 42 36",
"sms_subscription": true,
"email": "[email protected]",
"email_subscription": true,
"renaissance_membership": null
}
Expand Down
36 changes: 12 additions & 24 deletions src/Entity/Projection/ManagedUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ class ManagedUser
private const STYLE_TYPE_ADHERENT = 'adherent';
private const STYLE_TYPE_HOST = 'host';

public const NOT_APPLICABLE = 'not_applicable';
public const UNSUBSCRIBED = 'unsubscribed';
public const NOT_INDICATED = 'not_indicated';
public const NOT_AVAILABLE = 'not_available';

/**
* @var int
Expand Down Expand Up @@ -101,6 +99,8 @@ class ManagedUser
* @var string
*
* @ORM\Column
*
* @Groups({"managed_user_read"})
*/
private $email;

Expand Down Expand Up @@ -579,39 +579,27 @@ public function getCityCode(): ?string
return $zones ? current($zones)->getCode() : null;
}

/**
* @Groups({"managed_user_read"})
*/
public function getDepartmentCode(): ?string
{
$zones = $this->getZonesOfType(Zone::DEPARTMENT, true);

return $zones ? current($zones)->getCode() : null;
}

/**
* @Groups({"managed_user_read"})
*/
public function getDepartment(): ?string
{
$zones = $this->getZonesOfType(Zone::DEPARTMENT, true);

return $zones ? current($zones)->getName() : null;
}

/**
* @Groups({"managed_user_read"})
*/
public function getRegionCode(): ?string
{
$zones = $this->getZonesOfType(Zone::REGION, true);

return $zones ? current($zones)->getCode() : null;
}

/**
* @Groups({"managed_user_read"})
*/
public function getRegion(): ?string
{
$zones = $this->getZonesOfType(Zone::REGION, true);
Expand All @@ -622,16 +610,16 @@ public function getRegion(): ?string
/**
* @Groups({"managed_user_read"})
*/
public function getPhoneNumber(): ?string
public function getSmsSubscription(): bool
{
if (\in_array(SubscriptionTypeEnum::MILITANT_ACTION_SMS, $this->subscriptionTypes, true)) {
if (MembershipSourceEnum::RENAISSANCE === $this->source) {
return $this->getPhone() ? PhoneNumberUtils::format($this->getPhone()) : self::NOT_INDICATED;
}

return self::NOT_APPLICABLE;
}
return \in_array(SubscriptionTypeEnum::MILITANT_ACTION_SMS, $this->subscriptionTypes, true);
}

return self::UNSUBSCRIBED;
/**
* @Groups({"managed_user_read"})
*/
public function getPhoneNumber(): ?string
{
return $this->getPhone() ? PhoneNumberUtils::format($this->getPhone()) : self::NOT_AVAILABLE;
}
}
Loading

0 comments on commit c46d3e0

Please sign in to comment.