mosparo-django


Namemosparo-django JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryA Django app to integrate mosparo into your forms.
upload_time2024-09-26 18:13:46
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseThe MIT License (MIT) Copyright 2023-2024 mosparo Core Developers and contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords mosparo spam-protection accessibility captcha django app
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
             
<p align="center">
    <img src="https://github.com/mosparo/mosparo/blob/master/assets/images/mosparo-logo.svg?raw=true" alt="mosparo logo contains a bird with the name Mo and the mosparo text"/>
</p>

<h1 align="center">
    Integration for Django
</h1>
<p align="center">
    This Django app offers the needed form, field, and widget class to add mosparo to your Django form.
</p>

-----

## Description

With this Django app, you can protect your forms with mosparo. Install the app, configure it and add the field to your forms.

## How to use

Please see our [How to use](https://mosparo.io/how-to-use/) introduction on our website to learn how to use mosparo in your form.

In step 3 of the how-to-use explanation, you must integrate mosparo into your website. Please follow the [Installation](#installation) part below for this process.

In step 4 of the how-to-use explanation, you must connect your website with your mosparo project. Please follow the [Usage](#usage) part below.

## Installation

### Install using pip

Install this app by using pip:

```commandline
pip install mosparo_django
```

### Build from source

You need the module `build` to build the module from source.

1. Clone the repository
2. Build the package
```commandline
python -m build
```
3. Install the package
```commandline
pip install dist/mosparo_django-1.0.2-py3-none-any.whl
```

## Usage

1. Create a project in your mosparo installation
2. Edit the `settings.py` file of your project
2. Add the mosparo integration to the list of enabled apps:
```python
INSTALLED_APPS = [
    # ...
    'mosparo_django',
]
```
3. Specify the configuration for mosparo:
```python
MOSPARO_HOST = 'https://...'
MOSPARO_UUID = '...'
MOSPARO_PUBLIC_KEY = '...'
MOSPARO_PRIVATE_KEY = '...'
MOSPARO_VERIFY_SSL = True
```
4. Add the mosparo field to your form:
```python
from mosparo_django.fields import MosparoField

class Form(forms.Form):
    # Your other fields...
    mosparo = MosparoField(label='Spam protection')
```
5. Add the verification (see [Verification](#verification))
6. Test your form and verify that everything works correctly and you see the submission in mosparo.

### Verification

After the user submits the form, the backend has to verify the form data before you can process them. Since we didn't find a good way to do this automatically, you have to implement one of the following options:

#### Use the mosparo Form class

Use the mosparo Form class to create your form instead of the `django.forms.Form` class:

```python
from mosparo_django.forms import MosparoForm
from mosparo_django.fields import MosparoField

class Form(MosparoForm):
    # Your other fields...
    mosparo = MosparoField(label='Spam protection')
```

#### Override the `clean` method

The other option is to override the method `clean` of the Form class:

```python
from mosparo_django.fields import MosparoField

class Form(forms.Form):
    # Your other fields...
    mosparo = MosparoField(label='Spam protection')

    def clean(self):
        self.mosparo.verify_data(self)
    
        return super().clean()
```

**Important: No spam protection will happen if you do not use one of these two things.**

### Specify the connection details on the field

You can also specify the connection details on the field. For that, please add the field to your form and specify the connection settings by setting the parameters `mosparo_host`, `mosparo_uuid`, `mosparo_public_key`, `mosparo_private_key`, and `mosparo_verify_ssl`. If you want to change the UUID, public or private key, you have to specify all these three values because these depend on the project and if you want to connect the field to a different project, all three values will be different.

```python
from mosparo_django.forms import MosparoForm
from mosparo_django.fields import MosparoField

class Form(MosparoForm):
    # Your other fields...
    mosparo = MosparoField(label='Spam protection', mosparo_uuid='123', mosparo_public_key='test_key', mosparo_private_key = 'private_key')
```

### Filter the field types and form data

The MosparoField offers some callback methods to adjust the behavior of the field.

```python
from mosparo_django.forms import MosparoForm
from mosparo_django.fields import MosparoField

class Form(MosparoForm):
    # Your other fields...
    mosparo = MosparoField(callback_ignored_field_types=None, callback_verifiable_field_types=None, callback_after_prepare_form_data=None)
```

| Argument name                      | Description                                                                                                                                          |
|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| `callback_ignored_field_types`     | Gets and returns a list of class names of field types, which should be ignored (Example: `PasswordInput`)                                            |
| `callback_verifiable_field_types`  | Gets and returns a list of class names of field types, which are verifiable (Example: `TextInput`)                                                   |
| `callback_after_prepare_form_data` | Gets the dict with all prepared form data, the required field names, and the verifiable field names as argument and expects the same to be returned. |

## License

mosparo Integration for Django is open-sourced software licensed under the [MIT License](https://opensource.org/licenses/MIT).
Please see the [LICENSE](LICENSE) file for the full license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mosparo-django",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "mosparo, spam-protection, accessibility, captcha, django, app",
    "author": null,
    "author_email": "mosparo Core Developers <info@mosparo.io>",
    "download_url": "https://files.pythonhosted.org/packages/c7/74/8e4fad2e36168400fe7a083d035f5984c0054c7a3f994310fc152c32f34b/mosparo_django-1.0.2.tar.gz",
    "platform": null,
    "description": "&nbsp;\n<p align=\"center\">\n    <img src=\"https://github.com/mosparo/mosparo/blob/master/assets/images/mosparo-logo.svg?raw=true\" alt=\"mosparo logo contains a bird with the name Mo and the mosparo text\"/>\n</p>\n\n<h1 align=\"center\">\n    Integration for Django\n</h1>\n<p align=\"center\">\n    This Django app offers the needed form, field, and widget class to add mosparo to your Django form.\n</p>\n\n-----\n\n## Description\n\nWith this Django app, you can protect your forms with mosparo. Install the app, configure it and add the field to your forms.\n\n## How to use\n\nPlease see our [How to use](https://mosparo.io/how-to-use/) introduction on our website to learn how to use mosparo in your form.\n\nIn step 3 of the how-to-use explanation, you must integrate mosparo into your website. Please follow the [Installation](#installation) part below for this process.\n\nIn step 4 of the how-to-use explanation, you must connect your website with your mosparo project. Please follow the [Usage](#usage) part below.\n\n## Installation\n\n### Install using pip\n\nInstall this app by using pip:\n\n```commandline\npip install mosparo_django\n```\n\n### Build from source\n\nYou need the module `build` to build the module from source.\n\n1. Clone the repository\n2. Build the package\n```commandline\npython -m build\n```\n3. Install the package\n```commandline\npip install dist/mosparo_django-1.0.2-py3-none-any.whl\n```\n\n## Usage\n\n1. Create a project in your mosparo installation\n2. Edit the `settings.py` file of your project\n2. Add the mosparo integration to the list of enabled apps:\n```python\nINSTALLED_APPS = [\n    # ...\n    'mosparo_django',\n]\n```\n3. Specify the configuration for mosparo:\n```python\nMOSPARO_HOST = 'https://...'\nMOSPARO_UUID = '...'\nMOSPARO_PUBLIC_KEY = '...'\nMOSPARO_PRIVATE_KEY = '...'\nMOSPARO_VERIFY_SSL = True\n```\n4. Add the mosparo field to your form:\n```python\nfrom mosparo_django.fields import MosparoField\n\nclass Form(forms.Form):\n    # Your other fields...\n    mosparo = MosparoField(label='Spam protection')\n```\n5. Add the verification (see [Verification](#verification))\n6. Test your form and verify that everything works correctly and you see the submission in mosparo.\n\n### Verification\n\nAfter the user submits the form, the backend has to verify the form data before you can process them. Since we didn't find a good way to do this automatically, you have to implement one of the following options:\n\n#### Use the mosparo Form class\n\nUse the mosparo Form class to create your form instead of the `django.forms.Form` class:\n\n```python\nfrom mosparo_django.forms import MosparoForm\nfrom mosparo_django.fields import MosparoField\n\nclass Form(MosparoForm):\n    # Your other fields...\n    mosparo = MosparoField(label='Spam protection')\n```\n\n#### Override the `clean` method\n\nThe other option is to override the method `clean` of the Form class:\n\n```python\nfrom mosparo_django.fields import MosparoField\n\nclass Form(forms.Form):\n    # Your other fields...\n    mosparo = MosparoField(label='Spam protection')\n\n    def clean(self):\n        self.mosparo.verify_data(self)\n    \n        return super().clean()\n```\n\n**Important: No spam protection will happen if you do not use one of these two things.**\n\n### Specify the connection details on the field\n\nYou can also specify the connection details on the field. For that, please add the field to your form and specify the connection settings by setting the parameters `mosparo_host`, `mosparo_uuid`, `mosparo_public_key`, `mosparo_private_key`, and `mosparo_verify_ssl`. If you want to change the UUID, public or private key, you have to specify all these three values because these depend on the project and if you want to connect the field to a different project, all three values will be different.\n\n```python\nfrom mosparo_django.forms import MosparoForm\nfrom mosparo_django.fields import MosparoField\n\nclass Form(MosparoForm):\n    # Your other fields...\n    mosparo = MosparoField(label='Spam protection', mosparo_uuid='123', mosparo_public_key='test_key', mosparo_private_key = 'private_key')\n```\n\n### Filter the field types and form data\n\nThe MosparoField offers some callback methods to adjust the behavior of the field.\n\n```python\nfrom mosparo_django.forms import MosparoForm\nfrom mosparo_django.fields import MosparoField\n\nclass Form(MosparoForm):\n    # Your other fields...\n    mosparo = MosparoField(callback_ignored_field_types=None, callback_verifiable_field_types=None, callback_after_prepare_form_data=None)\n```\n\n| Argument name                      | Description                                                                                                                                          |\n|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `callback_ignored_field_types`     | Gets and returns a list of class names of field types, which should be ignored (Example: `PasswordInput`)                                            |\n| `callback_verifiable_field_types`  | Gets and returns a list of class names of field types, which are verifiable (Example: `TextInput`)                                                   |\n| `callback_after_prepare_form_data` | Gets the dict with all prepared form data, the required field names, and the verifiable field names as argument and expects the same to be returned. |\n\n## License\n\nmosparo Integration for Django is open-sourced software licensed under the [MIT License](https://opensource.org/licenses/MIT).\nPlease see the [LICENSE](LICENSE) file for the full license.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright 2023-2024 mosparo Core Developers and contributors  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Django app to integrate mosparo into your forms.",
    "version": "1.0.2",
    "project_urls": {
        "GitHub": "https://github.com/mosparo/django-integration",
        "Website": "https://mosparo.io"
    },
    "split_keywords": [
        "mosparo",
        " spam-protection",
        " accessibility",
        " captcha",
        " django",
        " app"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "50f78bcddb63f0d9f2e496b70ecaf262763a14ff201d582b7bc3800a604beba0",
                "md5": "17320f33ee42230fc43869108e3c7df1",
                "sha256": "7e906222eef26fd1978b59e86b38fda2cbdeeabba11faa365b974f3717600d98"
            },
            "downloads": -1,
            "filename": "mosparo_django-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17320f33ee42230fc43869108e3c7df1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8810,
            "upload_time": "2024-09-26T18:13:44",
            "upload_time_iso_8601": "2024-09-26T18:13:44.926847Z",
            "url": "https://files.pythonhosted.org/packages/50/f7/8bcddb63f0d9f2e496b70ecaf262763a14ff201d582b7bc3800a604beba0/mosparo_django-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c7748e4fad2e36168400fe7a083d035f5984c0054c7a3f994310fc152c32f34b",
                "md5": "67592009c616f31e952c27eb990aca6e",
                "sha256": "04b2619463dd254f59d4a41a239fc602188ff3df0db66e354ac8d5fa9c39365e"
            },
            "downloads": -1,
            "filename": "mosparo_django-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "67592009c616f31e952c27eb990aca6e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11253,
            "upload_time": "2024-09-26T18:13:46",
            "upload_time_iso_8601": "2024-09-26T18:13:46.084937Z",
            "url": "https://files.pythonhosted.org/packages/c7/74/8e4fad2e36168400fe7a083d035f5984c0054c7a3f994310fc152c32f34b/mosparo_django-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 18:13:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mosparo",
    "github_project": "django-integration",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "mosparo-django"
}
        
Elapsed time: 0.77294s