-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenums.py
71 lines (50 loc) · 1.76 KB
/
enums.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from enum import Enum
class EnumTuple(Enum):
@classmethod
def as_tuple(cls):
"""Used for making enums available as choices in Forms"""
return tuple((x.name, x.value) for x in cls)
@classmethod
def as_tuple_with_all(cls):
setup = [(x.name, x.value) for x in cls]
setup.append(('all', 'All'))
return tuple(x for x in setup)
@classmethod
def str_list(cls):
# List all enum values with a space after them, then trim the
# trailing whitespace
spaced_names = ''.join(x.value + ' ' for x in cls).strip()
SPACE = ' '
COMMA_SPACE = ', '
# put commas in the appropriate locations
return spaced_names.replace(SPACE, COMMA_SPACE)
class CustomerType(EnumTuple):
individual = 'Individual'
business = 'Business'
class AccountType(EnumTuple):
businessChecking = 'Business Checking'
checking = 'Checking'
savings = 'Saving'
class ECheckType(EnumTuple):
PPD = 'PPD'
WEB = 'WEB'
CCD = 'CCD'
class PaymentProfileType(EnumTuple):
"""Type of Payment Profile"""
bankAccount = 'Bank Account'
creditCard = 'Credit Card'
class ServerMode(EnumTuple):
"""
Use this enum within your Django settings file
Create a variable SERVER_MODE in settings
Example: SERVER_MODE = ServerMode.development.value
ServerMode is frequently used with the authorizenet SDK to
configure the posting URL of a controller. See customer_profile
for examples
"""
development = 'Development' # testing on your local machine
staging = 'Staging' # a semi-private server intended for testing
production = 'Production' # client facting software
class ValidationMode(EnumTuple):
testMode = 'Test Mode'
liveMode = 'Live Mode'