Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add banner for informate user hours and date of the maintenance #66

Closed
scwall opened this issue Jan 23, 2020 · 3 comments
Closed

Add banner for informate user hours and date of the maintenance #66

scwall opened this issue Jan 23, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@scwall
Copy link

scwall commented Jan 23, 2020

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 %}
@scwall scwall added the enhancement New feature or request label Jan 23, 2020
@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Jan 24, 2020

Hi @scwall,
thank you for this suggestion.
Maintenance-mode schedule is already in the 'todo' of this library.

Frankly my idea was to add support to it using a simple setting:

settings.MAINTENANCE_MODE_SCHEDULE = {
    'sun': {'start':'01:00', 'end':'02:00'},
    'mon': None,
    'tue': None,
    'wed': {'start':'01:00', 'end':'02:00'},
    'thu': None,
    'fri': None,
    'sat': None,
}

# or this to schedule maintenance every day:
settings.MAINTENANCE_MODE_SCHEDULE = {
    '*': {'start':'01:00', 'end':'02:00'},
}

Now, looking at your suggestion, I understand the flexibility to manage maintenance schedule using the admin and also the necessity to send an email to users to warn them about the incoming maintenance (which needs a cronjob).

Actually this library doesn't use database at all and I would prefer to keep it tiny and db free, but I also want to implement maintenance schedule in the best and flexible way...

I take some time to think better about it, in the meanwhile any other idea/suggestion will be appreciated.

@scwall
Copy link
Author

scwall commented Jan 24, 2020

Ok I understand, maybe adding an external yarml file for the hours, for don't modify settings file . Personally I will have to use a db, because I use docker (with dj cookie cutter) for the deployment of my projects. If I change the settings I will have to rebuild my image and redeploy it just to publish the time. For the use of a recurring stain: https://pypi.org/project/django-crontab/ is quite light.

example maintenance.yml:

schelude:
  - date: 14/05/2020
    start_time: 12h20
    end_time: 14h30
  - date: 14/05/2021
    start_time: 10h20
    end_time: 19h30

@fabiocaccamo
Copy link
Owner

I close this issue because it is very similar to another one, everything related to maintenance mode schedule will be discussed in #64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants