From 198f594766e60957a043ed792ad56382d3f82247 Mon Sep 17 00:00:00 2001 From: Brandon King Date: Wed, 19 Aug 2009 22:58:28 +0000 Subject: [PATCH] Admin compatibility for changes in Django >= 1.1. --- htsworkflow/frontend/bcmagic/utils.py | 26 +++++++++++++++++++++++++ htsworkflow/frontend/inventory/views.py | 1 + htsworkflow/frontend/urls.py | 16 +++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/htsworkflow/frontend/bcmagic/utils.py b/htsworkflow/frontend/bcmagic/utils.py index 5ee81a9..ee35268 100644 --- a/htsworkflow/frontend/bcmagic/utils.py +++ b/htsworkflow/frontend/bcmagic/utils.py @@ -1,4 +1,30 @@ +from htsworkflow.frontend import settings +import ftplib +import socket +import StringIO + + +def print_zpl(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST): + """ + Sends zpl_text to printer + """ + ftp = ftplib.FTP(host=host, user='blank', passwd='') + ftp.login() + ftp.storlines("STOR printme.txt", StringIO.StringIO(zpl_text)) + ftp.quit() + + +def print_zpl_socket(zpl_text, host=settings.BCPRINTER_PRINTER1_HOST, port=settings.BCPRINTER_PRINTER1_PORT): + """ + Sends zpl_text to printer via a socket + """ + s = socket.socket() + # PORT 9100 is default for Zebra tabletop/desktop printers + # PORT 6101 is default for Zebra mobile printers + s.connect((host, port)) + s.sendall(zpl_text) + s.close() def report_error(message): """ diff --git a/htsworkflow/frontend/inventory/views.py b/htsworkflow/frontend/inventory/views.py index 027c4aa..cb2fca6 100644 --- a/htsworkflow/frontend/inventory/views.py +++ b/htsworkflow/frontend/inventory/views.py @@ -27,6 +27,7 @@ INVENTORY_CONTEXT_DEFAULTS = { } INVENTORY_ITEM_PRINT_DEFAULTS = { + 'Hard Drive': 'inventory/hard_drive_shell.zpl', 'default': 'inventory/default.zpl', 'host': settings.BCPRINTER_PRINTER1_HOST } diff --git a/htsworkflow/frontend/urls.py b/htsworkflow/frontend/urls.py index abd8cd7..73a0a14 100644 --- a/htsworkflow/frontend/urls.py +++ b/htsworkflow/frontend/urls.py @@ -1,5 +1,6 @@ from django.conf.urls.defaults import * from django.contrib import admin +import django admin.autodiscover() # Databrowser: @@ -10,6 +11,7 @@ admin.autodiscover() from htsworkflow.frontend import settings + urlpatterns = patterns('', ('^accounts/login/$', 'django.contrib.auth.views.login'), ('^accounts/logout/$', 'django.contrib.auth.views.logout'), @@ -19,8 +21,8 @@ urlpatterns = patterns('', ('^accounts/profile/$', 'htsworkflow.frontend.samples.views.user_profile'), # Base: (r'^eland_config/', include('htsworkflow.frontend.eland_config.urls')), - # Admin: - (r'^admin/(.*)', admin.site.root), + ### MOVED Admin from here ### + #(r'^admin/(.*)', admin.site.root), # Experiments: (r'^experiments/', include('htsworkflow.frontend.experiments.urls')), # AnalysTrack: @@ -51,6 +53,16 @@ urlpatterns = patterns('', #(r'^databrowse/(.*)', databrowse.site.root) ) +# Allow admin +if django.VERSION >= (1, 1, 0, 'final', 0): + urlpatterns = patterns('', + (r'^admin/', include(admin.site.urls)), + ) +else: + urlpatterns = patterns('', + (r'^admin/(.*)', admin.site.root), + ) + if settings.DEBUG: urlpatterns += patterns('', (r'^static/(?P.*)$', 'django.views.static.serve', -- 2.30.2