Skip to content
This repository
Browse code

Adding Voice Auction workflows. Removing FC-specific stuff. Defaults …

…file.
  • Loading branch information...
commit 5fdb414145c5689ddadb08dc74d515fc7ee6784f 1 parent 4eb2dc3
Chris Cogdon authored
9 artshow/cashier.py
@@ -16,7 +16,8 @@
16 16 from django.conf import settings
17 17 from django.core.exceptions import ValidationError
18 18 from decimal import Decimal
19   -import logging, datetime
  19 +import logging
  20 +import datetime
20 21 import invoicegen
21 22 logger = logging.getLogger ( __name__ )
22 23 from django.contrib import messages
@@ -168,10 +169,11 @@ class PrintInvoiceForm ( forms.Form ):
168 169 def do_print_invoices ( request, invoice_id, copy_names ):
169 170 try:
170 171 invoicegen.print_invoices ( [invoice_id], copy_names, to_printer=True )
171   - except invoicegen.PrintingError:
  172 + except invoicegen.PrintingError, x:
172 173 messages.error ( request, "Printing failed. Please ask administrator to consult error log" )
  174 + logger.error ( "Printing failed with exception: %s", x )
173 175 else:
174   - messages.info ( request, "Invoice has been sent to the printer" )
  176 + messages.info ( request, "Invoice %s has been sent to the printer" % invoice_id )
175 177
176 178
177 179 @permission_required ( 'artshow.add_invoice' )
@@ -188,7 +190,6 @@ def print_invoice ( request, invoice_id ):
188 190 return_to = form.cleaned_data['return_to']
189 191 if not return_to:
190 192 return_to = "artshow.views.index"
191   - messages.info ( request, "Invoice %s has been sent to the printer." % invoice.id )
192 193 return redirect ( return_to )
193 194
194 195 messages.error ( request, "Print Invoice request is invalid" )
51 artshow/default_settings.py
... ... @@ -0,0 +1,51 @@
  1 +"""List of all Artshow Jockey settings. Those that can have reasonable
  2 +defaults have their defaults set here. Those that must be overridden
  3 +have been set to the _UNCONFIGURED object, which will be checked during
  4 +startup of the artshow application. _DISABLED is to leave a non-critical
  5 +feature disabled"""
  6 +
  7 +_UNCONFIGURED = object()
  8 +_DISABLED = object()
  9 +
  10 +# These are the "PaymentType" IDs used by various procedures
  11 +ARTSHOW_SPACE_FEE_PK = 3
  12 +ARTSHOW_PAYMENT_SENT_PK = 5
  13 +ARTSHOW_COMMISSION_PK = 6
  14 +ARTSHOW_SALES_PK = 7
  15 +
  16 +# name of the model handling people, in "app.model" format
  17 +ARTSHOW_PERSON_CLASS = "peeps.Person"
  18 +
  19 +# name of the module used to print forms, in python path format
  20 +ARTSHOW_PREPRINT_MODULE = "artshow.preprint_dummy"
  21 +
  22 +ARTSHOW_SHOW_NAME = "Generic Art Show"
  23 +ARTSHOW_SHOW_YEAR = "1999"
  24 +ARTSHOW_TAX_RATE = "0.10" # Used to initialise a Decimal object
  25 +ARTSHOW_TAX_DESCRIPTION = "Fictitious County 10% Tax"
  26 +ARTSHOW_EMAIL_SENDER = "Generic Art Show <artshow@example.com>"
  27 +ARTSHOW_COMMISSION = "0.1" # Used to initialise a Decimal object
  28 +ARTSHOW_INVOICE_PREFIX = "1999-" # Prefixed on all printed invoices
  29 +ARTSHOW_EMAIL_FOOTER = """\
  30 +--
  31 +Random J Hacker
  32 +Generic Art Show Lead.
  33 +artshow@example.com - http://www.example.com/artshow
  34 +"""
  35 +ARTSHOW_CHEQUE_THANK_YOU = "Thank you for exhibiting at Generic Art Show"
  36 +ARTSHOW_BLANK_BID_SHEET = "artshow/files/BidSheet.pdf"
  37 +ARTSHOW_BLANK_CONTROL_FORM = "artshow/files/ControlForm.pdf"
  38 +
  39 +# The in-build form printing code uses this font to print piece barcodes.
  40 +# Specify as a 2-tuple: ( "font name", "font path" )
  41 +ARTSHOW_BARCODE_FONT = ('Free3of9', 'artshow/files/free3of9/FREE3OF9.TTF')
  42 +ARTSHOW_SCANNER_DEVICE = "/dev/ttyUSB0"
  43 +
  44 +# Set this to "True" to prevent all standard logins from making edits to
  45 +# piece details. Best used when this database is no longer the "master".
  46 +ARTSHOW_SHUT_USER_EDITS = False
  47 +
  48 +# Command to send a text file to the printer. Eg: enscript
  49 +ARTSHOW_PRINT_COMMAND = _DISABLED
  50 +ARTSHOW_AUTOPRINT_INVOICE = [ "CUSTOMER COPY", "MERCHANT COPY", "PICK LIST" ]
  51 +ARTSHOW_MONEY_PRECISION = 2
BIN  artshow/files/FCBidSheetSingle.pdf
Binary file not shown
BIN  artshow/files/FCNFSSheetSingle.pdf
Binary file not shown
BIN  artshow/files/PrecisionID C39 04.ttf
Binary file not shown
BIN  artshow/files/blank_bid_sheet.pdf
Binary file not shown
5,368 artshow/files/blank_control_form.pdf
0 additions, 5,368 deletions not shown
BIN  artshow/files/free3of9/FRE3OF9X.TTF
Binary file not shown
BIN  artshow/files/free3of9/FREE3OF9.TTF
Binary file not shown
71 artshow/files/free3of9/FREE3OF9.TXT
... ... @@ -0,0 +1,71 @@
  1 +-----BEGIN PGP SIGNED MESSAGE-----
  2 +Hash: SHA1
  3 +
  4 +Font: Free 3 of 9 Barcode (free3of9.ttf)
  5 +Created By: Matthew Welch
  6 +E-Mail: daffy-duck@worldnet.att.net
  7 +Web Address: http://home.att.net/~daffy-duck
  8 + (PGP public key available here)
  9 +
  10 +Free 3 of 9, like all of my fonts, is free. You can use it for most
  11 +personal or business uses you'd like, and I ask for no money. I
  12 +would, however, like to hear from you. If you use my fonts for
  13 +something please send me a postcard or e-mail letting me know how
  14 +you used it. Send me a copy if you can or let me know where I can
  15 +find your work.
  16 +
  17 +You may use this font for graphical or printed work, but you may not
  18 +sell it or include it in a collection of fonts (on CD or otherwise)
  19 +being sold. You can redistribute this font as long as you charge
  20 +nothing to receive it. If you redistribute it include this text file
  21 +with it as is (without modifications).
  22 +
  23 +If you use this font for commercial purposes please credit me in
  24 +at least some little way.
  25 +
  26 +About the font:
  27 +
  28 +Can you believe there are people who would charge you for a barcode
  29 +font like this? It took very little time to make this so I thought
  30 +I'd donate it to the world. It is suitable for scanning even at
  31 +fairly small point sizes (with a laser printer). I have tested
  32 +printed copies of this font with a couple different scanners and it
  33 +worked perfectly.
  34 +
  35 +This is 3 of 9 (sometimes called "code 39"), a widely used barcode
  36 +standard that includes capital letters, numbers, and several symbols.
  37 +This is not the barcode for UPC's (universal price codes) found on
  38 +products at the store. However, most kinds of barcode scanners will
  39 +recognize 3 of 9 just fine.
  40 +
  41 +To create a valid 3 of 9 barcode you have to begin and end it with
  42 +a special character. Scanners look for this character to know
  43 +where to start and stop reading the barcode. It is represented in
  44 +this font with the '*' character. So, to create a barcode for the
  45 +text "ABC123" you have to type out "*ABC123*". Note that barcode
  46 +readers will not include the *'s in the text they return. They will
  47 +just give you the "ABC123".
  48 +
  49 +Two versions of 3 of 9 are included. The font called "Free 3 of 9" is
  50 +the basic 3 of 9 standard. It includes letters and these symbols: $ %
  51 ++ - . and /. The font called "Free 3 of 9 Extended" covers the
  52 +extended 3 of 9 standard. It includes all the ASCII characters.
  53 +
  54 +Special note to MS Word users: There is a default setting in Word
  55 +that changes text surrounded by *'s into bold text. This setting must
  56 +be disabled for these fonts to work, otherwise the * characters that
  57 +are necessary for the barcode to scan properly will be lost and the
  58 +thickness of the bars will be altered. I have a copy of Word '97. The
  59 +setting might be found in a different place in other versions but
  60 +this is how I disabled it. From the Tools menu open the AutoCorrect
  61 +dialog box. On the AutoFormat tab uncheck the box for "*Bold* and
  62 +_underline_"
  63 +
  64 +
  65 +-----BEGIN PGP SIGNATURE-----
  66 +Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
  67 +
  68 +iQA/AwUBOmY8/uEM8BJ4ZA+2EQLSDgCgqHT1WtBW34v7JAQr4+1zCzUaeGgAn2uu
  69 +stjL0d7RVR5C5p2zpks371e9
  70 +=jqNv
  71 +-----END PGP SIGNATURE-----
6 artshow/invoicegen.py
@@ -7,6 +7,7 @@
7 7 import sys
8 8 import subprocess
9 9 from django.conf import settings
  10 +from default_settings import _DISABLED as SETTING_DISABLED
10 11 from StringIO import StringIO
11 12 import re
12 13 from logging import getLogger
@@ -100,7 +101,7 @@ def write_header ():
100 101 def write_footer ():
101 102 for i in range( max_lines_per_page - lines_this_page ):
102 103 buffer.write (invoice_spacer)
103   - buffer.write ( non_last_invoice_footer % { 'copystr': copy_name.center(60) } )
  104 + buffer.write ( invoice_footer % { 'copystr': copy_name.center(60) } )
104 105
105 106 def write_item ( name_wrapped, price ):
106 107 for l in name_wrapped[:-1]:
@@ -182,6 +183,9 @@ def print_invoices ( invoices, copy_names, to_printer=False ):
182 183 if not sbuf.getvalue():
183 184 logger.error ( "nothing to generate" )
184 185 elif to_printer:
  186 + if settings.ARTSHOW_PRINT_COMMAND is SETTING_DISABLED:
  187 + logger.error ( "Cannot print invoice. ARTSHOW_PRINT_COMMAND is DISABLED" )
  188 + raise PrintingError ( "Printing is DISABLED in configuration" )
185 189 p = subprocess.Popen ( settings.ARTSHOW_PRINT_COMMAND, stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True )
186 190 output, error = p.communicate ( sbuf.getvalue() )
187 191 if output:
24 artshow/templates/artshow/auction_bids.html
... ... @@ -0,0 +1,24 @@
  1 +{% extends "artshow/base_generic.html" %}
  2 +{% block content %}
  3 +<h1>Enter Voice Auction Bids &mdash; {% if adult %}Adult{% else %}General{% endif %}</h1>
  4 +<form method="post">
  5 +{% csrf_token %}{{ formset.management_form }}
  6 +<table>
  7 +<tr><th rowspan="2">Code</th><th rowspan="2">Artist</th><th rowspan="2">Title</th><th colspan="2">Sheet</th><th rowspan="2">Action</th><th colspan="2">New</th></tr>
  8 +<tr><th>Bidder</th><th>Amount</th><th>Bidder</th><th>Amount</th></tr>
  9 +{% for form in formset %}
  10 +<tr>
  11 + <td>{{ form.piece }}{{ form.initial.piece.code }}</td>
  12 + <td>{{ form.initial.piece.artist.artistname }}</td>
  13 + <td>{{ form.initial.piece.name }}</td>
  14 + <td>{{ form.initial.piece.top_bid.bidder.bidder_ids|join:", " }}</td>
  15 + <td>{{ form.initial.piece.top_bid.amount }}</td>
  16 + <td>{{ form.id }}{{ form.action }}</td>
  17 + <td>{{ form.bidder }}</td>
  18 + <td>{{ form.amount }}</td>
  19 +</tr>
  20 +{% endfor %}
  21 +</table>
  22 +<input type="submit" value="Submit" />
  23 +</form>
  24 +{% endblock %}
4 artshow/templates/artshow/dataentry.html
@@ -6,8 +6,8 @@
6 6 <li><a href="{% url artshow.addbidder.bulk_add %}">Add Bidders</a></li>
7 7 <li>Auction Ordering
8 8 <ul>
9   - <li><a href="{% url artshow.auction_ordering.order_auction adult='y' %}">Adult</a></li>
10   - <li><a href="{% url artshow.auction_ordering.order_auction adult='n' %}">General</a></li>
  9 + <li><a href="{% url artshow.voice_auction.order_auction adult='y' %}">Adult</a></li>
  10 + <li><a href="{% url artshow.voice_auction.order_auction adult='n' %}">General</a></li>
11 11 </ul>
12 12 </li>
13 13
1  artshow/urls.py
@@ -9,6 +9,7 @@
9 9 (r'^entry/$', 'views.dataentry' ),
10 10 (r'^entry/bidders/$', 'addbidder.bulk_add' ),
11 11 (r'^entry/bids/$', 'addbidder.bid_bulk_add' ),
  12 + (r'^entry/auction_bids/(?P<adult>[yn])/$', 'voice_auction.auction_bids' ),
12 13 (r'^entry/order_auction/(?P<adult>[yn])/$', 'voice_auction.order_auction' ),
13 14 #(r'^entry/bids/location/(?P<location>[^/]+)/$', 'bidentry.add_bids' ),
14 15 (r'^reports/$', 'reports.index' ),
51 artshow/voice_auction.py
... ... @@ -1,6 +1,6 @@
1   -from artshow.models import Piece
  1 +from artshow.models import Piece, Bid
2 2 from django import forms
3   -from django.forms.models import modelformset_factory
  3 +from django.forms.models import modelformset_factory, formset_factory
4 4 from django.contrib.auth.decorators import permission_required
5 5 from django.shortcuts import render, redirect
6 6 from django.contrib import messages
@@ -36,3 +36,50 @@ def order_auction ( request, adult ):
36 36
37 37
38 38 return render ( request, "artshow/order_auction.html", {'formset':formset, 'adult':adult} )
  39 +
  40 +
  41 +
  42 +class AuctionBidForm ( forms.ModelForm ):
  43 +
  44 + ACTION_CHOICES = (
  45 + ( 0, "Defer" ),
  46 + ( 1, "To Bid Sheet" ),
  47 + ( 2, "Outbid" ),
  48 + )
  49 +
  50 + action = forms.ChoiceField ( choices=ACTION_CHOICES, initial=0, widget=forms.RadioSelect )
  51 +
  52 + class Meta:
  53 + model = Bid
  54 + fields = ( "action", "piece", "bidder", "amount" )
  55 + widgets = {
  56 + 'bidder': forms.TextInput,
  57 + 'piece': forms.HiddenInput,
  58 + }
  59 +
  60 +
  61 +AuctionBidFormSet = formset_factory ( AuctionBidForm, extra=0 )
  62 +
  63 +
  64 +def auction_bids ( request, adult ):
  65 +
  66 + adult = adult=="y"
  67 + pieces = Piece.objects.filter ( voice_auction=True, adult=adult ).order_by ( "order", "artist", "pieceid" )
  68 +
  69 + initial_data = [ {'piece':p} for p in pieces ]
  70 + logger.debug ( "initial_data %s", initial_data )
  71 +
  72 + if request.method == "POST":
  73 + pass
  74 + else:
  75 + formset = AuctionBidFormSet ( initial=initial_data )
  76 +
  77 + for index, f in enumerate(formset):
  78 + logger.debug ( "form %d %s", index, dir(f) )
  79 +
  80 + return render ( request, "artshow/auction_bids.html", { 'formset':formset, 'adult':adult } )
  81 +
  82 +
  83 +
  84 +
  85 +
9 artshowjockey/common_settings.py
@@ -168,12 +168,3 @@
168 168 AJAX_SELECT_INLINES = 'inline'
169 169
170 170 LOGIN_REDIRECT_URL = "/"
171   -
172   -ARTSHOW_SPACE_FEE_PK = 3
173   -ARTSHOW_PAYMENT_SENT_PK = 5
174   -ARTSHOW_COMMISSION_PK = 6
175   -ARTSHOW_SALES_PK = 7
176   -
177   -ARTSHOW_PERSON_CLASS = "peeps.Person"
178   -
179   -ARTSHOW_PREPRINT_MODULE = "artshow.preprint_dummy"
3  local_settings.py.example
... ... @@ -1,4 +1,5 @@
1 1 from artshowjockey.common_settings import *
  2 +from artshow.default_settings import *
2 3
3 4 # This is, probably, the minimum set of settings attributes that
4 5 # should be specified for your installation.
@@ -35,7 +36,7 @@ Generic Art Show Lead.
35 36 artshow@example.com - http://www.example.com/artshow
36 37 """
37 38 ARTSHOW_CHEQUE_THANK_YOU = "Thank you for exhibiting at Generic Art Show"
38   -ARTSHOW_PRINT_COMMAND = "enscript -P Samsung -B -L 66 -f Courier-Bold10"
  39 +ARTSHOW_PRINT_COMMAND = "enscript -P Samsung -B -L 66 -f Courier-Bold10 -q"
39 40 ARTSHOW_AUTOPRINT_INVOICE = [ "CUSTOMER COPY", "MERCHANT COPY", "PICK LIST" ]
40 41 ARTSHOW_BLANK_BID_SHEET = "artshow/files/blank_bid_sheet.pdf"
41 42 ARTSHOW_SCANNER_DEVICE = "/dev/ttyUSB0"

0 comments on commit 5fdb414

Please sign in to comment.
Something went wrong with that request. Please try again.