Skip to content

Commit

Permalink
Add code to product type model
Browse files Browse the repository at this point in the history
  • Loading branch information
Floris272 committed Nov 8, 2024
1 parent e3a9eef commit 6ca0283
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.2.13 on 2024-11-08 14:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("producttypes", "0009_alter_producttype_open_forms_slug"),
]

operations = [
migrations.AddField(
model_name="producttype",
name="code",
field=models.CharField(
help_text="Unique product type code",
max_length=100,
unique=True,
verbose_name="Code",
),
preserve_default=False,
),
]
8 changes: 8 additions & 0 deletions src/open_producten/producttypes/models/producttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ class CategoryProductType(models.Model):


class ProductType(BasePublishableModel):

code = models.CharField(
verbose_name=_("Code"),
max_length=100,
unique=True,
help_text=_("Unique product type code"),
)

name = models.CharField(
verbose_name=_("Name"), max_length=100, help_text=_("Name of the product type")
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def setUp(self):

self.data = {
"name": "test-product-type",
"code": "TEST",
"summary": "test",
"content": "test test",
"uniform_product_name": upn.uri,
Expand Down
1 change: 1 addition & 0 deletions src/open_producten/producttypes/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Meta:

class ProductTypeFactory(factory.django.DjangoModelFactory):
name = factory.Sequence(lambda n: f"product type {n}")
code = factory.Sequence(lambda n: f"product type code {n}")
summary = factory.Faker("sentence")
content = factory.Faker("paragraph")
published = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def setUp(self):
upn = UniformProductNameFactory.create()
self.data = {
"name": "test",
"code": "TEST",
"uniform_product_name": upn,
"content": "content",
"summary": "summary",
Expand Down
85 changes: 57 additions & 28 deletions src/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2436,10 +2436,6 @@ components:
type: string
format: uuid
readOnly: true
organisation:
allOf:
- $ref: '#/components/schemas/Organisation'
readOnly: true
organisation_id:
type: string
format: uuid
Expand Down Expand Up @@ -2467,11 +2463,15 @@ components:
title: Rol
description: The role/function of the contact
maxLength: 100
organisation:
type: string
format: uuid
nullable: true
description: The organisation of the contact
required:
- first_name
- id
- last_name
- organisation
- organisation_id
Data:
type: object
Expand Down Expand Up @@ -2602,6 +2602,10 @@ components:
type: string
format: uuid
readOnly: true
coordinates:
type: array
items: { }
readOnly: true
name:
type: string
maxLength: 100
Expand Down Expand Up @@ -2631,6 +2635,7 @@ components:
maxLength: 250
required:
- city
- coordinates
- id
- postcode
Neighbourhood:
Expand Down Expand Up @@ -2670,6 +2675,10 @@ components:
type: string
format: uuid
writeOnly: true
coordinates:
type: array
items: { }
readOnly: true
name:
type: string
maxLength: 100
Expand Down Expand Up @@ -2704,6 +2713,7 @@ components:
description: Logo of the organisation
required:
- city
- coordinates
- id
- neighbourhood
- neighbourhood_id
Expand Down Expand Up @@ -3154,14 +3164,9 @@ components:
type: string
format: uuid
readOnly: true
organisation:
allOf:
- $ref: '#/components/schemas/Organisation'
readOnly: true
organisation_id:
type: string
format: uuid
writeOnly: true
first_name:
type: string
description: First name of the contact
Expand All @@ -3185,6 +3190,11 @@ components:
title: Rol
description: The role/function of the contact
maxLength: 100
organisation:
type: string
format: uuid
nullable: true
description: The organisation of the contact
PatchedField:
type: object
properties:
Expand Down Expand Up @@ -3258,6 +3268,10 @@ components:
type: string
format: uuid
readOnly: true
coordinates:
type: array
items: { }
readOnly: true
name:
type: string
maxLength: 100
Expand Down Expand Up @@ -3319,6 +3333,10 @@ components:
type: string
format: uuid
writeOnly: true
coordinates:
type: array
items: { }
readOnly: true
name:
type: string
maxLength: 100
Expand Down Expand Up @@ -3505,6 +3523,10 @@ components:
format: date-time
readOnly: true
description: The datetime at which the object was last changed.
code:
type: string
description: Unique product type code
maxLength: 100
name:
type: string
description: Name of the product type
Expand All @@ -3528,6 +3550,11 @@ components:
format: uri
description: Action link to request the product type.
maxLength: 200
open_forms_slug:
type: string
description: Open forms slug of the product type form.
maxLength: 100
pattern: ^[-a-zA-Z0-9_]+$
content:
type: string
description: Product type content with build-in WYSIWYG editor.
Expand Down Expand Up @@ -3856,6 +3883,10 @@ components:
format: date-time
readOnly: true
description: The datetime at which the object was last changed.
code:
type: string
description: Unique product type code
maxLength: 100
name:
type: string
description: Name of the product type
Expand All @@ -3879,6 +3910,11 @@ components:
format: uri
description: Action link to request the product type.
maxLength: 200
open_forms_slug:
type: string
description: Open forms slug of the product type form.
maxLength: 100
pattern: ^[-a-zA-Z0-9_]+$
content:
type: string
description: Product type content with build-in WYSIWYG editor.
Expand All @@ -3891,6 +3927,7 @@ components:
required:
- categories
- category_ids
- code
- conditions
- contacts
- content
Expand Down Expand Up @@ -4071,6 +4108,10 @@ components:
format: date-time
readOnly: true
description: The datetime at which the object was last changed.
code:
type: string
description: Unique product type code
maxLength: 100
name:
type: string
description: Name of the product type
Expand All @@ -4094,6 +4135,11 @@ components:
format: uri
description: Action link to request the product type.
maxLength: 200
open_forms_slug:
type: string
description: Open forms slug of the product type form.
maxLength: 100
pattern: ^[-a-zA-Z0-9_]+$
content:
type: string
description: Product type content with build-in WYSIWYG editor.
Expand All @@ -4103,25 +4149,8 @@ components:
type: string
maxLength: 100
description: List of keywords for search
organisations:
type: array
items:
type: string
format: uuid
description: Organisations which provides this product
contacts:
type: array
items:
type: string
format: uuid
description: The contacts responsible for the product
locations:
type: array
items:
type: string
format: uuid
description: Locations where the product is available at.
required:
- code
- content
- created_on
- id
Expand Down

0 comments on commit 6ca0283

Please sign in to comment.