Need a way to start and stop users from creating new jobs

Hello,

I am creating an application that allows users to submit jobs. I want to be able to have an admin function that prevents users from submitting a new job and puts up a site-wide warning with a message like ‘not currently accepting jobs’. In a perfect world, an admin could log in and have a form that will allow for the site to either be accepting or not accepting new jobs. If not accepting jobs, the admin can select the text the warning banner will display at the top of each page.

I was thinking of putting a global variable in settings called ACCEPTING_JOBS that, when false, displays a banner in the base.html template and hides the option to submit a new job in the job_create.html template. However, I have read that changing the settings file while the site is running is not best practice.

Any suggestions? Thanks in advance!

Hello,

I remember using Django package that allowed defining settings that would be then accessible in admin to change and could be accessed in views, templates which would be great for this. But I cannot think of the name and my googling did not find it :frowning: Hopefully someone else knows the name

1 Like

You might be thinking of https://github.com/jazzband/django-constance which was going to be my answer :wink:It works really well and should do what you want.

I would start with the database backend as outlined in the docs here: https://django-constance.readthedocs.io/en/latest/backends.html?highlight=databasebackend#database

That was a stumbling point for me, since the default is to use Redis, which I don’t need in most of my side projects.

2 Likes

Thanks everyone! I will try out django-constance. Thank you!

–Update: I have installed django-constance and it is exactly what I was looking for. So cool. Thanks!!!

1 Like