Code Monkey home page Code Monkey logo

django-maintenance-mode's Introduction

๐Ÿ‘‹ Hello!

I'm Fabio Caccamo.

I'm a passionate, self-taught full-stack developer based in Torino, Italy. ๐Ÿ‡ฎ๐Ÿ‡น ๐ŸคŒ

I work mainly with ๐Ÿ Python, ๐Ÿฆ„ Django and Vue.js.

I love Open Source, I published and actively maintain many ๐Ÿ“ฆ libraries.

View all my libraries

๐Ÿฆ„ django-admin-interface
๐Ÿ“ฑ FCUUID
๐Ÿ python-benedict
๐Ÿ“ฑ FCFileManager
๐Ÿฆ„ django-treenode
๐Ÿฆ„ django-colorfield
๐Ÿฆ„ django-extra-settings
๐Ÿฆ„ django-maintenance-mode
๐Ÿ“ฑ FCCurrentLocationGeocoder
๐Ÿ python-fsutil
๐Ÿ“ฑ FCIPAddressGeocoder
๐Ÿฆ„ django-freeze
๐Ÿ python-codicefiscale
๐Ÿฆ„ django-redirects
๐Ÿ python-fontbro
๐Ÿ’ป utils.js
:octocat: create-matrix-action
๐Ÿ’ป tabbo.js

django-maintenance-mode's People

Contributors

ade555 avatar alexdlaird avatar andrewpwade avatar cocoatomo avatar dependabot[bot] avatar epicserve avatar fabiocaccamo avatar fallen avatar github-actions[bot] avatar haidaram avatar matmair avatar natureshadow avatar ondrejit avatar paduszyk avatar pbx avatar pre-commit-ci[bot] avatar samizdis avatar synapticarbors avatar ziima avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-maintenance-mode's Issues

Add a view decorator

For a complex applications, such as we have, the split of views available and unavailable during the maintenance can be non-trivial. Decorator which marks views turned off during the maintenance would allow fine-tuning of the application maintenance.

Version 0.13.2 isn't installing currently

When trying to install 0.13.2, I'm getting the following:

$ pip install django-maintenance-mode==0.13.2
Collecting django-maintenance-mode==0.13.2
  ERROR: Could not find a version that satisfies the requirement django-maintenance-mode==0.13.2 (from versions: 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.5.0, 0.5.1, 0.5.2, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.5, 0.6.6, 0.6.7, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.9.0, 0.9.1, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 0.13.1)
ERROR: No matching distribution found for django-maintenance-mode==0.13.2

state file content value is not 0|1

This issue caused by empty line at the end of the file maintance_mode_state.txt which can be added by pre-commit hooks or the IDE

python3.8/site-packages/maintenance_mode/backends.py", line 22, in get_value
    raise ValueError('state file content value is not 0|1')

Solution add strip strip()

class LocalFileBackend(AbstractStateBackend):

    def get_value(self):
        value = read_file(settings.MAINTENANCE_MODE_STATE_FILE_PATH, '0')
        if value.strip() not in ['0', '1']:
            raise ValueError('state file content value is not 0|1')
        value = bool(int(value))
        return value

Running tests with maintenance mode on

Issue: I found that running tests while maintenance mode was on failed a lot of tests because all views responded with 503.

Expected behaviour: I would expect that global maintenance mode does not affect test environment and tests run in isolation.

Example use case: Running tests in production to check whether it is deployed correctly before opening the site to public use.

Suggestion: Perhaps make it configurable with a MAINTENANCE_MODE_IGNORE_TEST which would disable maintenance mode behaviour while running tests?

Add banner for informate user hours and date of the maintenance

Hello, I integrated a maintenance signalling system for a project, quickly. I thought it would be a good idea to have this system in django-maintenance-mode. Which allows you to signal users of maintenance hours. I am in the process of following up for an email sending with the scheduled maintenance to all users of the company.
(i'm use django solo : https://github.com/lazybird/django-solo for singleton model) but now several hours could be scheduled
models :

class MaintenanceSchedule(SingletonModel):
    day = models.DateField('Day of the maintenance', help_text='Day of the maintenance',default=timezone.now)
    start_time = models.TimeField('Starting time', help_text='Starting time',default=timezone.now)
    end_time = models.TimeField('Final time', help_text='Final time',default=timezone.now)
    active = models.BooleanField(default=False)

tags_maintenance:

@register.simple_tag
def maintenance_schedule():
    maintenance = MaintenanceSchedule.get_solo()
    return maintenance

and base.html

  {% maintenance_schedule as maintenance_schelude %}
    {% if maintenance_schelude.active %}
    <div style="padding-bottom: 80px;width:100%; height: 50px;position: fixed;bottom: 0;background-color: #ffcc00" id="maintenance-banner">
      <p style="font-size: 22px;" class="text-center"> <b>{% blocktrans %}The site will be under maintenance : {% endblocktrans %}</b>{{ maintenance_schelude.day }}{% blocktrans %} between{% endblocktrans %} {{ maintenance_schelude.start_time }} {% blocktrans %}and{% endblocktrans %} {{ maintenance_schelude.end_time }}  </p>
    </div>
    {% endif %}

MAINTENANCE_MODE_IGNORE_IP_ADDRESSES does not work.

How does "else:
client_ip_address = get_client_ip_address_func(request)_" (1st one) work?

 if settings.MAINTENANCE_MODE_IGNORE_IP_ADDRESSES:
        if settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS:
            try:
                get_client_ip_address_func = import_string(
                    settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS)
            except ImportError:
                raise ImproperlyConfigured(
                    'settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS '
                    'is not a valid function path.')
            else:
                client_ip_address = get_client_ip_address_func(request)_
        else:
            client_ip_address = get_client_ip_address(request)

        for ip_address in settings.MAINTENANCE_MODE_IGNORE_IP_ADDRESSES:

            ip_address_re = re.compile(ip_address)

            if ip_address_re.match(client_ip_address):
                return False

Update Installation Instructions

Please update the installation instructions to include: "Add 'maintenance_mode.context_processors.maintenance_mode' to context_processors". I didn't do this and it prevented the maintenance_mode template tag from working.

MAINTENANCE_MODE_STATE_FILE_PATH could be configurable

currently MAINTENANCE_MODE_STATE_FILE_PATH points to directory of file which on some setups is not writable and django-maintenance-mode is not usable on those setups. I think this option could be configurable via settings, just like the other settings of django-maintenance-mode.

Default context is missing in templates when maintenance mode is on in Django 1.9

I can't access some variables in context in templates when maintenance mode is on. For example the variables requestand maintenance_mode are not available and I think some others variables also. I have to add them by myself by using MAINTENANCE_MODE_TEMPLATE_CONTEXT.

I think the problem is with this commit 4c2a6e5 when you added django 1.10 compatibility. I know there is a warning that says The context_instance argument of render_to_string is deprecated... but you can you use the render function as the documentation says https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/#render-to-response.

I can make a pull request if you want.

IGNORE_URLS setting not working

I ran pip install django-maintenance-mode

Added 'maintenance_mode', to settings.INSTALLED_APPS

And 'maintenance_mode.middleware.MaintenanceModeMiddleware', to settings.MIDDLEWARE

Along with these settings to settings.py:

MAINTENANCE_MODE = True
MAINTENANCE_MODE_IGNORE_SUPERUSER = True
MAINTENANCE_MODE_IGNORE_URLS = (r'^admin/login/$')

But there is no redirect to a 503 error page. DEBUG = True and I'm running the server locally

EDIT: If I remove the MAINTENANCE_MODE_IGNORE_URLS setting the 503 redirect DOES work, but as soon as I set IGNORE_URLS the redirect stops working.

FIX: Change (r'^admin/login/$') to (r'^/admin/login/$',)

Default state file location

By documentation, the default location of the state file is next to the settings.py, which I interpret as the used DJANGO_SETTINGS_MODULE file. Instead it is created in maintenance_mode directory, which may be in /usr/share, /usr/lib/ or other unexpected locations.

Ignore urls

Hi

I want be able to use in 503.html template a images from static directory.

I use in settings.py:

MAINTENANCE_MODE_IGNORE_URLS = (r'^/static/images/$',)

but it doesnt work. I need help...

Thanks

Add changelog

As the project continues, a changelog is needed to publish which changes happened in which version.

Configurable HTTP status code

I'm running an application on AWS Elastic Beanstalk which monitors the health of requests. HTTP 5xx is treated as an error by the monitoring processes and this doesn't seem configurable.

One solution is to make maintenance mode return 200. I have a patch that adds a MAINTENANCE_MODE_STATUS_CODE setting with a default 503.

Would you accept a PR with this patch as it might be useful for others?

NoReverseMatch exception if maintenance_mode.urls was not added to urlpatterns

Based on the readme, maintenance_mode.urls can be ignored if won't superusers are able to set maintenance_mode using urls. However, the exception throw as below:

Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'maintenance_mode_off' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 495

Check the middleware.py

    url_off = reverse('maintenance_mode_off')

    try:
        resolve(url_off)

        if url_off == request.path_info:
            return None

    except NoReverseMatch:
        #maintenance_mode.urls not added
        pass

the invoking revere should be embraced in try-except block. Could you please double check the logic? Thanks.

No longer compatible with Django <1.8 since release 0.3.3

Seems the status parameter got added to the render_to_response method in Django 1.8, so the README.md of django-maintenance-mode will need to be updated.

On Django 1.7, I currently get

web      โ”‚ ERROR 2016-10-06 19:04:31,614 Internal Server Error: /
web      โ”‚ Traceback (most recent call last):
web      โ”‚   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 87, in get_response
web      โ”‚     response = middleware_method(request)
web      โ”‚   File "/usr/local/lib/python2.7/dist-packages/maintenance_mode/middleware.py", line 57, in process_request
web      โ”‚     response = render_to_response(settings.MAINTENANCE_MODE_TEMPLATE, self.get_request_context(request), context_instance=RequestContext(request), content_type='text/html', status=503)
web      โ”‚   File "/usr/local/lib/python2.7/dist-packages/django/shortcuts.py", line 25, in render_to_response
web      โ”‚     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
web      โ”‚ TypeError: render_to_string() got an unexpected keyword argument 'status'

Add no cache headers to response

Django has a decorator called never_cache that ensures that requests are, umm, never cached. Caching is complicated, but I think this library should use this functionality to ensure that the maintenance mode is not cached. This way, when maintenance mode is disabled, the site will return quickly.

I just rewrote the middleware for my own project, and you can see how I implemented this there (it's a small, simple change).

Thanks for laying this groundwork. Great little middleware.

Is it possible to have this not redirect?

Effectively I just need something that would let me know whether the site's under maintenance or not and allow my base.html to display a toast message. So I really only want to use {% if maintenance_mode %}. Is it currently possible to change its behavior to not redirect to a maintenance page?

'Settings' object has no attribute 'MAINTENANCE_MODE'

I've got a system in MAINTENANCE_MODE to perform a change to the database server. It's an RDS instance on AWS and I've changed it's type.

While the instance was being modified I was seeing the 503 response at first, but then that became 'Settings' object has no attribute 'MAINTENANCE_MODE'.

Given the fact the app sets the default value to None django clearly wasn't running quite right while this happened, but it's a point in time that I have enabled MAINTENANCE_MODE and the system is undergoing changes so odd behaviour/side effects might be expected. Therefore could the app default to MAINTENANCE_MODE = True similar to;

    def get_maintenance_mode():
        """
        Get maintenance_mode state from state file.
        """
        try:
            # If maintenance mode is defined in settings, it has priority.
            if settings.MAINTENANCE_MODE is not None:
                return settings.MAINTENANCE_MODE
        except AttributeError:
            return True

        backend = get_maintenance_mode_backend()
        return backend.get_value()

Full stacktrace;

AttributeError: 'Settings' object has no attribute 'MAINTENANCE_MODE'
  File "django/core/handlers/exception.py", line 42, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 244, in _legacy_get_response
    response = middleware_method(request)
  File "newrelic/hooks/framework_django.py", line 220, in wrapper
    return wrapped(*args, **kwargs)
  File "maintenance_mode/middleware.py", line 19, in process_request
    if need_maintenance_response(request):
  File "maintenance_mode/http.py", line 93, in need_maintenance_response
    if not get_maintenance_mode():
  File "maintenance_mode/core.py", line 53, in get_maintenance_mode
    if settings.MAINTENANCE_MODE is not None:
  File "django/conf/__init__.py", line 54, in __getattr__
    return getattr(self._wrapped, name)

Redirect on /maintenance-mode/on

The /maintenance-mode/on and /maintenance-mode/off urls should redirect back to the referring page instead of redirecting back to the main page in super admin.

Disable emailing 503 errors to admins while maintenance mode is enabled

Python version
3.8

Django version
3.1.4

Package version
0.15.1

I think it would be nice to have a setting like this:

# Don't send 503 error emails to admins while maintenance mode is active
MAINTENANCE_MODE_DISABLE_503_EMAILS = True

By default, Django sends emails to site admins for HTTP errors >= 500. It would be nice if this could be turned off while maintenance mode is on, since these errors would be expected at that time.

FileNotFoundError on MAINTENANCE_MODE_STATE_FILE_PATH

When I don't specify MAINTENANCE_MODE_STATE_FILE_PATH in settings.py and try to turn off maintenance mode, it results in:
FileNotFoundError: [Errno 2] No such file or directory: '/project/settings/maintenance_mode_state.txt'

In the docs, it's said that:
By default, a file named maintenance_mode_state.txt will be created in the maintenance_mode directory, and that we can customize the state file path in case the default one is not writable.

For me, that directory was writable, but still maintenance_mode_state.txt file got created in the same folder of my settings.py file. And the above error is thrown.

To fix the issue on my end, I had to explicitly specify
MAINTENANCE_MODE_STATE_FILE_PATH = 'maintenance_mode_state.txt' in my settings.py
and add maintenance_mode_state.txt to gitignore.

Drop support for old Django versions

Some of the versions are not supported for quite some time. I think it's time to dump those, as support for old Django versions requires extra time which may be used elsewhere.

All tox environments fail on coverage

When I run tox, all environments fail with an error Can't combine arc data with line data.

It's using coverage==4.5.1, which seems to be the source of the error.

Exception in django-ipware integration

Hello. Awesome work with this plugin. Very straight-forward and very useful. Was especially happy to see you can integrate it with django-ipware.

Unfortunately, though, I can't get that part to work. No matter what I set MAINTENANCE_MODE_IGNORE_IP_ADDRESSES to be, I receive the following exception:

Environment:


Request Method: GET
Request URL: http://localhost:8000/

Django Version: 2.0.5
Python Version: 3.5.3
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'django.contrib.sites',
 'django.contrib.redirects',
 'django.forms',
 'versatileimagefield',
 'storages',
 'webpack_loader',
 'taggit',
 'redacted.custom.apps',)
Installed Middleware:
['bugsnag.django.middleware.BugsnagMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware',
 'ifs.middleware.StaffOnlyMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
 'maintenance_mode.middleware.MaintenanceModeMiddleware']



Traceback:

File "/Users/Dan/.local/share/virtualenvs/ifs-I-ZwDr_o/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/Users/Dan/.local/share/virtualenvs/ifs-I-ZwDr_o/lib/python3.5/site-packages/django/utils/deprecation.py" in __call__
  93.             response = self.process_request(request)

File "/Users/Dan/.local/share/virtualenvs/ifs-I-ZwDr_o/lib/python3.5/site-packages/maintenance_mode/middleware.py" in process_request
  19.         if need_maintenance_response(request):

File "/Users/Dan/.local/share/virtualenvs/ifs-I-ZwDr_o/lib/python3.5/site-packages/maintenance_mode/http.py" in need_maintenance_response
  158.             if ip_address_re.match(client_ip_address):

Exception Type: TypeError at /
Exception Value: expected string or bytes-like object

And here are my settings:

# Maintenance Mode
# ------------------------------------------------------------------------------
# See: https://github.com/fabiocaccamo/django-maintenance-mode
DJANGO_APPS += ('maintenance_mode',)
MIDDLEWARE += ['maintenance_mode.middleware.MaintenanceModeMiddleware']
MAINTENANCE_MODE = env.bool('MAINTENANCE_MODE', default='True')
MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS = 'ipware.ip2.get_client_ip'
MAINTENANCE_MODE_IGNORE_STAFF = True
MAINTENANCE_MODE_IGNORE_SUPERUSER = True
MAINTENANCE_MODE_IGNORE_URLS = ('/login/', '/logout/', '/admin/', '/users/redirect/')
MAINTENANCE_MODE_IGNORE_IP_ADDRESSES = ('127.0.0.1',)

Way to add subnets on ip addresses to ignore

Python version
3.8

Django version
1.11

Package version
0.14.0

Current behavior (bug description)
Is there a way to add the subnets to the ip addresses to ignore when maintenance mode is active?

to something like this? because i tried this way and it's not working for me:

MAINTENANCE_MODE_IGNORE_URLS = ('192.168.0.0/32',)

Expected behavior
192.168.0.0/32

Control maintenance mode via DB

(feature request)

Using a text file on the host doesn't work for django installations that distribute requests across multiple hosts. It seems like more of a detriment of the library to avoid using tables for this control than a benefit. Are the maintainers philosophically against this, or was it just a more expensive implementation than the sentinel file approach?

Reason and Service Timeline

Hey.
Tell me, do you have such an opportunity to enable and disable the mode from the admin panel? And add a description + time to it

Python 3

Are there plans to make this compatible with Python 3?

Allow passing context to 503 view

Currently we cannot pass any context to the view rendered by the middleware as it is set to {}. It would be nice to have a way to pass my own parameters to it, e.g., planned update finish time

FileNotFoundError with default settings

Python version
3.6.9

Django version
2.2.19

Package version
0.15.1

Current behavior (bug description)
My DJANGO_SETTINGS_MODULE is set to "pytition.settings.maconfig"
I let all django maintenance mode settings be default
I get a FileNotFoundError at / exception directly on my home page.
By using Debug=True I can see the values of the settings, the following one is incorrect:

MAINTENANCE_MODE_STATE_FILE_PATH = '/pytition/settings/maintenance_mode_state.txt'

Expected behavior
I would expect to have the following default setting:

MAINTENANCE_MODE_STATE_FILE_PATH = '/home/pytitiondemo/www/pytition/pytition/pytition/settings/maintenance_mode_state.txt' which is the correct absolute path to the file.

Fix proposal

I think the issue comes from https://github.com/fabiocaccamo/django-maintenance-mode/blob/master/maintenance_mode/settings.py#L56
After some debugging I can see that in my example settings_dir = './pytition/settings' which is correct.
But the following line uses os.path.abspath( os.path.join(os.sep, settings_dir, settings.MAINTENANCE_MODE_STATE_FILE_NAME))
But os.path.join(os.sep, settings_dir, settings.MAINTENANCE_MODE_STATE_FILE_NAME)) value is '/./pytition/settings/maintenance_mode_state.txt'

So giving os.path.abspath() an argument beginning with '/' does not generate the correct absolute path.

I wonder why os.sep was put as first argument of os.path.join in the first place? Is it mandatory for some other setup? MS Windows?

I think the fix would be to remove os.sep

django 1.9 comparable

Please update your URL's to django 1.9 comparable

-- coding: utf-8 --

from django.conf.urls import url
from . import views

urlpatterns = [
url(r'^off/$', views.maintenance_mode_off, name='maintenance_mode_off'),
url(r'^on/$', views.maintenance_mode_on, name='maintenance_mode_on'),
]

Verbose turn on interactive mode

Verbosity in level 3 makes the maintenance_mode command behave interactively, which is not expected. The interactive option should be separate.

MAINTENANCE_MODE_GET_TEMPLATE_CONTEXT

they is an error on the doc naming convection
on the doc its says MAINTENANCE_MODE_GET_TEMPLATE_CONTEXT but on the settings its getting MAINTENANCE_MODE_TEMPLATE_CONTEXT

MAINTENANCE_MODE_GET_TEMPLATE_CONTEXT = getattr(settings, 'MAINTENANCE_MODE_TEMPLATE_CONTEXT', None)

404 Not Found Error When SCRIPT_NAME Defined

Python version
3.8

Django version
3.1

Package version
0.15.1

Current behavior (bug description)
When tried to enable the maintenance mode with a defined SCRIPT_NAME variable (under uWSGI), the app goes into the maintenance mode. However, returns 404 errors for every possible route including the maintenance-mode/off/ route. Thus, effectively prevents disabling the maintenance mode from the URL.

For example, assume that running under a SCRIPT_NAME /pclink-test. After enabling the maintenance mode, all routes start to give a 404 Not Found error with a message like The current path, pclink-test/maintenance-mode/off/, didn't match any of these.

Expected behavior
With a defined SCRIPT_NAME parameter in uWSGI, the application should gracefully turn off the maintenance mode when entered a URL like http://example.com/<script-name>/maintenance-mode/off/ and shows the proper 503.html template instead of 404 Not Found errors.

If there some custom processor is using django request, it returns an error.

My application is using django's request in context processor. but if i get into maintenance mode then error occurs.

The error follows 'NoneType' object has no attribute 'kwargs'.
it means i refer request's kwargs in context processor but if i turn on the maintenance mode, it can't find request. i solve this problem with 'if' sentence but it has to improve i think.

thanks for reading and this product. i'm using this very in a useful way.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar

Maintenance mode cannot be turned off

If I comment out MAINTENANCE_MODE = True, I get this exception:

Exception Value: | [Errno 2] No such file or directory: '/territory/maintenance_mode_state.txt'
-- | --
/usr/local/lib/python3.5/dist-packages/maintenance_mode/io.py in write_file, line 26

Not sure why it's trying to write to some file in the root of the filesystem. If I add MAINTENANCE_MODE_STATE_FILE_PATH = '/tmp/maintenance_mode_state.txt', this works as a temporary workaround.

Banner for all templates to warn users when maintenance will be

It would be awesome if there was a way to create something like this:
https://github-images.s3.amazonaws.com/enterprise/2.19/assets/images/enterprise/maintenance/maintenance-scheduled.png

to warn users ahead of time when maintenance mode will be scheduled.

It would be nice to have a custom warning message and make the message css customizable like where it should be on your website like below the navbar or by the footer or somewhere else. I like at the bottom similar to a cookie banner but that is just me that the user could close/dismiss. Please use vanilla javascript and not jquery for this if it is needed.

Maybe make a page/setting to specify when the warning will be triggered and how long it will go for and automatically place the website into maintenance mode when the scheduled time happens.

Add time window

The business want to be able to specify a time window (start time and end time) in which the website turns automatically the website on and off. What would be the best method? Maybe a new setting which defines a function which is called in need_maintenance_response?
Would you accept a pull request for this?

Fund with Polar

django.conf.urls.patterns() is deprecated and will be removed in Django 1.10

I had this warning when I installed the package.

You can simply use a list of django.conf.urls.url() instances in `urls.py:

urlpatterns = [
    url(r'^off/$', views.maintenance_mode_off, name='maintenance_mode_off'),
    url(r'^on/$', views.maintenance_mode_on, name='maintenance_mode_on'),
]

Full waring message : RemovedInDjango110Warning: django.conf.urls.patterns() is deprecated and will be removed in Django 1.10. Update your urlpatterns to be a list of django.conf.urls.url() instances instead. url(r'^on/$', views.maintenance_mode_on, name='maintenance_mode_on'),

change breaks compatibility and broke my tests

Hi! Very nice project.

You made a recent change that broke my tests. For some reasons, they were not failing before, and MAINTENANCE_MODE was False.

Now, while testing, the MAINTENANCE_MODE is False and it picks up an IOError along the line, which makes the test fail.

This is most likely happening here: https://github.com/fabiocaccamo/django-maintenance-mode/blob/master/maintenance_mode/io.py#L12-L13

The function in core.py tries to convert this to an int, and fails. This is the traceback

ERROR: test_home (sistema.tests.test_context_processors.RegistroContextProcessorTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/utils.py", line 196, in inner
    return test_func(*args, **kwargs)
  File "/builds/geoadmin/geoadmin/src/sistema/tests/test_context_processors.py", line 21, in test_home
    resposta = client.get(reverse('hotsite:home'))
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 500, in get
    **extra)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 303, in get
    return self.generic('GET', path, secure=secure, **r)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 379, in generic
    return self.request(**r)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/test/client.py", line 466, in request
    six.reraise(*exc_info)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 108, in get_response
    response = middleware_method(request)
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/maintenance_mode/middleware.py", line 31, in process_request
    if settings.MAINTENANCE_MODE or core.get_maintenance_mode():
  File "/builds/geoadmin/geoadmin/env/local/lib/python2.7/site-packages/maintenance_mode/core.py", line 9, in get_maintenance_mode
    value = bool(int(value))
TypeError: int() argument must be a string or a number, not 'NoneType'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.