Tools for creating and managing multi-site integrations like API Keys and Tokens
Project description
Django Integrations
Tools for creating and managing multi-site integrations like API Keys and Tokens
Prerequisites
This pakcage makes use of Encrypted Fields that come form the django-fernet-fields packages. Make sure to checkout their documentation for any questions related to Field Encryption.
This package makes use of JSON fields so you’ll need Download and install Postgresql. This will change with Django 3.1+ and the universal JSON field.
Installation
> pip install django-integration
For Developers
Make sure you run the following command to ensure you have all the requirements needed to us the develop example project:
pip install -e .[dev]
Then run the migration command inside the develop folder
./manage.py migrate
finally create a super user:
./manage.py createsuperuser
Example
In the develop django project you will find a core application that has three Forms each with its view to show case how to use the Credential Model in the integration package.
For example you have a ZoomForm to present the user with the fields Zoom gives to use their API with you project. The ZoomForm is responsible for presenting and validating the fields and linking it to the credentials Model just like a normal ModelForm would.
class ZoomForm(forms.ModelForm):
class Meta:
model = Credential
fields = ['public_key', 'private_key']
labels = {
'public_key': "Zoom Key",
'private_key': "Zoom Secret"
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['public_key'].required = True
self.fields['private_key'].required = True
It is in the view where it creates a Credential Model instance form the form submitted and saved. If you need to add additional fields or logic you can do it here, for example settting the site field in the Credential Model.
class ZoomFormView(FormView):
template_name = "core/form.html"
form_class = ZoomForm
success_url = reverse_lazy('integration-list')
def form_valid(self, form):
zoom = form.save(commit=False)
zoom.name = 'Zoom Integration'
zoom.site = Site.objects.get_current()
zoom.save()
return super().form_valid(form)
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
Hashes for django-integrations-0.1.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 625dbda45ac145ee64eafff7c091b8715050155cba9df08f343848563ae2410f |
|
MD5 | 0b00c88d8528ed2a996beea4e86e6545 |
|
BLAKE2b-256 | d154397e23164a427f7e0dfc8496607dbb553f3357562acad6b7523eb8da9918 |
Hashes for django_integrations-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4363ce32442a3b4299d73f632f5fddc37eb88998999b661b7cb26147b0100244 |
|
MD5 | 9aab65c4fc4ead2aa7d3f866e5a05a27 |
|
BLAKE2b-256 | 12cf7d7d3eb35bf5595fa58a258f704da15ca1c00b7c2496394267239eb1d30f |