diff --git a/printer/templates/printer/printer_disabled.html b/printer/templates/printer/printer_disabled.html new file mode 100644 index 00000000..43975e9a --- /dev/null +++ b/printer/templates/printer/printer_disabled.html @@ -0,0 +1,11 @@ +{% extends "printer/sidebar.html" %} +{% load staticfiles %} + +{% load i18n %} +{% load bootstrap3 %} + +{% block title %}Printing interface{% endblock %} +{% block content %} +{% csrf_token %} +

{% trans "Sorry, the printer currently experiences fatal issues..." %}

+{% endblock %} diff --git a/printer/utils.py b/printer/utils.py index dafce878..6892ca5c 100644 --- a/printer/utils.py +++ b/printer/utils.py @@ -5,13 +5,21 @@ import os from django.template.loader import get_template from django.core.mail import EmailMessage -from preferences.models import GeneralOption, AssoOption +from preferences.models import GeneralOption, AssoOption, OptionalPrinter from .models import Digicode import datetime +def printer_enabled(): + """ + Check whether the printer is enabled or not + """ + settings, created = OptionalPrinter.objects.get_or_create() + return settings.Printer_enabled + + def pdfinfo(file_path): """ Uses pdfinfo to extract the PDF meta information. diff --git a/printer/views.py b/printer/views.py index a7a75c4c..0b795da6 100644 --- a/printer/views.py +++ b/printer/views.py @@ -18,7 +18,7 @@ from users.models import User from re2o.base import re2o_paginator from . import settings -from .utils import pdfinfo, send_mail_printer +from .utils import pdfinfo, send_mail_printer, printer_enabled from .models import ( JobWithOptions, @@ -48,6 +48,8 @@ def new_job(request): """ View to create a new printing job """ + if not printer_enabled(): + return render(request, 'printer/printer_disabled.html', {}) print_operation = PrintOperation(user=request.user) job_formset = formset_factory(JobWithOptionsForm)(