76 lines
1.8 KiB
Python
76 lines
1.8 KiB
Python
from django.conf import settings
|
|
|
|
TEACHER_KEY = 'teacher'
|
|
STUDENT_KEY = 'student'
|
|
MYSKILLBOX_PLATFORM = 'myskillbox'
|
|
MYKV_PLATFORM = 'mykv'
|
|
|
|
MYSKILLBOX_LICENSES = {
|
|
"978-3-0355-1397-4": {
|
|
'edition': STUDENT_KEY,
|
|
'duration': 4 * 365,
|
|
'name': 'Student 4 years',
|
|
'platform': MYSKILLBOX_PLATFORM,
|
|
'default': True
|
|
},
|
|
"978-3-0355-1860-3": {
|
|
'edition': STUDENT_KEY,
|
|
'duration': 365,
|
|
'name': 'Student 1 year',
|
|
'platform': MYSKILLBOX_PLATFORM
|
|
},
|
|
"978-3-0355-1862-7": {
|
|
'edition': STUDENT_KEY,
|
|
'duration': 30,
|
|
'name': 'Student test 1 month',
|
|
'platform': MYSKILLBOX_PLATFORM
|
|
},
|
|
"978-3-0355-1861-0": {
|
|
'edition': TEACHER_KEY,
|
|
'duration': 30,
|
|
'name': 'Teacher test 1 month',
|
|
'platform': MYSKILLBOX_PLATFORM
|
|
},
|
|
"978-3-0355-1823-8": {
|
|
'edition': TEACHER_KEY,
|
|
'duration': 365,
|
|
'name': 'Teacher 1 year',
|
|
'platform': MYSKILLBOX_PLATFORM
|
|
},
|
|
'978-3-0355-2189-4': {
|
|
'edition': STUDENT_KEY,
|
|
'duration': 30,
|
|
'name': 'Student test 1 month',
|
|
'platform': MYKV_PLATFORM,
|
|
'default': True
|
|
},
|
|
'978-3-0355-2188-7': {
|
|
'edition': TEACHER_KEY,
|
|
'duration': 30,
|
|
'name': 'Student test 1 month',
|
|
'platform': MYKV_PLATFORM
|
|
}
|
|
}
|
|
|
|
|
|
def get_license_dict():
|
|
return {
|
|
k: v for k, v in MYSKILLBOX_LICENSES.items() if v.get('platform') == settings.PLATFORM
|
|
}
|
|
|
|
|
|
def get_valid_isbns():
|
|
return list(get_license_dict().keys())
|
|
|
|
|
|
def is_myskillbox_product(isbn):
|
|
return isbn in get_valid_isbns()
|
|
|
|
|
|
def get_default_isbn():
|
|
defaults = {
|
|
k: v for k, v in get_license_dict().items() if v.get('default', False)
|
|
}
|
|
default_isbns = list(defaults.keys())
|
|
return default_isbns[0]
|