skillbox/server/users/licenses.py

64 lines
1.6 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
},
"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
},
'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()