Reusable functionality
Project description
About
A reusable DRF library that provides reusable components.
Installation
pip install django-pycorpkit
Quick start
Add “django-pycorpkit” to your INSTALLED_APPS setting:
INSTALLED_APPS = [ ... "pycorpkit.common", "pycorpkit.accountx", "pycorpkit.org_structure", ]
Include the django_sample_lib URLconf in your project urls.py:
path('api/', include('pycorpkit.urls')),
Run migrations:
python manage.py migrate
Add exception handler and default backend filter:
REST_FRAMEWORK = { "EXCEPTION_HANDLER": "pycorpkit.common.utils.exception_handler.custom_exception_handler", "DEFAULT_PERMISSION_CLASSES": [ "pycorpkit.accountx.permissions.enforce.EnforceDRFViewPermission", ], "DEFAULT_FILTER_BACKENDS": ( "pycorpkit.common.filters.base.OrganisationFilterBackend", ), }
Add required variables in settings file:
PERMISSIONS_PATH = "testapp.perms" APP_NAME = "PyCorpKit" CLIENT_DOMAIN = "http://domain.com/" AUTH_USER_MODEL = "accountx.User" DEFAULT_FROM_EMAIL = "admin@example.com" SIMPLE_JWT = { "ACCESS_TOKEN_LIFETIME": timedelta(seconds=3600), "REFRESH_TOKEN_LIFETIME": timedelta(days=7), }
INCLUDE django_rest_passwordreset in installed apps
INSTALLED_APPS = ( 'django_rest_passwordreset', )
Add PhoneModelBackend to AUTHENTICATION_BACKENDS
AUTHENTICATION_BACKENDS = [ 'django.contrib.auth.backends.ModelBackend', # add the below after `ModelBackend` 'pycorpkit.common.utils.phone_backend.PhoneModelBackend', ]
Add organisation middleware
MIDDLEWARE = [ "pycorpkit.common.utils.middleware.OrganisationIDMiddleware", ]
Define DEFAULT_ROLES in settings
DEFAULT_ROLES = { "Organisation Admin": ORGANISATION_ADMIN, "Branch Admin": BRANCH_ADMIN, "Department Admin": DEPARTMENT_ADMIN, "User": PROFILE_ADMIN, }
Development
To set up the development environment:
Clone the repository
Create a virtual environment and activate it
Install development dependencies:
pip install -e ".[dev]"
Run tests:
python -m pytest tests # OR pytest tests/
Install test dependencies
pip install -e ".[test]"
Making migrations
python testapp/manage.py makemigrations
python testapp/manage.py makemigrations <app_name> --empty
Migrate
python testapp/manage.py migrate
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_pycorpkit-1.0.2.tar.gz
.
File metadata
- Download URL: django_pycorpkit-1.0.2.tar.gz
- Upload date:
- Size: 70.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41bd12b7dfa2e05df07585bd0ae05a65252f94fc70ad1ac71c71f90e53481a32 |
|
MD5 | 5b5be38abc2dd4ac2973cde368be8c30 |
|
BLAKE2b-256 | cff8a39ca757aa580dfe8fe180b971b038b90e309d35d8431052671b18a5818c |
File details
Details for the file django_pycorpkit-1.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: django_pycorpkit-1.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 68.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f490d927fd6cc22b545b0a73a274b355e77a3571603b38054d6997096b4e6b4 |
|
MD5 | 6b301b709e850f76e2902323df98422a |
|
BLAKE2b-256 | ea57d4e389b0629c7e50ff648ba60aebb032f28f720109658dd8a44df0c6b652 |