Skip to content

Commit

Permalink
Add hidden products
Browse files Browse the repository at this point in the history
  • Loading branch information
didrikmunther committed Aug 15, 2023
1 parent ed7acdf commit afda26f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion accounting/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Meta:
"unit_price",
"description",
"category",
"no_customer_removal",
"display_in_product_list",
"registration_section",
)
fields = read_only_fields + ("id",)
Expand Down
27 changes: 27 additions & 0 deletions accounting/migrations/0026_rename_hidden_products_field.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
16 changes: 9 additions & 7 deletions accounting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
]
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
}
Expand Down Expand Up @@ -65,7 +65,7 @@ export const productSlice = createSlice({
initialState,
reducers: {
loadProducts: (state, action: PayloadAction<Product[]>) => {
state.records = action.payload
state.records = action.payload.filter(product => product.display_in_product_list)
},
loadProductMeta: (
state,
Expand Down

0 comments on commit afda26f

Please sign in to comment.