client-barcode: Add command classes
This commit is contained in:
parent
68ba629966
commit
a4c37ce813
|
@ -6,6 +6,7 @@
|
|||
|
||||
from __future__ import print_function
|
||||
import freitagslib.network as net
|
||||
from freitagslib.commands import BuyCommand, DepositCommand
|
||||
|
||||
import sys
|
||||
import decimal
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2011 Sebastian Pipping <sebastian@pipping.org>
|
||||
# Licensed under GPL v3 or later
|
||||
|
||||
import freitagslib.network as net
|
||||
|
||||
|
||||
class Command(object):
|
||||
def difference(self):
|
||||
return self._difference
|
||||
|
||||
|
||||
class DepositCommand(Command):
|
||||
def __init__(self, amount):
|
||||
self._difference = amount
|
||||
|
||||
def run(self, user_name):
|
||||
net.deposit(self._difference, DEPOSIT_CASH, user_name)
|
||||
|
||||
def label(self):
|
||||
return '%.2f Euro einzahlen' % self._difference
|
||||
|
||||
|
||||
class BuyCommand(Command):
|
||||
def __init__(self, item):
|
||||
self.item = item
|
||||
self._difference = item.price
|
||||
|
||||
def run(self, user_name):
|
||||
net.buy_item(self.item.id, user_name)
|
||||
|
||||
def label(self):
|
||||
return self.item.name
|
Loading…
Reference in New Issue