diff options
| author | Paolo Melchiorre <paolo@melchiorre.org> | 2022-12-25 17:04:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-25 10:04:59 -0600 |
| commit | a59d6f55baca966cee3b6f31416fe8e6c42721ad (patch) | |
| tree | 5558c10922be8a921dbcb46e47b4dd374724df08 /fundraising | |
| parent | 5b58b15c2113a28c2edc452ad6d04c8915acf148 (diff) | |
Fixed #1293 -- Modernize to Django 3.2/Python 3.8 (#1294)
Diffstat (limited to 'fundraising')
| -rw-r--r-- | fundraising/forms.py | 2 | ||||
| -rw-r--r-- | fundraising/management/commands/create_stripe_plans.py | 6 | ||||
| -rw-r--r-- | fundraising/models.py | 6 | ||||
| -rw-r--r-- | fundraising/tests/test_models.py | 4 | ||||
| -rw-r--r-- | fundraising/tests/test_views.py | 4 |
5 files changed, 9 insertions, 13 deletions
diff --git a/fundraising/forms.py b/fundraising/forms.py index 622014ba..915f1059 100644 --- a/fundraising/forms.py +++ b/fundraising/forms.py @@ -106,7 +106,7 @@ class StripeTextInput(forms.TextInput): return kwargs def _strip_name_attr(self, widget_string, name): - return widget_string.replace('name="%s"' % (name,), "") + return widget_string.replace(f'name="{name}"', "") def render(self, name, *args, **kwargs): kwargs = self._add_data_stripe_attr(name, kwargs) diff --git a/fundraising/management/commands/create_stripe_plans.py b/fundraising/management/commands/create_stripe_plans.py index f1705946..7f17c06a 100644 --- a/fundraising/management/commands/create_stripe_plans.py +++ b/fundraising/management/commands/create_stripe_plans.py @@ -13,7 +13,7 @@ class Command(BaseCommand): print("Monthly plan exists, not creating!") except stripe.error.InvalidRequestError: name = "Monthly donation" - logger.info("Creating plan: {0}".format(name)) + logger.info(f"Creating plan: {name}") stripe.Plan.create( id="monthly", amount=100, @@ -27,7 +27,7 @@ class Command(BaseCommand): print("Quarterly plan exists, not creating!") except stripe.error.InvalidRequestError: name = "Quarterly donation" - logger.info("Creating plan: {0}".format(name)) + logger.info(f"Creating plan: {name}") stripe.Plan.create( id="quarterly", amount=100, @@ -42,7 +42,7 @@ class Command(BaseCommand): print("Yearly plan exists, not creating!") except stripe.error.InvalidRequestError: name = "Yearly donation" - logger.info("Creating plan: {0}".format(name)) + logger.info(f"Creating plan: {name}") stripe.Plan.create( id="yearly", amount=100, diff --git a/fundraising/models.py b/fundraising/models.py index 4dc7ca31..8c173fde 100644 --- a/fundraising/models.py +++ b/fundraising/models.py @@ -84,7 +84,7 @@ class DjangoHero(FundraisingModel): objects = DjangoHeroManager() def __str__(self): - return self.name if self.name else "Anonymous #{}".format(self.pk) + return self.name if self.name else f"Anonymous #{self.pk}" class Meta: verbose_name = "Django hero" @@ -114,7 +114,7 @@ class Donation(FundraisingModel): receipt_email = models.EmailField(blank=True) def __str__(self): - return "{} from {}".format(self.get_interval_display(), self.donor) + return f"{self.get_interval_display()} from {self.donor}" def get_absolute_url(self): return reverse("fundraising:thank-you", kwargs={"donation": self.id}) @@ -135,7 +135,7 @@ class Payment(models.Model): date = models.DateTimeField(auto_now_add=True) def __str__(self): - return "${}".format(self.amount) + return f"${self.amount}" class Testimonial(models.Model): diff --git a/fundraising/tests/test_models.py b/fundraising/tests/test_models.py index 8e3db76e..48a848ef 100644 --- a/fundraising/tests/test_models.py +++ b/fundraising/tests/test_models.py @@ -43,9 +43,7 @@ class TestDjangoHero(TestCase): os.remove(image_path) self.assertTrue( os.path.exists( - thumbnail.url.replace( - settings.MEDIA_URL, "{}/".format(settings.MEDIA_ROOT) - ) + thumbnail.url.replace(settings.MEDIA_URL, f"{settings.MEDIA_ROOT}/") ) ) diff --git a/fundraising/tests/test_views.py b/fundraising/tests/test_views.py index 9afa0258..f52f5b5f 100644 --- a/fundraising/tests/test_views.py +++ b/fundraising/tests/test_views.py @@ -173,9 +173,7 @@ class TestWebhooks(TestCase): ) def stripe_data(self, filename): - file_path = settings.BASE_DIR.joinpath( - "fundraising/test_data/{}.json".format(filename) - ) + file_path = settings.BASE_DIR.joinpath(f"fundraising/test_data/{filename}.json") with file_path.open() as f: data = json.load(f) return stripe.util.convert_to_stripe_object(data, stripe.api_key, None) |
