mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-24 20:33:11 +00:00
[Printer] Allow to disable printer in 'Preferences'
This commit is contained in:
parent
278d752b65
commit
aa6590e5b1
3 changed files with 23 additions and 2 deletions
11
printer/templates/printer/printer_disabled.html
Normal file
11
printer/templates/printer/printer_disabled.html
Normal 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 %}
|
|
@ -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.
|
||||||
|
|
|
@ -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)(
|
||||||
|
|
Loading…
Reference in a new issue