-
Notifications
You must be signed in to change notification settings - Fork 17
Add support for adjustments #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11,15 +11,15 @@ from ocflib.misc.shell import green | |||||
| from ocflib.misc.shell import red | ||||||
| from ocflib.misc.shell import yellow | ||||||
| from ocflib.misc.whoami import current_user | ||||||
| from ocflib.printing.quota import add_refund | ||||||
| from ocflib.printing.quota import add_adjustment | ||||||
| from ocflib.printing.quota import get_connection | ||||||
| from ocflib.printing.quota import get_quota | ||||||
| from ocflib.printing.quota import Refund | ||||||
| from ocflib.printing.quota import Payload | ||||||
|
|
||||||
|
|
||||||
| def staff_creds(): | ||||||
| """Return dictionary of staff creds, if we can read them.""" | ||||||
| return json.load(open('/etc/ocfprinting.json')) | ||||||
| return json.load(open('/etc/ocfprinting-dev.json')) | ||||||
|
|
||||||
|
|
||||||
| def view(args): | ||||||
|
|
@@ -43,36 +43,37 @@ def view(args): | |||||
| print(bold(red("Group accounts can't print. Sorry!"))) | ||||||
|
|
||||||
|
|
||||||
| def refund(args): | ||||||
| refund = Refund( | ||||||
| def adjust(args, type): | ||||||
| payload = Payload( | ||||||
| user=args.user, | ||||||
| time=datetime.now(), | ||||||
| pages=args.pages, | ||||||
| action=type, | ||||||
|
||||||
| staffer=current_user(), | ||||||
| reason=args.reason, | ||||||
| ) | ||||||
| prompt = bold('Refund {} pages to {}? [yN] '.format(refund.pages, refund.user)) | ||||||
|
|
||||||
| stringtype = 'Refund' if type == 'refund' else 'Forward' | ||||||
| prompt = bold(stringtype + ' {} pages to {}? [yN] '.format(payload.pages, payload.user)) | ||||||
|
||||||
| prompt = bold(stringtype + ' {} pages to {}? [yN] '.format(payload.pages, payload.user)) | |
| prompt = bold('{} {} pages to {}? [yN] '.format(stringtype, payload.pages, payload.user)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forward probably in itself is the reason, I don't know if this needs to be a required field. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still fine, and it's a database constraint anyways
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the reason being clear, I think this would be important to include due to the human aspect of it. A person who is issuing the forward request will need to think twice before actually increasing the daily quota for a particular user.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of an if statement here, which makes the subcommand logic harder to understand, you should put the same if statement in the adjust command (which has access to args and therefore args.command).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix this for prod
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch