2012-08-07 18:12:50 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "grant credit to a user"
|
|
|
|
args = "<username> <amount> <action>"
|
|
|
|
|
|
|
|
def handle(self, username, amount, action="credit", *args, **kwargs):
|
|
|
|
if action=="debit":
|
|
|
|
amount=-int(amount)
|
|
|
|
else:
|
|
|
|
amount= int(amount)
|
|
|
|
user = User.objects.get(username=username)
|
|
|
|
user.credit.add_to_balance(amount)
|
2013-12-13 20:15:35 +00:00
|
|
|
print "%s now has a balance of %s gift credits" % (username, user.credit.balance)
|
2012-08-07 18:12:50 +00:00
|
|
|
|