From e1eceb41c9cf0e6ba242d4653933e63bb1444bfc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com>
Date: Wed, 2 Sep 2020 17:50:46 +0200
Subject: [PATCH] donate: Set fixed amounts per project

---
 donate/migrations/0010_auto_20200902_1744.py  | 28 +++++++++++++++++++
 donate/models.py                              | 11 +++++++-
 donate/templates/donate/donate_home_page.html |  2 +-
 donate/templates/donate/donate_info_page.html |  2 +-
 .../templates/donate/donate_project_page.html | 14 +++++-----
 .../templates/donate/donate_region_page.html  |  2 +-
 .../donate_targeted_donations_page.html       |  2 +-
 7 files changed, 49 insertions(+), 12 deletions(-)
 create mode 100644 donate/migrations/0010_auto_20200902_1744.py

diff --git a/donate/migrations/0010_auto_20200902_1744.py b/donate/migrations/0010_auto_20200902_1744.py
new file mode 100644
index 00000000..2953e455
--- /dev/null
+++ b/donate/migrations/0010_auto_20200902_1744.py
@@ -0,0 +1,28 @@
+# Generated by Django 3.0.9 on 2020-09-02 15:44
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ("donate", "0009_donateprojectpage_allow_periodic_donations"),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name="donateprojectpage",
+            name="form_amount_1",
+            field=models.IntegerField(default=100, verbose_name="pevná částka 1"),
+        ),
+        migrations.AddField(
+            model_name="donateprojectpage",
+            name="form_amount_2",
+            field=models.IntegerField(default=200, verbose_name="pevná částka 2"),
+        ),
+        migrations.AddField(
+            model_name="donateprojectpage",
+            name="form_amount_3",
+            field=models.IntegerField(default=500, verbose_name="pevná částka 3"),
+        ),
+    ]
diff --git a/donate/models.py b/donate/models.py
index 056f6e09..66f75c10 100644
--- a/donate/models.py
+++ b/donate/models.py
@@ -369,6 +369,9 @@ class DonateProjectPage(DonateFormMixin, Page, SubpageMixin, MetadataPageMixin):
     )
     expected_amount = models.IntegerField("očekávaná částka", blank=True, null=True)
     donated_amount = models.IntegerField("vybraná částka", blank=True, null=True)
+    form_amount_1 = models.IntegerField("pevná částka 1", default=100)
+    form_amount_2 = models.IntegerField("pevná částka 2", default=200)
+    form_amount_3 = models.IntegerField("pevná částka 3", default=500)
     # we will use photo as search image
     search_image = None
 
@@ -406,7 +409,13 @@ class DonateProjectPage(DonateFormMixin, Page, SubpageMixin, MetadataPageMixin):
 
     settings_panels = Page.settings_panels + [
         MultiFieldPanel(
-            [FieldPanel("portal_project_id"), FieldPanel("allow_periodic_donations"),],
+            [
+                FieldPanel("portal_project_id"),
+                FieldPanel("allow_periodic_donations"),
+                FieldPanel("form_amount_1"),
+                FieldPanel("form_amount_2"),
+                FieldPanel("form_amount_3"),
+            ],
             "nastavení darů",
         ),
     ]
diff --git a/donate/templates/donate/donate_home_page.html b/donate/templates/donate/donate_home_page.html
index cdc64930..dc86beb2 100644
--- a/donate/templates/donate/donate_home_page.html
+++ b/donate/templates/donate/donate_home_page.html
@@ -77,7 +77,7 @@
             <div class="form-group row mb-4 align-items-center" id="js-custom-amount-input" style="display: none;">
               <div class="offset-md-4 col-md-8">
                 <div class="input-group input-group-lg mb-3 custom-amount">
-                  <input type="number" class="form-control" id="customamount" name="custom_amount" placeholder="1000" aria-describedby="customamount-currency">
+                  <input type="number" class="form-control" id="customamount" name="custom_amount" aria-describedby="customamount-currency">
                   <div class="input-group-append">
                     <span class="input-group-text" id="customamount-currency">Kč</span>
                   </div>
diff --git a/donate/templates/donate/donate_info_page.html b/donate/templates/donate/donate_info_page.html
index 40cbefa0..94dbcee9 100644
--- a/donate/templates/donate/donate_info_page.html
+++ b/donate/templates/donate/donate_info_page.html
@@ -58,7 +58,7 @@
                 <div class="form-group row mb-2 align-items-center" id="js-custom-amount-input" style="display: none;">
                     <div class="col-md-12">
                       <div class="input-group input-group-lg mb-3 custom-amount">
-                        <input type="number" class="form-control" id="customamount" name="custom_amount" placeholder="1000" aria-describedby="customamount-currency">
+                        <input type="number" class="form-control" id="customamount" name="custom_amount" aria-describedby="customamount-currency">
                         <div class="input-group-append">
                           <span class="input-group-text" id="customamount-currency">Kč</span>
                         </div>
diff --git a/donate/templates/donate/donate_project_page.html b/donate/templates/donate/donate_project_page.html
index f80bed62..6c0f9dce 100644
--- a/donate/templates/donate/donate_project_page.html
+++ b/donate/templates/donate/donate_project_page.html
@@ -81,16 +81,16 @@
                       <legend class="col-form-label col-md-12 col-form-label-lg">Částka</legend>
                       <div class="col-md-12">
                           <div class="custom-control custom-radio custom-control-inline">
-                            <input type="radio" id="amount1" name="amount" value="100" class="custom-control-input" checked>
-                            <label class="custom-control-label col-form-label-lg" for="amount1">100 Kč</label>
+                            <input type="radio" id="amount1" name="amount" value="{{ page.form_amount_1 }}" class="custom-control-input" checked>
+                            <label class="custom-control-label col-form-label-lg" for="amount1">{{ page.form_amount_1 }} Kč</label>
                           </div>
                           <div class="custom-control custom-radio custom-control-inline">
-                            <input type="radio" id="amount2" name="amount" value="200" class="custom-control-input">
-                            <label class="custom-control-label col-form-label-lg" for="amount2">200 Kč</label>
+                            <input type="radio" id="amount2" name="amount" value="{{ page.form_amount_2 }}" class="custom-control-input">
+                            <label class="custom-control-label col-form-label-lg" for="amount2">{{ page.form_amount_2 }} Kč</label>
                           </div>
                           <div class="custom-control custom-radio custom-control-inline">
-                            <input type="radio" id="amount3" name="amount" value="500" class="custom-control-input">
-                            <label class="custom-control-label col-form-label-lg" for="amount3">500 Kč</label>
+                            <input type="radio" id="amount3" name="amount" value="{{ page.form_amount_3 }}" class="custom-control-input">
+                            <label class="custom-control-label col-form-label-lg" for="amount3">{{ page.form_amount_3 }} Kč</label>
                           </div>
                           <div class="custom-control custom-radio custom-control-inline">
                             <input type="radio" id="amount4" name="amount" value="-1" class="custom-control-input">
@@ -101,7 +101,7 @@
                   <div class="form-group row mb-2 align-items-center" id="js-custom-amount-input" style="display: none;">
                       <div class="col-md-12">
                         <div class="input-group input-group-lg mb-3 custom-amount">
-                          <input type="number" class="form-control" id="customamount" name="custom_amount" placeholder="1000" aria-describedby="customamount-currency">
+                          <input type="number" class="form-control" id="customamount" name="custom_amount" aria-describedby="customamount-currency">
                           <div class="input-group-append">
                             <span class="input-group-text" id="customamount-currency">Kč</span>
                           </div>
diff --git a/donate/templates/donate/donate_region_page.html b/donate/templates/donate/donate_region_page.html
index f542f037..f202fc53 100644
--- a/donate/templates/donate/donate_region_page.html
+++ b/donate/templates/donate/donate_region_page.html
@@ -65,7 +65,7 @@
                 <div class="form-group row mb-2 align-items-center" id="js-custom-amount-input" style="display: none;">
                   <div class="col-md-12">
                     <div class="input-group input-group-lg mb-3 custom-amount">
-                      <input type="number" class="form-control" id="customamount" name="custom_amount" placeholder="1000" aria-describedby="customamount-currency">
+                      <input type="number" class="form-control" id="customamount" name="custom_amount" aria-describedby="customamount-currency">
                       <div class="input-group-append">
                         <span class="input-group-text" id="customamount-currency">Kč</span>
                       </div>
diff --git a/donate/templates/donate/donate_targeted_donations_page.html b/donate/templates/donate/donate_targeted_donations_page.html
index fa247405..5529abaa 100644
--- a/donate/templates/donate/donate_targeted_donations_page.html
+++ b/donate/templates/donate/donate_targeted_donations_page.html
@@ -56,7 +56,7 @@
             <div class="form-group row mb-4 align-items-center" id="js-custom-amount-input" style="display: none;">
               <div class="offset-md-3 col-md-9">
                 <div class="input-group input-group-lg mb-3 custom-amount">
-                  <input type="number" class="form-control" id="customamount" name="custom_amount" placeholder="1000" aria-describedby="customamount-currency">
+                  <input type="number" class="form-control" id="customamount" name="custom_amount" aria-describedby="customamount-currency">
                   <div class="input-group-append">
                     <span class="input-group-text" id="customamount-currency">Kč</span>
                   </div>
-- 
GitLab