8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-28 15:42:25 +00:00

[Printer] Allow to disable printer in 'Preferences'

This commit is contained in:
Maxime Bombar 2018-11-17 13:26:22 +01:00 committed by root
parent 278d752b65
commit aa6590e5b1
3 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,11 @@
{% extends "printer/sidebar.html" %}
{% load staticfiles %}
{% load i18n %}
{% load bootstrap3 %}
{% block title %}Printing interface{% endblock %}
{% block content %}
{% csrf_token %}
<h3>{% trans "Sorry, the printer currently experiences fatal issues..." %}</h3>
{% endblock %}

View file

@ -5,13 +5,21 @@ import os
from django.template.loader import get_template from django.template.loader import get_template
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
from preferences.models import GeneralOption, AssoOption from preferences.models import GeneralOption, AssoOption, OptionalPrinter
from .models import Digicode from .models import Digicode
import datetime 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): def pdfinfo(file_path):
""" """
Uses pdfinfo to extract the PDF meta information. Uses pdfinfo to extract the PDF meta information.

View file

@ -18,7 +18,7 @@ from users.models import User
from re2o.base import re2o_paginator from re2o.base import re2o_paginator
from . import settings from . import settings
from .utils import pdfinfo, send_mail_printer from .utils import pdfinfo, send_mail_printer, printer_enabled
from .models import ( from .models import (
JobWithOptions, JobWithOptions,
@ -48,6 +48,8 @@ def new_job(request):
""" """
View to create a new printing job View to create a new printing job
""" """
if not printer_enabled():
return render(request, 'printer/printer_disabled.html', {})
print_operation = PrintOperation(user=request.user) print_operation = PrintOperation(user=request.user)
job_formset = formset_factory(JobWithOptionsForm)( job_formset = formset_factory(JobWithOptionsForm)(