tom-registration


Nametom-registration JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryReusable TOMToolkit app to support multiple user registration flows.
upload_time2025-07-16 21:50:44
maintainerJoey Chatelain
docs_urlNone
authorTOM Toolkit Project
requires_python<3.13,>=3.9.0
licenseGPL-3.0-only
keywords tomtoolkit tom astronomy astrophysics cosmology science
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![pypi](https://img.shields.io/pypi/v/tom-registration.svg)](https://pypi.python.org/pypi/tom-registration)
[![run-tests](https://github.com/TOMToolkit/tom_registration/actions/workflows/run-tests.yml/badge.svg)](https://github.com/TOMToolkit/tom_registration/actions/workflows/run-tests.yml)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/96d28f95266144f7afc7d118050b24ba)](https://www.codacy.com/gh/TOMToolkit/tom_registration/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TOMToolkit/tom_registration&amp;utm_campaign=Badge_Grade)
[![Coverage Status](https://coveralls.io/repos/github/TOMToolkit/tom_registration/badge.svg?branch=main)](https://coveralls.io/github/TOMToolkit/tom_registration?branch=main)

# TOM Registration

This reusable TOM Toolkit app provides support for two user registration flows in the TOM Toolkit.

The two registration flows are as follows:

 1. Open Registration - In this flow, the user fills in a registration form and is immediately able to access the TOM and see all public data.

 2. Approval Registration - In this flow, the user fills in a registration form, and is inactive until an administrator reviews and approves their registration.

## Installation

 1. Install the package into your TOM environment:
   ```bash
   pip install tom-registration
   ```

 2. In your project `settings.py`, add `tom_registration` to your `INSTALLED_APPS` setting:

    ```python
    INSTALLED_APPS = [
        ...
        'tom_registration',
    ]
    ```

    And add the follow setting, with appropriate values for your use case:

    ```python
    TOM_REGISTRATION = {
        'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.ModelBackend',
        'REGISTRATION_REDIRECT_PATTERN': 'home',
        'REGISTRATION_STRATEGY': 'open',  # ['open', 'approval_required']
        'SEND_APPROVAL_EMAILS': True,  # Optional email behavior if `REGISTRATION_STRATEGY = 'approval_required'`, default is False
        'APPROVAL_SUBJECT': f'Your {TOM_NAME} registration has been approved!',  # Optional subject line of approval email, (Default Shown)
        'APPROVAL_MESSAGE': f'Your {TOM_NAME} registration has been approved. You can log in <a href="mytom.com/login">here</a>.'  # Optional html-enabled body for approval email, (Default Shown)
    }
    ```

    To prevent logged-in users from accessing the registration page, add `RedirectAuthenticatedUsersFromRegisterMiddleware` to the `MIDDLEWARE` settings:

    ```python
    MIDDLEWARE = [
        ...
        'tom_common.middleware.AuthStrategyMiddleware',
        'tom_registration.middleware.RedirectAuthenticatedUsersFromRegisterMiddleware',
    ]
    ```
 
 3. If you're using approval registration and you would like a message informing the user that their account is pending approval if they try to log in prior to approval, you'll need to make the following changes:

     First, in your `settings.py`, set the first item of your `AUTHENTICATION_BACKENDS`:

     ```python
     AUTHENTICATION_BACKENDS = (
         'django.contrib.auth.backends.AllowAllUsersModelBackend',
         'guardian.backends.ObjectPermissionBackend'
     )
     ```

     Then, change the value of `REGISTRATION_AUTHENTICATION_BACKEND` in the `TOM_REGISTRATION` setting that was just created:

     ```python
     TOM_REGISTRATION = {
         'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.AllowAllUsersModelBackend',
         ...
     }
     ```

## Email

In the approval required registration flow, there is available behavior to send basic emails notifying moderators
of a registration request, and notifying users of registration approval. Administrators are determined by the
[Django MANAGERS setting](https://docs.djangoproject.com/en/stable/ref/settings/#managers). 
Email behavior can be enabled or disabled with `SEND_APPROVAL_EMAILS`.

The configuration of an email backend is a topic covered in depth by the 
[Django docs](http://docs.djangoproject.com/en/stable/topics/email/#smtp-backend). 
There are a number of required settings that will need to be added.
An example of how the most important settings should look something like the following:

```python
    MANAGERS = [('Manager1', 'manager@my_tom.com')]  # List of managers who should receive registration emails
    EMAIL_SUBJECT_PREFIX = f'[{TOM_NAME}]'  # Optional prefix for all approval requests to managers
    EMAIL_HOST = 'smtp.gmail.com'   # SMTP server for sending emails (this example is for gmail)
    EMAIL_PORT = 587  # Port for the SMTP server
    EMAIL_HOST_USER = 'my_tom@gmail.com'  # Email address for the account sending emails
    EMAIL_HOST_PASSWORD = '******************'  # Password for the account sending emails (app password for gmail)
    EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
    EMAIL_USE_TLS = True  # this is needed for gmail, other services may vary
    EMAIL_USE_SSL = False  # this is needed for gmail, other services may vary
    SERVER_EMAIL = "my_tom@email.com"  # Email address used as the "from" address if EMAIL_HOST_USER is not needed
```

**Note if using gmail:** the `EMAIL_HOST_PASSWORD` above is not the account email password associated with `EMAIL_HOST_USER`,
but an app password generated by the account owner. This can be generated from the account settings page by searching for "app passwords".


## Running the tests

In order to run the tests, run the following in your virtualenv:

```bash
    python tom_registration/tests/run_tests.py
```

For options see
```bash
    python tom_registration/tests/run_tests.py --help
```



            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tom-registration",
    "maintainer": "Joey Chatelain",
    "docs_url": null,
    "requires_python": "<3.13,>=3.9.0",
    "maintainer_email": "jchate6@gmail.com",
    "keywords": "tomtoolkit, TOM, astronomy, astrophysics, cosmology, science",
    "author": "TOM Toolkit Project",
    "author_email": "tomtoolkit-maintainers@lco.global",
    "download_url": "https://files.pythonhosted.org/packages/6f/a1/b91236de259bf8309cd23f94ee5c5195e0ec63dfd5cb393eb5b3085e36cb/tom_registration-1.0.2.tar.gz",
    "platform": null,
    "description": "[![pypi](https://img.shields.io/pypi/v/tom-registration.svg)](https://pypi.python.org/pypi/tom-registration)\n[![run-tests](https://github.com/TOMToolkit/tom_registration/actions/workflows/run-tests.yml/badge.svg)](https://github.com/TOMToolkit/tom_registration/actions/workflows/run-tests.yml)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/96d28f95266144f7afc7d118050b24ba)](https://www.codacy.com/gh/TOMToolkit/tom_registration/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=TOMToolkit/tom_registration&amp;utm_campaign=Badge_Grade)\n[![Coverage Status](https://coveralls.io/repos/github/TOMToolkit/tom_registration/badge.svg?branch=main)](https://coveralls.io/github/TOMToolkit/tom_registration?branch=main)\n\n# TOM Registration\n\nThis reusable TOM Toolkit app provides support for two user registration flows in the TOM Toolkit.\n\nThe two registration flows are as follows:\n\n 1. Open Registration - In this flow, the user fills in a registration form and is immediately able to access the TOM and see all public data.\n\n 2. Approval Registration - In this flow, the user fills in a registration form, and is inactive until an administrator reviews and approves their registration.\n\n## Installation\n\n 1. Install the package into your TOM environment:\n   ```bash\n   pip install tom-registration\n   ```\n\n 2. In your project `settings.py`, add `tom_registration` to your `INSTALLED_APPS` setting:\n\n    ```python\n    INSTALLED_APPS = [\n        ...\n        'tom_registration',\n    ]\n    ```\n\n    And add the follow setting, with appropriate values for your use case:\n\n    ```python\n    TOM_REGISTRATION = {\n        'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.ModelBackend',\n        'REGISTRATION_REDIRECT_PATTERN': 'home',\n        'REGISTRATION_STRATEGY': 'open',  # ['open', 'approval_required']\n        'SEND_APPROVAL_EMAILS': True,  # Optional email behavior if `REGISTRATION_STRATEGY = 'approval_required'`, default is False\n        'APPROVAL_SUBJECT': f'Your {TOM_NAME} registration has been approved!',  # Optional subject line of approval email, (Default Shown)\n        'APPROVAL_MESSAGE': f'Your {TOM_NAME} registration has been approved. You can log in <a href=\"mytom.com/login\">here</a>.'  # Optional html-enabled body for approval email, (Default Shown)\n    }\n    ```\n\n    To prevent logged-in users from accessing the registration page, add `RedirectAuthenticatedUsersFromRegisterMiddleware` to the `MIDDLEWARE` settings:\n\n    ```python\n    MIDDLEWARE = [\n        ...\n        'tom_common.middleware.AuthStrategyMiddleware',\n        'tom_registration.middleware.RedirectAuthenticatedUsersFromRegisterMiddleware',\n    ]\n    ```\n \n 3. If you're using approval registration and you would like a message informing the user that their account is pending approval if they try to log in prior to approval, you'll need to make the following changes:\n\n     First, in your `settings.py`, set the first item of your `AUTHENTICATION_BACKENDS`:\n\n     ```python\n     AUTHENTICATION_BACKENDS = (\n         'django.contrib.auth.backends.AllowAllUsersModelBackend',\n         'guardian.backends.ObjectPermissionBackend'\n     )\n     ```\n\n     Then, change the value of `REGISTRATION_AUTHENTICATION_BACKEND` in the `TOM_REGISTRATION` setting that was just created:\n\n     ```python\n     TOM_REGISTRATION = {\n         'REGISTRATION_AUTHENTICATION_BACKEND': 'django.contrib.auth.backends.AllowAllUsersModelBackend',\n         ...\n     }\n     ```\n\n## Email\n\nIn the approval required registration flow, there is available behavior to send basic emails notifying moderators\nof a registration request, and notifying users of registration approval. Administrators are determined by the\n[Django MANAGERS setting](https://docs.djangoproject.com/en/stable/ref/settings/#managers). \nEmail behavior can be enabled or disabled with `SEND_APPROVAL_EMAILS`.\n\nThe configuration of an email backend is a topic covered in depth by the \n[Django docs](http://docs.djangoproject.com/en/stable/topics/email/#smtp-backend). \nThere are a number of required settings that will need to be added.\nAn example of how the most important settings should look something like the following:\n\n```python\n    MANAGERS = [('Manager1', 'manager@my_tom.com')]  # List of managers who should receive registration emails\n    EMAIL_SUBJECT_PREFIX = f'[{TOM_NAME}]'  # Optional prefix for all approval requests to managers\n    EMAIL_HOST = 'smtp.gmail.com'   # SMTP server for sending emails (this example is for gmail)\n    EMAIL_PORT = 587  # Port for the SMTP server\n    EMAIL_HOST_USER = 'my_tom@gmail.com'  # Email address for the account sending emails\n    EMAIL_HOST_PASSWORD = '******************'  # Password for the account sending emails (app password for gmail)\n    EMAIL_BACKEND = \"django.core.mail.backends.smtp.EmailBackend\"\n    EMAIL_USE_TLS = True  # this is needed for gmail, other services may vary\n    EMAIL_USE_SSL = False  # this is needed for gmail, other services may vary\n    SERVER_EMAIL = \"my_tom@email.com\"  # Email address used as the \"from\" address if EMAIL_HOST_USER is not needed\n```\n\n**Note if using gmail:** the `EMAIL_HOST_PASSWORD` above is not the account email password associated with `EMAIL_HOST_USER`,\nbut an app password generated by the account owner. This can be generated from the account settings page by searching for \"app passwords\".\n\n\n## Running the tests\n\nIn order to run the tests, run the following in your virtualenv:\n\n```bash\n    python tom_registration/tests/run_tests.py\n```\n\nFor options see\n```bash\n    python tom_registration/tests/run_tests.py --help\n```\n\n\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-only",
    "summary": "Reusable TOMToolkit app to support multiple user registration flows.",
    "version": "1.0.2",
    "project_urls": null,
    "split_keywords": [
        "tomtoolkit",
        " tom",
        " astronomy",
        " astrophysics",
        " cosmology",
        " science"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56122e8512068bd9f8f07dbb70a7e350a781caf47010b967c9b2f73652269b25",
                "md5": "c69b073aeb5706b94e24d1b7e5d2853e",
                "sha256": "f8a5bdbfc0d898c33788aab929ad698299b08e5468b119b68f657bcd500aa750"
            },
            "downloads": -1,
            "filename": "tom_registration-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c69b073aeb5706b94e24d1b7e5d2853e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.9.0",
            "size": 31644,
            "upload_time": "2025-07-16T21:50:42",
            "upload_time_iso_8601": "2025-07-16T21:50:42.504998Z",
            "url": "https://files.pythonhosted.org/packages/56/12/2e8512068bd9f8f07dbb70a7e350a781caf47010b967c9b2f73652269b25/tom_registration-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6fa1b91236de259bf8309cd23f94ee5c5195e0ec63dfd5cb393eb5b3085e36cb",
                "md5": "bfc89bb5a326eee6ec372254c706fe76",
                "sha256": "f0cf86b0da774de40bbccdf7fa317aad9c3fa0751b48806f2b87c459e973c1a0"
            },
            "downloads": -1,
            "filename": "tom_registration-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "bfc89bb5a326eee6ec372254c706fe76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.9.0",
            "size": 25582,
            "upload_time": "2025-07-16T21:50:44",
            "upload_time_iso_8601": "2025-07-16T21:50:44.175837Z",
            "url": "https://files.pythonhosted.org/packages/6f/a1/b91236de259bf8309cd23f94ee5c5195e0ec63dfd5cb393eb5b3085e36cb/tom_registration-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-16 21:50:44",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "tom-registration"
}
        
Elapsed time: 0.90208s