django-maintenancemode-0.11.3/0000755000076500000240000000000013447635460016424 5ustar bashustaff00000000000000django-maintenancemode-0.11.3/AUTHORS0000644000076500000240000000023313447626722017473 0ustar bashustaff00000000000000django-maintenancemode is written by Remco Wendt Feel free to contact me by mail if you have any questions, or just want to say hi.django-maintenancemode-0.11.3/LICENSE0000644000076500000240000000306013447635270017427 0ustar bashustaff00000000000000Copyright (c) 2008, Maykin Media Copyright (c) 2012, enn.io Copyright (c) 2015-2019, Basil Shubin All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the author nor the names of other contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. django-maintenancemode-0.11.3/MANIFEST.in0000644000076500000240000000015313447631302020150 0ustar bashustaff00000000000000include AUTHORS include CHANGES include LICENSE include README.rst recursive-exclude maintenancemode test* django-maintenancemode-0.11.3/PKG-INFO0000644000076500000240000002022213447635460017517 0ustar bashustaff00000000000000Metadata-Version: 1.2 Name: django-maintenancemode Version: 0.11.3 Summary: django-maintenancemode allows you to temporary shutdown your site for maintenance work Home-page: http://github.com/shanx/django-maintenancemode Author: Remco Wendt Author-email: remco@maykinmedia.nl Maintainer: Basil Shubin Maintainer-email: basil.shubin@gmail.com License: BSD License Download-URL: https://github.com/shanx/django-maintenancemode/zipball/master Description: django-maintenancemode ====================== django-maintenancemode is a middleware that allows you to temporary shutdown your site for maintenance work. Logged in users having staff credentials can still fully use the site as can users visiting the site from an IP address defined in Django's ``INTERNAL_IPS``. Authored by `Remco Wendt `_, and some great `contributors `_. .. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg :target: https://travis-ci.org/shanx/django-maintenancemode/ How it works ------------ ``maintenancemode`` works the same way as handling 404 or 500 error in Django work. It adds a ``handler503`` which you can override in your main ``urls.py`` or you can add a ``503.html`` to your templates directory. * If user is logged in and staff member, the maintenance page is not displayed. * If user's IP is in ``INTERNAL_IPS``, the maintenance page is not displayed. * To override the default view which is used if the maintenance mode is enabled you can simply define a ``handler503`` variable in your ROOT_URLCONF_, similar to how you would customize other `error handlers`_, e.g. : .. code-block:: python handler503 = 'example.views.maintenance_mode' Installation ------------ 1. Either checkout ``maintenancemode`` from GitHub, or install using pip : .. code-block:: bash pip install django-maintenancemode 2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` : .. code-block:: python INSTALLED_APPS = ( ... 'maintenancemode', ) 3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` : .. code-block:: python MIDDLEWARE_CLASSES = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenancemode.middleware.MaintenanceModeMiddleware', ) 4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file : .. code-block:: python MAINTENANCE_MODE = True # Setting this variable to ``True`` activates the middleware. or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command : .. code-block:: shell python ./manage.py maintenance Please see ``example`` application. This application is used to manually test the functionalities of this package. This also serves as a good example... You need only Django 1.4 or above to run that. It might run on older versions but that is not tested. Configuration ------------- There are various optional configuration options you can set in your ``settings.py`` .. code-block:: python # Enable / disable maintenance mode. # Default: False MAINTENANCE_MODE = True # or ``False`` and use ``maintenance`` command # Sequence of URL path regexes to exclude from the maintenance mode. # Default: () MAINTENANCE_IGNORE_URLS = ( r'^/docs/.*', r'^/contact' ) License ------- ``django-maintenancemode`` is released under the BSD license. .. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf .. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views Changes ------- 0.11.3 ~~~~~~ - Added support for django 2.x, dropped support for django < 1.11. It may still work with django 1.8, but this is no longer tested. 0.11.2 ~~~~~~ - Getting ready for Django 1.10 release. - Dropped support for Django 1.3 and older. 0.11.1 ~~~~~~ - Enable network specify in INTERNAL_IPS 0.11.0 ~~~~~~ - Added management command to set maintenance mode on/off 0.10.1 ~~~~~~ - Made sure the app runs on Django 1.8. 0.10.0 ~~~~~~ - Got rid of dependency on setuptools - Added ability to exclude specific paths from maintenance mode with the ``MAINTENANCE_IGNORE_URLS`` setting. - Use RequestContext when rending the ``503.html`` template. - Use tox for running the tests instead of buildout. - Made sure the app runs on Django 1.4. 0.9.3 ~~~~~~ - Minor documentation updates for the switch to github, expect more changes to follow soon. 0.9.2 ~~~~~~ - Fixed an issue with setuptools, thanks for reporting this ksato9700 0.9.1 ~~~~~~ - Tested django-maintenancemode with django-1.0 release (following the 1.0.X release branch) - Bundled buildout.cfg and bootstrap with the source version of the project, allowing repeatable buildout - The middleware now uses its own default config file, thanks to a patch by semente - Use INTERNAL_IPS to check for users that need access. user.is_staff will stay in place for backwards incompatibility. Thanks for the idea Joshua Works - Have setup.py sdist only distribute maintenancemode itself, no longer distribute tests and buildout stuff - Use README and CHANGES in setup.py's long_description, stolen from Jeroen's djangorecipe :) - Updated the documentation and now use pypi as the documentation source (link there from google code) 0.9 ~~~~~~ First release Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Requires: Django (>=1.4.2) django-maintenancemode-0.11.3/README.rst0000644000076500000240000000727213447626722020124 0ustar bashustaff00000000000000django-maintenancemode ====================== django-maintenancemode is a middleware that allows you to temporary shutdown your site for maintenance work. Logged in users having staff credentials can still fully use the site as can users visiting the site from an IP address defined in Django's ``INTERNAL_IPS``. Authored by `Remco Wendt `_, and some great `contributors `_. .. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg :target: https://travis-ci.org/shanx/django-maintenancemode/ How it works ------------ ``maintenancemode`` works the same way as handling 404 or 500 error in Django work. It adds a ``handler503`` which you can override in your main ``urls.py`` or you can add a ``503.html`` to your templates directory. * If user is logged in and staff member, the maintenance page is not displayed. * If user's IP is in ``INTERNAL_IPS``, the maintenance page is not displayed. * To override the default view which is used if the maintenance mode is enabled you can simply define a ``handler503`` variable in your ROOT_URLCONF_, similar to how you would customize other `error handlers`_, e.g. : .. code-block:: python handler503 = 'example.views.maintenance_mode' Installation ------------ 1. Either checkout ``maintenancemode`` from GitHub, or install using pip : .. code-block:: bash pip install django-maintenancemode 2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` : .. code-block:: python INSTALLED_APPS = ( ... 'maintenancemode', ) 3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` : .. code-block:: python MIDDLEWARE_CLASSES = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenancemode.middleware.MaintenanceModeMiddleware', ) 4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file : .. code-block:: python MAINTENANCE_MODE = True # Setting this variable to ``True`` activates the middleware. or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command : .. code-block:: shell python ./manage.py maintenance Please see ``example`` application. This application is used to manually test the functionalities of this package. This also serves as a good example... You need only Django 1.4 or above to run that. It might run on older versions but that is not tested. Configuration ------------- There are various optional configuration options you can set in your ``settings.py`` .. code-block:: python # Enable / disable maintenance mode. # Default: False MAINTENANCE_MODE = True # or ``False`` and use ``maintenance`` command # Sequence of URL path regexes to exclude from the maintenance mode. # Default: () MAINTENANCE_IGNORE_URLS = ( r'^/docs/.*', r'^/contact' ) License ------- ``django-maintenancemode`` is released under the BSD license. .. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf .. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views django-maintenancemode-0.11.3/django_maintenancemode.egg-info/0000755000076500000240000000000013447635460024567 5ustar bashustaff00000000000000django-maintenancemode-0.11.3/django_maintenancemode.egg-info/PKG-INFO0000644000076500000240000002022213447635460025662 0ustar bashustaff00000000000000Metadata-Version: 1.2 Name: django-maintenancemode Version: 0.11.3 Summary: django-maintenancemode allows you to temporary shutdown your site for maintenance work Home-page: http://github.com/shanx/django-maintenancemode Author: Remco Wendt Author-email: remco@maykinmedia.nl Maintainer: Basil Shubin Maintainer-email: basil.shubin@gmail.com License: BSD License Download-URL: https://github.com/shanx/django-maintenancemode/zipball/master Description: django-maintenancemode ====================== django-maintenancemode is a middleware that allows you to temporary shutdown your site for maintenance work. Logged in users having staff credentials can still fully use the site as can users visiting the site from an IP address defined in Django's ``INTERNAL_IPS``. Authored by `Remco Wendt `_, and some great `contributors `_. .. image:: https://img.shields.io/pypi/v/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/pypi/dm/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/github/license/shanx/django-maintenancemode.svg :target: https://pypi.python.org/pypi/django-maintenancemode/ .. image:: https://img.shields.io/travis/shanx/django-maintenancemode.svg :target: https://travis-ci.org/shanx/django-maintenancemode/ How it works ------------ ``maintenancemode`` works the same way as handling 404 or 500 error in Django work. It adds a ``handler503`` which you can override in your main ``urls.py`` or you can add a ``503.html`` to your templates directory. * If user is logged in and staff member, the maintenance page is not displayed. * If user's IP is in ``INTERNAL_IPS``, the maintenance page is not displayed. * To override the default view which is used if the maintenance mode is enabled you can simply define a ``handler503`` variable in your ROOT_URLCONF_, similar to how you would customize other `error handlers`_, e.g. : .. code-block:: python handler503 = 'example.views.maintenance_mode' Installation ------------ 1. Either checkout ``maintenancemode`` from GitHub, or install using pip : .. code-block:: bash pip install django-maintenancemode 2. Add ``maintenancemode`` to your ``INSTALLED_APPS`` : .. code-block:: python INSTALLED_APPS = ( ... 'maintenancemode', ) 3. Add ``MaintenanceModeMiddleware`` to ``MIDDLEWARE_CLASSES``, make sure it comes after ``AuthenticationMiddleware`` : .. code-block:: python MIDDLEWARE_CLASSES = ( ... 'django.contrib.auth.middleware.AuthenticationMiddleware', 'maintenancemode.middleware.MaintenanceModeMiddleware', ) 4. Add variable called ``MAINTENANCE_MODE`` in your project's ``settings.py`` file : .. code-block:: python MAINTENANCE_MODE = True # Setting this variable to ``True`` activates the middleware. or set ``MAINTENANCE_MODE`` to ``False`` and use ``maintenance`` command : .. code-block:: shell python ./manage.py maintenance Please see ``example`` application. This application is used to manually test the functionalities of this package. This also serves as a good example... You need only Django 1.4 or above to run that. It might run on older versions but that is not tested. Configuration ------------- There are various optional configuration options you can set in your ``settings.py`` .. code-block:: python # Enable / disable maintenance mode. # Default: False MAINTENANCE_MODE = True # or ``False`` and use ``maintenance`` command # Sequence of URL path regexes to exclude from the maintenance mode. # Default: () MAINTENANCE_IGNORE_URLS = ( r'^/docs/.*', r'^/contact' ) License ------- ``django-maintenancemode`` is released under the BSD license. .. _ROOT_URLCONF: https://docs.djangoproject.com/en/dev/ref/settings/#root-urlconf .. _`error handlers`: https://docs.djangoproject.com/en/dev/topics/http/views/#customizing-error-views Changes ------- 0.11.3 ~~~~~~ - Added support for django 2.x, dropped support for django < 1.11. It may still work with django 1.8, but this is no longer tested. 0.11.2 ~~~~~~ - Getting ready for Django 1.10 release. - Dropped support for Django 1.3 and older. 0.11.1 ~~~~~~ - Enable network specify in INTERNAL_IPS 0.11.0 ~~~~~~ - Added management command to set maintenance mode on/off 0.10.1 ~~~~~~ - Made sure the app runs on Django 1.8. 0.10.0 ~~~~~~ - Got rid of dependency on setuptools - Added ability to exclude specific paths from maintenance mode with the ``MAINTENANCE_IGNORE_URLS`` setting. - Use RequestContext when rending the ``503.html`` template. - Use tox for running the tests instead of buildout. - Made sure the app runs on Django 1.4. 0.9.3 ~~~~~~ - Minor documentation updates for the switch to github, expect more changes to follow soon. 0.9.2 ~~~~~~ - Fixed an issue with setuptools, thanks for reporting this ksato9700 0.9.1 ~~~~~~ - Tested django-maintenancemode with django-1.0 release (following the 1.0.X release branch) - Bundled buildout.cfg and bootstrap with the source version of the project, allowing repeatable buildout - The middleware now uses its own default config file, thanks to a patch by semente - Use INTERNAL_IPS to check for users that need access. user.is_staff will stay in place for backwards incompatibility. Thanks for the idea Joshua Works - Have setup.py sdist only distribute maintenancemode itself, no longer distribute tests and buildout stuff - Use README and CHANGES in setup.py's long_description, stolen from Jeroen's djangorecipe :) - Updated the documentation and now use pypi as the documentation source (link there from google code) 0.9 ~~~~~~ First release Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Framework :: Django Classifier: Intended Audience :: Developers Classifier: Intended Audience :: System Administrators Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Internet :: WWW/HTTP Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Requires: Django (>=1.4.2) django-maintenancemode-0.11.3/django_maintenancemode.egg-info/SOURCES.txt0000644000076500000240000000121313447635460026450 0ustar bashustaff00000000000000AUTHORS LICENSE MANIFEST.in README.rst setup.cfg setup.py django_maintenancemode.egg-info/PKG-INFO django_maintenancemode.egg-info/SOURCES.txt django_maintenancemode.egg-info/dependency_links.txt django_maintenancemode.egg-info/not-zip-safe django_maintenancemode.egg-info/requires.txt django_maintenancemode.egg-info/top_level.txt maintenancemode/__init__.py maintenancemode/conf.py maintenancemode/http.py maintenancemode/middleware.py maintenancemode/models.py maintenancemode/utils.py maintenancemode/views.py maintenancemode/management/__init__.py maintenancemode/management/commands/__init__.py maintenancemode/management/commands/maintenance.pydjango-maintenancemode-0.11.3/django_maintenancemode.egg-info/dependency_links.txt0000644000076500000240000000000113447635460030635 0ustar bashustaff00000000000000 django-maintenancemode-0.11.3/django_maintenancemode.egg-info/not-zip-safe0000644000076500000240000000000113447630310027002 0ustar bashustaff00000000000000 django-maintenancemode-0.11.3/django_maintenancemode.egg-info/requires.txt0000644000076500000240000000002313447635460027162 0ustar bashustaff00000000000000django-appconf ipy django-maintenancemode-0.11.3/django_maintenancemode.egg-info/top_level.txt0000644000076500000240000000002013447635460027311 0ustar bashustaff00000000000000maintenancemode django-maintenancemode-0.11.3/maintenancemode/0000755000076500000240000000000013447635460021553 5ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/__init__.py0000644000076500000240000000002713447635305023661 0ustar bashustaff00000000000000__version__ = '0.11.3' django-maintenancemode-0.11.3/maintenancemode/conf.py0000644000076500000240000000062113447626722023052 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- import os from django.conf import settings # pylint: disable=W0611 from appconf import AppConf class MaintenanceSettings(AppConf): IGNORE_URLS = () LOCKFILE_PATH = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'maintenance.lock') MODE = False class Meta: prefix = 'maintenance' holder = 'maintenancemode.conf.settings' django-maintenancemode-0.11.3/maintenancemode/http.py0000644000076500000240000000021413447626722023102 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- from django.http import HttpResponse class HttpResponseTemporaryUnavailable(HttpResponse): status_code = 503 django-maintenancemode-0.11.3/maintenancemode/management/0000755000076500000240000000000013447635460023667 5ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/management/__init__.py0000644000076500000240000000000013447626722025767 0ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/management/commands/0000755000076500000240000000000013447635460025470 5ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/management/commands/__init__.py0000644000076500000240000000000013447626722027570 0ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/management/commands/maintenance.py0000644000076500000240000000220213447626722030321 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- from django.core.management.base import BaseCommand, CommandError from maintenancemode import utils as maintenance class Command(BaseCommand): opts = ('on', 'off', 'activate', 'deactivate') def add_arguments(self, parser): parser.add_argument('command', nargs='?', help='|'.join(self.opts)) def handle(self, *args, **options): command = options.get('command', args[0] if len(args) > 0 else None) verbosity = int(options.get('verbosity')) if command is not None: if command.lower() in ('on', 'activate'): maintenance.activate() if verbosity > 0: self.stdout.write( "Maintenance mode was activated succesfully") elif command.lower() in ('off', 'deactivate'): maintenance.deactivate() if verbosity > 0: self.stdout.write( "Maintenance mode was deactivated succesfully") if command not in self.opts: raise CommandError( "Allowed commands are: %s" % '|'.join(self.opts)) django-maintenancemode-0.11.3/maintenancemode/middleware.py0000644000076500000240000000362513447635270024247 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- import re from django.conf import urls from django.urls import get_resolver from django.utils.deprecation import MiddlewareMixin from . import utils as maintenance from .conf import settings urls.handler503 = 'maintenancemode.views.temporary_unavailable' urls.__all__.append('handler503') IGNORE_URLS = tuple([re.compile(u) for u in settings.MAINTENANCE_IGNORE_URLS]) class MaintenanceModeMiddleware(MiddlewareMixin): def process_request(self, request): # Allow access if middleware is not activated allow_staff = getattr(settings, 'MAINTENANCE_ALLOW_STAFF', True) allow_superuser = getattr(settings, 'MAINTENANCE_ALLOW_SUPERUSER', True) if not (settings.MAINTENANCE_MODE or maintenance.status()): return None INTERNAL_IPS = maintenance.IPList(settings.INTERNAL_IPS) # Preferentially check HTTP_X_FORWARDED_FOR b/c a proxy # server might have obscured REMOTE_ADDR for ip in request.META.get('HTTP_X_FORWARDED_FOR', '').split(','): if ip.strip() in INTERNAL_IPS: return None # Allow access if remote ip is in INTERNAL_IPS if request.META.get('REMOTE_ADDR') in INTERNAL_IPS: return None # Allow access if the user doing the request is logged in and a # staff member. if hasattr(request, 'user'): if request.user.is_staff and allow_staff: return None if request.user.is_superuser and allow_superuser: return None # Check if a path is explicitly excluded from maintenance mode for url in IGNORE_URLS: if url.match(request.path_info): return None # Otherwise show the user the 503 page resolver = get_resolver() callback, param_dict = resolver.resolve_error_handler('503') return callback(request, **param_dict) django-maintenancemode-0.11.3/maintenancemode/models.py0000644000076500000240000000000013447626722023377 0ustar bashustaff00000000000000django-maintenancemode-0.11.3/maintenancemode/utils.py0000644000076500000240000000162113447626722023266 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- import os from .conf import settings class IPList(list): """Stolen from https://djangosnippets.org/snippets/1362/""" def __init__(self, ips): try: from IPy import IP for ip in ips: self.append(IP(ip)) except ImportError: pass def __contains__(self, ip): try: for net in self: if ip in net: return True except: pass return False def activate(): try: open(settings.MAINTENANCE_LOCKFILE_PATH, 'ab', 0).close() except OSError: pass # shit happens def deactivate(): if os.path.isfile(settings.MAINTENANCE_LOCKFILE_PATH): os.remove(settings.MAINTENANCE_LOCKFILE_PATH) def status(): return settings.MAINTENANCE_MODE or os.path.isfile( settings.MAINTENANCE_LOCKFILE_PATH) django-maintenancemode-0.11.3/maintenancemode/views.py0000644000076500000240000000172113447626722023264 0ustar bashustaff00000000000000# -*- coding: utf-8 -*- import django if django.get_version() >= '1.8': from django.template.loader import render_to_string else: from django.template import loader, RequestContext def render_to_string(template_name, context=None, request=None): context_instance = RequestContext(request) if request else None return loader.render_to_string( template_name, context, context_instance) from . import http def temporary_unavailable(request, template_name='503.html'): """ Default 503 handler, which looks for the requested URL in the redirects table, redirects if found, and displays 404 page if not redirected. Templates: ``503.html`` Context: request_path The path of the requested URL (e.g., '/app/pages/bad_page/') """ context = { 'request_path': request.path, } return http.HttpResponseTemporaryUnavailable( render_to_string(template_name, context)) django-maintenancemode-0.11.3/setup.cfg0000644000076500000240000000007513447635460020247 0ustar bashustaff00000000000000[wheel] universal = 1 [egg_info] tag_build = tag_date = 0 django-maintenancemode-0.11.3/setup.py0000644000076500000240000000444213447635305020140 0ustar bashustaff00000000000000#!/usr/bin/env python import os import re import sys import codecs from setuptools import setup, find_packages def read(*parts): file_path = os.path.join(os.path.dirname(__file__), *parts) return codecs.open(file_path, encoding='utf-8').read() def find_version(*parts): version_file = read(*parts) version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M) if version_match: return str(version_match.group(1)) raise RuntimeError("Unable to find version string.") setup( name='django-maintenancemode', version=find_version('maintenancemode', '__init__.py'), license='BSD License', install_requires=[ 'django-appconf', 'ipy', ], requires=[ 'Django (>=1.4.2)', ], description="django-maintenancemode allows you to temporary shutdown your site for maintenance work", long_description=read('README.rst') + '\n\n' + read('CHANGES.rst'), author='Remco Wendt', author_email='remco@maykinmedia.nl', maintainer='Basil Shubin', maintainer_email='basil.shubin@gmail.com', url='http://github.com/shanx/django-maintenancemode', download_url='https://github.com/shanx/django-maintenancemode/zipball/master', packages=find_packages(exclude=('example*', '*.tests*')), include_package_data=True, tests_require=[ 'django-setuptest', ], test_suite='setuptest.setuptest.SetupTestSuite', zip_safe=False, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Framework :: Django', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', 'Programming Language :: Python', 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Topic :: Internet :: WWW/HTTP', 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', ], )