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/0026_rename_hidden_products_field.py b/accounting/migrations/0026_rename_hidden_products_field.py new file mode 100644 index 000000000..ec6a00253 --- /dev/null +++ b/accounting/migrations/0026_rename_hidden_products_field.py @@ -0,0 +1,27 @@ +# 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..049543958 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,