You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

#! /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, net.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
self._to_go = False ## TODO session state, instead?
def run(self, user_name):
net.buy_item(self.item.id, self._to_go, user_name)
def label(self):
return self.item.name
def is_to_go(self):
return self._to_go
def set_to_go(self, to_go):
self._to_go = to_go
def deposit(self):
return self.item.deposit
class ToGoCommand(Command):
def __init__(self, buy_command):
self.buy_command = buy_command
self._difference = -buy_command.item.deposit
def run(self, *args, **kvargs):
pass
def label(self):
return '%s - Pfand' % self.buy_command.label()