From de78d242d8aebe30205d54b3546d72ca80d536df Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 28 Feb 2023 19:48:44 +0100 Subject: [PATCH] Rename current_product to subscription --- CHANGELOG.md | 6 ++++++ accounts/admin.py | 2 +- ...rename_current_product_user_subscription.py | 18 ++++++++++++++++++ accounts/models.py | 6 +++--- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 accounts/migrations/0008_rename_current_product_user_subscription.py diff --git a/CHANGELOG.md b/CHANGELOG.md index c960920..51cc09f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.10] - 2023-02-28 + +### Improved + +- Database relations [@AivGitHub](https://github.com/AivGitHub/). + ## [0.0.9] - 2023-02-28 ### Added diff --git a/accounts/admin.py b/accounts/admin.py index 7451918..4115ef8 100644 --- a/accounts/admin.py +++ b/accounts/admin.py @@ -103,7 +103,7 @@ class UserAdmin(admin.ModelAdmin): _('Products'), { 'fields': ( - 'current_product', + 'subscription', ) } ), diff --git a/accounts/migrations/0008_rename_current_product_user_subscription.py b/accounts/migrations/0008_rename_current_product_user_subscription.py new file mode 100644 index 0000000..cd485d0 --- /dev/null +++ b/accounts/migrations/0008_rename_current_product_user_subscription.py @@ -0,0 +1,18 @@ +# Generated by Django 4.1.3 on 2023-02-28 18:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0007_rename_product_subscription'), + ] + + operations = [ + migrations.RenameField( + model_name='user', + old_name='current_product', + new_name='subscription', + ), + ] diff --git a/accounts/models.py b/accounts/models.py index 0766b51..823e22f 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -89,7 +89,7 @@ class User(AbstractBaseUser, PermissionsMixin): null=True, blank=True ) - current_product = models.ForeignKey( + subscription = models.ForeignKey( 'accounts.Subscription', related_name='clients', null=True, @@ -539,7 +539,7 @@ class ProductBase(models.Model): ) def get_internal_info(self, user: User): - is_available = user.current_product != self + is_available = user.subscription != self if not is_available: return { @@ -600,6 +600,6 @@ def configure_user(self): if self.status != PaymentStatus.CONFIRMED: return - self.client.current_product = self.product + self.client.subscription = self.product self.client.save()