Skip to content

Feature/vue3 #3123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e99ff00
added test to check for API pagination
smilerz Mar 28, 2024
f560365
stub out schema completeness tests
smilerz Apr 5, 2024
f401b0f
add test to validate all list endpoints are paginated
smilerz Apr 18, 2024
f312f60
ensure that all schema fields are typed correctly
smilerz Apr 18, 2024
fd8411b
regenerate fetch API
smilerz Apr 18, 2024
5f0eb73
regenerate vue typescript API
smilerz Apr 18, 2024
8412aa1
paginate all list endpoints or explicitly mark as pagination_disabled
smilerz Apr 18, 2024
4edd729
add schema parameters for all list endpoinst with filters
smilerz Apr 18, 2024
f06b3e8
add enum to filters that have Choice fields
smilerz Apr 18, 2024
1e326fe
remove apis no longer in use
smilerz Apr 18, 2024
71765f3
change function based views to @api_view
smilerz Apr 18, 2024
d3abe4d
updated tests to reflect API changes in pagination
smilerz Apr 19, 2024
8cd79cd
update SpaceFilterSerializer to reflect paginated ViewSets provide
smilerz Apr 19, 2024
fd0d581
update SpaceFilterSerializer to handle both lists and QuerySets
smilerz Apr 19, 2024
2847721
update tests to reflect pagination and API changes
smilerz Apr 23, 2024
3184deb
change reset_food_inheritance from GET to POST
smilerz Apr 23, 2024
dd3f38f
Merge remote-tracking branch 'upstream/feature/vue3' into feature/vue3
smilerz Apr 23, 2024
a67b084
regenerate API
smilerz Apr 23, 2024
e4ff6ed
adding TZ to default .env.template
smilerz Apr 24, 2024
b83f3a2
update documentation
smilerz Apr 24, 2024
ebcc814
remove deprecated api endpoints
smilerz Apr 24, 2024
a047d36
update tests to reflect API changes
smilerz Apr 24, 2024
f0088b2
delete openapi generated files from root of vue3
smilerz Apr 24, 2024
931865b
restore original openapi update.bat
smilerz Apr 24, 2024
9e49652
deleted openapi models at root of project
smilerz Apr 25, 2024
4fa7155
delete extraneous openapi files
smilerz Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# random secret key, use for example `base64 /dev/urandom | head -c50` to generate one
SECRET_KEY=

# your default timezone See https://timezonedb.com/time-zones for a list of timezones
TZ=Europe/Berlin

# add only a database password if you want to run with the default postgres, otherwise change settings accordingly
DB_ENGINE=django.db.backends.postgresql
POSTGRES_HOST=db_recipes
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ vue/webpack-stats.json
/docker-compose.override.yml
vue/node_modules
/recipes/plugins
.vscode/
vetur.config.js
cookbook/static/vue
vue/webpack-stats.json
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"console": "integratedTerminal",
"env": {
// coverage and pytest can't both be running at the same time
"PYTEST_ADDOPTS": "--no-cov"
"PYTEST_ADDOPTS": "--no-cov -n 0"
},
"django": true,
"justMyCode": true
Expand Down
200 changes: 128 additions & 72 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,75 +1,131 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Run Migrations",
"type": "shell",
"command": "python3 manage.py migrate",
},
{
"label": "Collect Static Files",
"type": "shell",
"command": "python3 manage.py collectstatic",
"dependsOn": ["Yarn Build"],
},
{
"label": "Setup Dev Server",
"dependsOn": ["Run Migrations", "Yarn Build"],
},
{
"label": "Run Dev Server",
"type": "shell",
"dependsOn": ["Setup Dev Server"],
"command": "python3 manage.py runserver",
},
{
"label": "Yarn Install",
"type": "shell",
"command": "yarn install",
"options": {
"cwd": "${workspaceFolder}/vue"
}
},
{
"label": "Yarn Serve",
"type": "shell",
"command": "yarn serve",
"dependsOn": ["Yarn Install"],
"options": {
"cwd": "${workspaceFolder}/vue"
}
},
{
"label": "Yarn Build",
"type": "shell",
"command": "yarn build",
"dependsOn": ["Yarn Install"],
"options": {
"cwd": "${workspaceFolder}/vue"
},
"group": "build",
},
{
"label": "Setup Tests",
"dependsOn": ["Run Migrations", "Collect Static Files"],
},
{
"label": "Run all pytests",
"type": "shell",
"command": "python3 -m pytest cookbook/tests",
"dependsOn": ["Setup Tests"],
"group": "test",
"version": "2.0.0",
"tasks": [
{
"label": "Run Migrations",
"type": "shell",
"command": "python3 manage.py migrate"
},
{
"label": "Collect Static Files",
"type": "shell",
"command": "python3 manage.py collectstatic",
"dependsOn": ["Yarn Build"]
},
{
"label": "Setup Dev Server",
"dependsOn": ["Run Migrations", "Yarn Build"]
},
{
"label": "Run Dev Server",
"type": "shell",
"dependsOn": ["Setup Dev Server"],
"command": "python3 manage.py runserver"
},
{
"label": "Yarn Install",
"dependsOn": ["Yarn Install - Vue", "Yarn Install - Vue3"]
},
{
"label": "Yarn Install - Vue",
"type": "shell",
"command": "yarn install --force",
"options": {
"cwd": "${workspaceFolder}/vue"
}
},
{
"label": "Yarn Install - Vue3",
"type": "shell",
"command": "yarn install --force",
"options": {
"cwd": "${workspaceFolder}/vue3"
}
},
{
"label": "Generate API",
"dependsOn": ["Generate API - Vue", "Generate API - Vue3"]
},
{
"label": "Generate API - Vue",
"type": "shell",
"command": "openapi-generator-cli generate -g typescript-axios -i http://127.0.0.1:8000/openapi/",
"options": {
"cwd": "${workspaceFolder}/vue/src/utils/openapi"
}
},
{
"label": "Generate API - Vue3",
"type": "shell",
"command": "openapi-generator-cli generate -g typescript-fetch -i http://127.0.0.1:8000/openapi/",
"options": {
"cwd": "${workspaceFolder}/vue3/src/openapi"
}
},
{
"label": "Yarn Serve",
"type": "shell",
"command": "yarn serve",
"dependsOn": ["Yarn Install - Vue"],
"options": {
"cwd": "${workspaceFolder}/vue"
}
},
{
"label": "Vite Serve",
"type": "shell",
"command": "vite",
"dependsOn": ["Yarn Install - Vue3"],
"options": {
"cwd": "${workspaceFolder}/vue3"
}
},
{
"label": "Yarn Build",
"dependsOn": ["Yarn Build - Vue", "Vite Build - Vue3"],
"group": "build"
},
{
"label": "Yarn Build - Vue",
"type": "shell",
"command": "yarn build",
"dependsOn": ["Yarn Install - Vue"],
"options": {
"cwd": "${workspaceFolder}/vue"
},
{
"label": "Setup Documentation Dependencies",
"type": "shell",
"command": "pip install mkdocs-material mkdocs-include-markdown-plugin",
"group": "build"
},
{
"label": "Vite Build - Vue3",
"type": "shell",
"command": "vite build",
"dependsOn": ["Yarn Install - Vue3"],
"options": {
"cwd": "${workspaceFolder}/vue3"
},
{
"label": "Serve Documentation",
"type": "shell",
"command": "mkdocs serve",
"dependsOn": ["Setup Documentation Dependencies"],
}
]
}
"group": "build"
},
{
"label": "Setup Tests",
"dependsOn": ["Run Migrations", "Collect Static Files"]
},
{
"label": "Run all pytests",
"type": "shell",
"command": "python3 -m pytest cookbook/tests",
"dependsOn": ["Setup Tests"],
"group": "test"
},
{
"label": "Setup Documentation Dependencies",
"type": "shell",
"command": "pip install mkdocs-material mkdocs-include-markdown-plugin"
},
{
"label": "Serve Documentation",
"type": "shell",
"command": "mkdocs serve",
"dependsOn": ["Setup Documentation Dependencies"]
}
]
}
39 changes: 24 additions & 15 deletions cookbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def parent(self):
return None

@property
def full_name(self):
def full_name(self) -> str:
"""
Returns a string representation of a tree node and it's ancestors,
e.g. 'Cuisine > Asian > Chinese > Catonese'.
Expand Down Expand Up @@ -911,12 +911,19 @@ class PropertyType(models.Model, PermissionModelMixin, MergeModelMixin):
GOAL = 'GOAL'
OTHER = 'OTHER'

CHOICES = (
(NUTRITION, _('Nutrition')),
(ALLERGEN, _('Allergen')),
(PRICE, _('Price')),
(GOAL, _('Goal')),
(OTHER, _('Other')),
)

name = models.CharField(max_length=128)
unit = models.CharField(max_length=64, blank=True, null=True)
order = models.IntegerField(default=0)
description = models.CharField(max_length=512, blank=True, null=True)
category = models.CharField(max_length=64, choices=((NUTRITION, _('Nutrition')), (ALLERGEN, _('Allergen')),
(PRICE, _('Price')), (GOAL, _('Goal')), (OTHER, _('Other'))), null=True, blank=True)
category = models.CharField(max_length=64, choices=CHOICES, null=True, blank=True)
open_data_slug = models.CharField(max_length=128, null=True, blank=True, default=None)

fdc_id = models.IntegerField(null=True, default=None, blank=True)
Expand Down Expand Up @@ -1461,19 +1468,21 @@ class Automation(ExportModelOperationsMixin('automations'), models.Model, Permis
UNIT_REPLACE = 'UNIT_REPLACE'
NAME_REPLACE = 'NAME_REPLACE'

automation_types = (
(FOOD_ALIAS, _('Food Alias')),
(UNIT_ALIAS, _('Unit Alias')),
(KEYWORD_ALIAS, _('Keyword Alias')),
(DESCRIPTION_REPLACE, _('Description Replace')),
(INSTRUCTION_REPLACE, _('Instruction Replace')),
(NEVER_UNIT, _('Never Unit')),
(TRANSPOSE_WORDS, _('Transpose Words')),
(FOOD_REPLACE, _('Food Replace')),
(UNIT_REPLACE, _('Unit Replace')),
(NAME_REPLACE, _('Name Replace')),
)

type = models.CharField(max_length=128,
choices=(
(FOOD_ALIAS, _('Food Alias')),
(UNIT_ALIAS, _('Unit Alias')),
(KEYWORD_ALIAS, _('Keyword Alias')),
(DESCRIPTION_REPLACE, _('Description Replace')),
(INSTRUCTION_REPLACE, _('Instruction Replace')),
(NEVER_UNIT, _('Never Unit')),
(TRANSPOSE_WORDS, _('Transpose Words')),
(FOOD_REPLACE, _('Food Replace')),
(UNIT_REPLACE, _('Unit Replace')),
(NAME_REPLACE, _('Name Replace')),
))
choices=automation_types)
name = models.CharField(max_length=128, default='')
description = models.TextField(blank=True, null=True)

Expand Down
Loading