Commit b01dc43e authored by nono's avatar nono 💻
Browse files

Merge branch 'preprod' into 'master'

Fusion de la branch préprod et master

See merge request !144
parents 20a9bc05 114b9aa2
......@@ -86,6 +86,12 @@ class Campaign extends Controller
$sum = $f3->get('amount_other');
}
// If the donation is not a positive amount, we fail the donation.
if ($f3->get('amount') < 1) {
$f3->set("error", _("Montant du don invalide, il doit être supérieur à 1€."));
$f3->error("403");
}
$f3->set('amount', $sum);
$status = 0;
......
......@@ -287,6 +287,22 @@ class Perso extends Controller
}
$f3->push('SESSION.message', _("Adresse ajoutée à votre profil"));
break;
case 'UPDATE':
$f3->get('container')['command_handler']->handle(
new AddressUpdateCommand(
\Utils::asl($f3->get('id')),
\Utils::asl($f3->get('SESSION.id')),
\Utils::asl($f3->get('nom')),
\Utils::asl($f3->get('adresse')),
\Utils::asl($f3->get('adresse2')),
\Utils::asl($f3->get('codepostal')),
\Utils::asl($f3->get('ville')),
\Utils::asl($f3->get('pays')),
\Utils::asl($f3->get('state'))
)
);
$f3->push('SESSION.message', _("Adresse du profil modifiée."));
break;
case 'DELETE':
try {
$f3->get('container')['command_handler']->handle(
......
<!DOCTYPE html>
<html>
<html lang="fr">
<include href="header.html" />
<body>
<include href="toolbar.html" />
......
......@@ -13,8 +13,8 @@
<input type="text" name="card" value="Carte de Crédit"><br>
<input type="text" name="crypto" value="123"><br>
<input type="text" name="expiry" value="1218"><br>
<input type="radio" name="monthly" value="1">Récurrent</br>
<input type="radio" name="monthly" value="0">Ponctuel</br>
<input type="radio" name="monthly" value="1">Récurrent </br>
<input type="radio" name="monthly" value="0">Ponctuel </br>
<input type="submit" value="Submit"><br>
</form>
......
......@@ -15,7 +15,7 @@
<form method="POST" class="form-inline" action="{{ 'login' | alias }}">
<fieldset>
<legend>
<h3 class="text-center">{{ _("Réinitialiser votre mot de passe.") }}</h4>
<h3 class="text-center">{{ _("Réinitialiser votre mot de passe.") }}</h3>
</legend>
<input type="hidden" name="csrf" id="csrf" value="{{ @CSRF }}">
<input type="hidden" name="action" id="action" value="renew_password">
......
......@@ -150,12 +150,12 @@
<input id="don-bitcoin" type="checkbox">
<div class="panel-heading">
<h4>
<label for="don-bitcoin">{{ _("Puis-je faire un don via BitCoin ou d'autres crypto-monnaies&nbsp;?") }}<span class="panel-caret pull-right"></span></label>
<label for="don-bitcoin">{{ _("Puis-je faire un don en Bitcoin&nbsp;?") }}<span class="panel-caret pull-right"></span></label>
</h4>
</div>
<div class="collapsed ">
<div class="panel-body white-pure">
<p>{{ _("Non&nbsp;, nous n'acceptons plus les bitcoins, car ils représentent une faible partie des dons, et qu'ils ont un impact écologique disproportioné. Mais nous continuons d’accepter l’argent physique, en chèque ou autre.") }}<ul><li>{{ _("S'il vous plaît, n'utilisez plus l'ancienne adresse bitcoin : ils partiront dans le vide.") }}</li></ul></p>
<p>{{ _("Nous n'acceptons plus les dons en Bitcoin&nbsp;: ils représentent une faible partie des dons et ont un impact écologique disproportioné. Nous continuons d’accepter les dons en espèce, en chèque ou autre.") }}<ul><li>{{ _("S'il vous plaît, n'utilisez plus l'ancienne adresse Bitcoin&nbsp;: vos dons partiront dans le vide.") }}</li></ul></p>
</div>
</div>
</div>
......
......@@ -44,7 +44,7 @@
<legend class="modal-form-only">{{ _("Récapitulatif de votre don") }}</legend>
<fieldset>
<div class="modal-row">
<div class="radio-row">
<div class="radio-row">
<input type="radio" name="amount" id="amount1" value="11">
<label for="amount1" class="text-center">11€ </label>
<input type="radio" name="amount" id="amount2" value="42">
......@@ -71,7 +71,7 @@
</div>
</div>
</fieldset>
<p class="unmodal">{{ _("Vous pouvez donner par <b>carte bancaire</b>, <b><a href=\"/faq#don-cheque\">chèque</a></b>, <b><a href=\"/faq#don-bitcoin\">crypto-monnaie</a></b> ou <b><a href=\"/faq#don-virement\">virement</a></b>.") }}</p>
<p class="unmodal">{{ _("Vous pouvez donner par <b>carte bancaire</b>, <b><a href=\"/faq#don-cheque\">chèque</a></b> ou <b><a href=\"/faq#don-virement\">virement</a></b>.") }}</p>
<a class="btn btn-modal btn-lg unmodal" href="#step1"><em>{{ _("Faire un don") }}</em></a>
<check if="{{ @@SESSION.user }}">
<false>
......
......@@ -16,7 +16,7 @@
<!-- Twitter cards -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@laquadrature" />
<meta name="twitter:title" content="{{ _("Soutenez la Quadrature du Net&nbsp!") }}">
<meta name="twitter:title" content="{{ _("Soutenez la Quadrature du Net &nbsp; !") }}">
<meta name="twitter:image" content="https://soutien.laquadrature.net/static/img/anim_3.gif">
<meta name="twitter:description" content="{{ _("Depuis sa création, La Quadrature du Net agit sans relâche pour qu'Internet demeure un outil de partage, de libre expression, d'émancipation et permette la participation de tous au débat démocratique.") }}">
......
......@@ -79,8 +79,15 @@
<h3>{{ _("Renseigner votre adresse.")}}</h3>
<form method="POST" action="{{ 'adresses' | alias }}" id="create-adress-form">
<input type="hidden" name="csrf" value="{{ @CSRF }}" />
<input type="hidden" name="action" value="ADD" />
<check if="{{ @adresse }}">
<true>
<input type="hidden" name="action" value="UPDATE" />
<input type="hidden" name="id" value="{{ @@adresse.id }}" />
</true>
<false>
<input type="hidden" name="action" value="ADD" />
</false>
</check>
<div class="form-group">
<label for="nom">{{ _("Destinataire") }}</label>
<input type="text" class="form-control" name="nom" value="{{ @@adresse.nom }}">
......
......@@ -113,7 +113,7 @@ msgid ""
"Site hébergé par <a href=\"https://laquadrature.net\">La Quadrature du Net</"
"a>"
msgstr ""
"Website hosted by <a href=\"https://laqaudrature.net\">La Quadrature du Net</"
"Website hosted by <a href=\"https://laquadrature.net\">La Quadrature du Net</"
"a>"
#: app/view/footer.html:7
......@@ -830,12 +830,8 @@ msgstr ""
"to protect our financial freedom. Our financial regulations document defines "
"how:<br />As for companies, the following rules applies:"
<<<<<<< Updated upstream
#: app/view/campaign/faq.html:234
#, c-format
=======
#: app/view/campaign/faq.html:235
>>>>>>> Stashed changes
msgid ""
"La part du budget annuel de LQdN apportée par des entreprises donnant "
"chacune 1 000 euros ou plus une année donnée ne peut dépasser 20% du budget "
......@@ -877,11 +873,7 @@ msgstr ""
msgid "Qui finance La Quadrature du Net&nbsp;?"
msgstr "Who's financing La Quadrature du Net?"
<<<<<<< Updated upstream
#: app/view/campaign/faq.html:252
=======
#: app/view/campaign/faq.html:253
>>>>>>> Stashed changes
msgid ""
"La Quadrature du Net est financée à 70 % par des dons individuels : vos "
"dons ! Nous acceptons aussi les dons d'entreprise, mais tous les dons "
......
<?php
namespace LQDN\Command;
class AddressUpdateCommand
{
private $addressId;
private $userId;
private $name;
private $address;
private $address2;
private $postalCode;
private $city;
private $country;
private $state;
public function __construct($addressId, $userId, $name, $address, $address2, $postalCode, $city, $country, $state)
{
$this->addressId = $addressId;
$this->userId = $userId;
$this->name = $name;
$this->address = $address;
$this->address2 = $address2;
$this->postalCode = $postalCode;
$this->city = $city;
$this->country = $country;
$this->state = $state;
}
public function getAddressId()
{
return $this->addressId;
}
public function getUserId()
{
return $this->userId;
}
public function getName()
{
return $this->name;
}
public function getAddress()
{
return $this->address;
}
public function getAddress2()
{
return $this->address2;
}
public function getPostalCode()
{
return $this->postalCode;
}
public function getCity()
{
return $this->city;
}
public function getCountry()
{
return $this->country;
}
public function getState()
{
return $this->state;
}
}
......@@ -63,24 +63,6 @@ EOF;
$stmt->execute();
}
/**
* Check if an address already exists.
*
* @param int $userId
*
* @return bool
*/
private function addressExists($userId)
{
return (bool) $this->connection->fetchColumn(
"SELECT 1 FROM adresses WHERE user_id = :user_id",
[
'user_id' => $userId,
],
0
);
}
/**
* Check if an adress is used.
*
......@@ -99,4 +81,33 @@ EOF;
);
return ($count > 0);
}
/**
* Update an address.
*
* @param AddressUpdateCommand $command
*/
public function handleAddressUpdateCommand(AddressUpdateCommand $command)
{
$addressId = $command->getAddressId();
$userId = $command->getUserId();
$query =<<<EOF
UPDATE adresses
SET nom = :name, adresse = :address, adresse2 = :address2, codepostal = :postal_code, ville = :city, etat = :state, pays = :country
WHERE id = :id and user_id = :user_id
EOF;
$stmt = $this->connection->prepare($query);
$stmt->bindValue('id', $command->getAddressId());
$stmt->bindValue('user_id', $command->getUserId());
$stmt->bindValue('name', $command->getName());
$stmt->bindValue('address', $command->getAddress());
$stmt->bindValue('address2', $command->getAddress2());
$stmt->bindValue('postal_code', $command->getPostalCode());
$stmt->bindValue('city', $command->getCity());
$stmt->bindValue('state', $command->getState());
$stmt->bindValue('country', $command->getCountry());
$stmt->execute();
}
}
......@@ -61,6 +61,30 @@ class AddressHandlerTest extends FunctionalTest
$this->assertSame($expectedAddress, $latestAddress);
}
public function testAddressUpdate()
{
$this->assertTrue($this->addressExists(1));
$latestAddress = $this->getLatestAddress();
$this->container['command_handler']->handle(new AddressUpdateCommand(1, 1, 'LQDN', '115 rue de Ménilmontant', '', 75020, 'Paris', 'France', 'IDF'));
$expectedAddress = [
'id' => '1',
'user_id' => '1',
'nom' => 'LQDN',
'adresse' => '115 rue de Ménilmontant',
'adresse2' => '',
'codepostal' => '75020',
'ville' => 'Paris',
'pays' => 'France',
'etat' => 'IDF',
];
$updatedAddress = $this->getAddressById(1);
$this->assertSame($expectedAddress, $updatedAddress);
}
/**
* Check if an address exists in DB.
*
......@@ -82,4 +106,16 @@ class AddressHandlerTest extends FunctionalTest
{
return $this->container['db']->fetchAssoc("SELECT * FROM adresses ORDER BY id DESC LIMIT 1");
}
/**
* Retrieve address by its ID.
*
* @param int $id
*
* @return []
*/
private function getAddressById($id)
{
return $this->container['db']->fetchAssoc("SELECT id,user_id,nom,adresse,adresse2,codepostal,ville,pays,etat FROM adresses WHERE id = $id LIMIT 1");
}
}
Supports Markdown
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