-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more base viewsets for import/export
* Add base import/export views what only allows users to work with their own jobs (`ImportJobForUserViewSet` and `ExportJobForUserViewSet`). * Small actions definition refactor in `ExportJobViewSet/ExportJobViewSet` to allow easier overriding.
- Loading branch information
1 parent
8f3b2c1
commit f6187be
Showing
19 changed files
with
382 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Django", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/test_project/manage.py", | ||
"preLaunchTask": "Launch containers and wait for DB", | ||
"args": [ | ||
"runserver_plus", | ||
"localhost:8000", | ||
], | ||
"django": true, | ||
"justMyCode": false | ||
}, | ||
{ | ||
"name": "Python: Django With SQL Logs", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/test_project/manage.py", | ||
"preLaunchTask": "Launch containers and wait for DB", | ||
"args": [ | ||
"runserver_plus", | ||
"localhost:8000", | ||
"--print-sql" | ||
], | ||
"django": true, | ||
"justMyCode": false | ||
}, | ||
{ | ||
"name": "Python: Celery", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"module": "celery", | ||
"preLaunchTask": "Launch containers and wait for DB", | ||
"args": [ | ||
"--app", | ||
"test_project.celery_app.app", | ||
"worker", | ||
"--beat", | ||
"--scheduler=django", | ||
"--loglevel=info", | ||
], | ||
"justMyCode": false | ||
}, | ||
{ | ||
"name": "Python: Debug Tests", | ||
"type": "debugpy", | ||
"request": "launch", | ||
"program": "${file}", | ||
"purpose": ["debug-test"], | ||
"console": "integratedTerminal", | ||
"justMyCode": false | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"files.exclude": { | ||
"**/__pycache__": true, | ||
"**/.pytest_cache": true, | ||
"**/.mypy_cache": true, | ||
"**/.ruff_cache": true, | ||
"**/htmlcov": true, | ||
}, | ||
|
||
"editor.rulers": [79], | ||
|
||
"editor.bracketPairColorization.enabled": true, | ||
|
||
"python.analysis.typeCheckingMode": "off", | ||
|
||
"python.analysis.inlayHints.functionReturnTypes": true, | ||
"mypy.enabled": false, | ||
|
||
"python.testing.unittestEnabled": false, | ||
"python.testing.pytestEnabled": true, | ||
|
||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "charliermarsh.ruff" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Launch containers and wait for DB", | ||
"type": "shell", | ||
"command": "inv django.wait-for-database", | ||
"problemMatcher": [], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": false | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
from .serializers.export_job import CreateExportJob, ExportJobSerializer | ||
from .serializers.import_job import CreateImportJob, ImportJobSerializer | ||
from .serializers.progress import ProgressInfoSerializer, ProgressSerializer | ||
from .mixins import LimitQuerySetToCurrentUserMixin | ||
from .serializers import ( | ||
CreateExportJob, | ||
CreateImportJob, | ||
ExportJobSerializer, | ||
ImportJobSerializer, | ||
ProgressInfoSerializer, | ||
ProgressSerializer, | ||
) | ||
from .views import ( | ||
ExportJobForUserViewSet, | ||
ExportJobViewSet, | ||
ImportJobForUserViewSet, | ||
ImportJobViewSet, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class LimitQuerySetToCurrentUserMixin: | ||
"""Make queryset to return only current user jobs.""" | ||
|
||
def get_queryset(self): | ||
"""Return user's jobs.""" | ||
return ( | ||
super() | ||
.get_queryset() | ||
.filter(created_by_id=getattr(self.request.user, "pk", None)) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
from .export_job import ExportJobSerializer, get_create_export_job_serializer | ||
from .import_job import ImportJobSerializer, get_create_import_job_serializer | ||
from .export_job import ( | ||
CreateExportJob, | ||
ExportJobSerializer, | ||
get_create_export_job_serializer, | ||
) | ||
from .import_job import ( | ||
CreateImportJob, | ||
ImportJobSerializer, | ||
get_create_import_job_serializer, | ||
) | ||
from .progress import ProgressInfoSerializer, ProgressSerializer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,8 @@ | ||
from .export_job import ExportJobViewSet | ||
from .import_job import ImportJobViewSet | ||
from .export_job import ( | ||
ExportJobForUserViewSet, | ||
ExportJobViewSet, | ||
) | ||
from .import_job import ( | ||
ImportJobForUserViewSet, | ||
ImportJobViewSet, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.