diff --git a/accounting/api.py b/accounting/api.py index 059acc0e1..24b214cd4 100644 --- a/accounting/api.py +++ b/accounting/api.py @@ -35,7 +35,7 @@ class Meta: "unit_price", "description", "category", - "no_customer_removal", + "display_in_product_list", "registration_section", ) fields = read_only_fields + ("id",) diff --git a/accounting/migrations/0025_add_child_product_descriptoin.py b/accounting/migrations/0025_add_child_product_descriptoin.py index ef34a71ba..2317e81e5 100644 --- a/accounting/migrations/0025_add_child_product_descriptoin.py +++ b/accounting/migrations/0025_add_child_product_descriptoin.py @@ -5,20 +5,21 @@ class Migration(migrations.Migration): - dependencies = [ - ('accounting', '0024_add_child_product_model'), + ("accounting", "0024_add_child_product_model"), ] operations = [ migrations.AddField( - model_name='childproduct', - name='description', + model_name="childproduct", + name="description", field=models.TextField(blank=True, null=True), ), migrations.AlterField( - model_name='product', - name='revenue', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounting.Revenue'), + model_name="product", + name="revenue", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="accounting.Revenue" + ), ), ] diff --git a/accounting/migrations/0026_rename_hidden_products_field.py b/accounting/migrations/0026_rename_hidden_products_field.py new file mode 100644 index 000000000..a1459e404 --- /dev/null +++ b/accounting/migrations/0026_rename_hidden_products_field.py @@ -0,0 +1,33 @@ +# Generated by Django 2.2.24 on 2023-08-15 12:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("accounting", "0025_add_child_product_descriptoin"), + ] + + operations = [ + migrations.RemoveField( + model_name="product", + name="no_customer_removal", + ), + migrations.AddField( + model_name="product", + name="display_in_product_list", + field=models.BooleanField( + default=True, + help_text="This product will not be shown to the customer unless a salesperson has added it, or it was ordered with a package Only a salesperson can add and remove it. Used among other things to be a child product to a package product.", + ), + ), + migrations.AlterField( + model_name="product", + name="child_products", + field=models.ManyToManyField( + blank=True, + help_text='This product will automatically add these products when added. Recommended (but not neccessary) is to toggle the "Display in product list" to false on the child products in order to make the package automatically add packages which can only be removed by a salesperson. This feature was used in 2023 when selling gold, silver, and bronze packages.', + to="accounting.ChildProduct", + ), + ), + ] diff --git a/accounting/models.py b/accounting/models.py index 5d2e81100..bf8a8eaae 100644 --- a/accounting/models.py +++ b/accounting/models.py @@ -78,20 +78,22 @@ class Product(models.Model): help_text=" ".join( [ "This product will automatically add these products when added.", - 'Recommended (but not neccessary) is to toggle the "No customer removal" on', - "the child products in order to make the package automatically add packages ", + 'Recommended (but not neccessary) is to toggle the "Display in product list" to false on', + "the child products in order to make the package automatically add packages", "which can only be removed by a salesperson.", "This feature was used in 2023 when selling gold, silver, and bronze packages.", ] ), ) - no_customer_removal = models.BooleanField( - default=False, + + display_in_product_list = models.BooleanField( + default=True, help_text=" ".join( [ - "This product will be unable to be removed by the customer." - "Only a salesperson can remove it.", - "Used in order to be a child product to a package product.", + "This product will not be shown to the customer unless a salesperson has added it,", + "or it was ordered with a package", + "Only a salesperson can add and remove it.", + "Used among other things to be a child product to a package product.", ] ), ) diff --git a/apps/complete_registration/src/store/products/products_slice.ts b/apps/complete_registration/src/store/products/products_slice.ts index 4dad17143..2aedbd8f5 100644 --- a/apps/complete_registration/src/store/products/products_slice.ts +++ b/apps/complete_registration/src/store/products/products_slice.ts @@ -25,7 +25,7 @@ export interface Product { unit_price: number description: string category: Category | null - no_customer_removal: boolean + display_in_product_list: boolean registration_section: RegistrationSection | null child_products: ChildProduct[] } @@ -65,7 +65,7 @@ export const productSlice = createSlice({ initialState, reducers: { loadProducts: (state, action: PayloadAction) => { - state.records = action.payload + state.records = action.payload.filter(product => product.display_in_product_list) }, loadProductMeta: ( state, diff --git a/register/api/registration/__init__.py b/register/api/registration/__init__.py index eb2c64a17..2b8c4c40f 100644 --- a/register/api/registration/__init__.py +++ b/register/api/registration/__init__.py @@ -29,6 +29,7 @@ def render_company(request, company, contact, exhibitor): else: return status.INVALID_REGISTRATION_PERIOD + # Todo: remove in prod @csrf_exempt def submit(request): @@ -50,6 +51,7 @@ def submit(request): return submit_cr(request, company, fair, contact, exhibitor) + # Todo: remove in prod @csrf_exempt def index(request): @@ -69,6 +71,7 @@ def index(request): return render_company(request, company, contact, exhibitor) + # Todo: remove in prod @csrf_exempt def get_company(request, company_pk):