Commit Graph

14 Commits

Author SHA1 Message Date
Adnan Umer ab12904826 Migrated to TEMPLATES settings 2017-04-17 15:54:16 +05:00
Stéphane Raimbault 36e1ba3800 Django 1.11 support (#463)
* Added Django 1.11 to Travis

- related to #435
- 😉 to tomturner/django-tenants#120

* Replace direct use of import_module by proper load_backend

Handle new 'django.db.backends.postgresql' name (Django 1.9)

* Fix 'default' already present in _fields in Django 1.11

* Fix not existing access to original_backend.DatabaseError (Django 1.11)

Removed exports because django.db.utils.DatabaseError and
django.db.utils.IntegrityError must be used instead.

This change must be stated in release notes.

* The signature of DatabaseWrapper._cursor has changed in Django 1.11

Use the public API

* Add missing allowed hosts for tests

* Don't override default user or blocks Unix socket DB connection

* Updated tox.ini for Django 1.11rc1

* Properly add '.test.com' to ALLOWED_HOSTS in test cases

* Internal tests don't use TenantTestCase so set allowed hosts manually

* Drop Django 1.9 support

Django 1.8 is still within LTS until the end of 2017.
2017-04-17 15:03:59 +05:00
Gary Reynolds 2e789f71bc TenantStorageMixin (#442)
* Add a tenant aware storage backend.

Using a mixin that can be combined with existing core and 3rd party
storage backends which isolates user uploaded media by introducing a
directory based on the schema_name (which shouldn't change after it's
been created) and a symbolic link from the domain_url to the directory.

In the reverse proxy, the domain_url can be parametrised to serve the
content via the symbolic link.

* WARN if project is not using a tenant aware storage backend.

* Add collectstatic_schemas management command

* Update the __all__ directive for tenant_schemas.storage

* Update test project for storage mixins

* Add documentation for DEFAULT_FILE_STORAGE changes
2017-02-22 20:08:37 +11:00
Gary Reynolds 6df7a1c019 Adjust to check that tenant_schemas is listed first in INSTALLED_APPS
The Django documentation suggests that the correct way to overload
management commands with the same name is to load them earlier in the
INSTALLED_APPS list.
2016-11-11 07:57:14 +11:00
Gary Reynolds ea95f3f7a4 Refactor ImproperlyConfigured to system check framework
- ensure TENANT_APPS is defined in settings.py
- ensure TENANT_MODEL is defined in settings.py
- ensure TenantSyncRouter appears in DATABASE_ROUTERS
- ensure public schema and any existing tenant schemas are not listed in PG_EXTRA_SEARCH_PATHS
- raise error when TENANT_APPS is empty
- issue warning when 'tenant_schemas' is not the last item in INSTALLED_APPS
- issue warning when items in TENANT_APPS are not in INSTALLED_APPS
- add checks for SHARED_APPS
- add test cases for the best_practice system check
- update install documentation which previously suggested concatenation
- fix import path of get_public_schema_name
- fix failing test case for TenantContextFilter
- update tox.ini
- add .travis.yml
- PEP8 fixes
2016-11-11 07:57:14 +11:00
Gary Reynolds ca7536be55 Add travis-ci.org integration 2016-11-10 11:53:50 +11:00
Gary Reynolds b62cbd7fba Add TenantContextFilter to test project settings 2016-09-26 07:49:51 +10:00
Justin Wunderle d9ce4ff99a Add TenantContextFilter - put schema_name and domain_url in log records
Add a LOGGING configuration similar to the section below.

    LOGGING = {
        'filters': {
            'tenant_context': {
                '()': 'tenant_schemas.log.TenantContextFilter',
            },
        },
        'formatters': {
            'default': {
                'format': '[%(schema_name)s:%(domain_url)s] '
                          '%(levelname)s %(asctime)s '
                          '%(message)s',
            },
        },
        'handlers': {
            'console': {
                'class': 'logging.StreamHandler',
                'formatter': 'default',
                'filters': ['tenant_context'],
            },
        },
    }

Your logging output will not look something like:

    [example:example.com] DEBUG 13:29 django.db.backends: (0.001) SELECT ...
2016-09-26 07:40:35 +10:00
Gary Reynolds cb8862d026 Remove Django < 1.8 compatibility
- resolves template loading in Django 1.8+ (thanks to @tomturner)
 - removed code branches based on django.VERSION value
 - updated documentation to remove details of removed functionality

Closes #289
2016-05-18 22:18:31 +10:00
Gary Reynolds 920a884a44 Update dts_test_project.settings to work with codeship CI
https://codeship.com/documentation/databases/postgresql/#django
2016-01-19 17:51:55 +11:00
Gary Reynolds 1743b4867b Add LOGGING configuration to test project 2016-01-19 17:51:55 +11:00
Bernardo Pires 50e67c8900 Now using django's new test runner. Fixed test project and examples. 2015-01-05 15:43:40 +01:00
Bernardo Pires 845e19be9c Test project and examples now compatible with Django 1.7 2015-01-05 15:34:47 +01:00
Bernardo Pires 9a9b8a00df Added test project to enable testing with additional models and apps. This allow us to test different apps in TENANT_APPS AND SHARED_APPS. Added more tests that ensure cross schema foreign keys are possible, although the constraints are not created. 2014-12-29 00:07:45 +01:00