-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: theme config tenant creation api implementation #234
feat: theme config tenant creation api implementation #234
Conversation
4345c74
to
7ffef17
Compare
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.
thank you @tehreem-sadat , please check my notes
""" | ||
Generate a tenant configuration by copying the default config and replacing placeholder PARAM. | ||
|
||
:param name: Name to replace 'PARAM' in the default configuration |
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.
please use platform_name
instead of name
. The more descriptive is the better
:param name: Name to replace 'PARAM' in the default configuration | |
:param platform_name: Name to replace `{{platform_name}}` in the default configuration |
we also need sub_domain
and course_org_filter
as parameters
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.
As discussed we don't need course_org_filter separately as param. In default config to copy we can have somethings as follows which can be handled by sub_domain replacement.
"course_org_filter": [
"{sub_domain}"
]
:param sub_domain: The subdomain to be used for the tenant | ||
:return: The created TenantConfig object | ||
""" | ||
config_data = generate_tenant_config(sub_domain) |
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.
config_data = generate_tenant_config(sub_domain) | |
# .... Verify that the site domain is not already in `Route` .... | |
config_data = generate_tenant_config(sub_domain) |
958e098
to
8263304
Compare
8263304
to
3353162
Compare
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.
Thank you @tehreem-sadat . Please address the change requests and merge
'description': 'Create new tenant along with default theme config. The caller must have staff or fx ' | ||
'api global access.\n', |
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.
No need for this to be mentioned since it's configurable through View Roles admin page
'description': 'Create new tenant along with default theme config. The caller must have staff or fx ' | |
'api global access.\n', | |
'description': 'Create new tenant along with default theme config.\n', |
caller=self.fx_permission_info['user'], | ||
tenant_ids=[tenant_config.id], | ||
user_keys=[data['owner_user_id']], | ||
role='staff', |
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.
role='staff', | |
role=cs.COURSE_ACCESS_ROLES_STAFF_EDITOR, |
if cs.CACHE_NAMES.get(name) is None: | ||
raise FXCodedException( | ||
code=FXExceptionCodes.INVALID_INPUT, | ||
message=f'Cache with {name} does not exist.' | ||
) | ||
cache.set(name, None) |
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.
no need to raise an error
if cs.CACHE_NAMES.get(name) is None: | |
raise FXCodedException( | |
code=FXExceptionCodes.INVALID_INPUT, | |
message=f'Cache with {name} does not exist.' | |
) | |
cache.set(name, None) | |
cache.delete(name) |
if TenantConfig.objects.filter(external_key=sub_domain).exists(): | ||
raise FXCodedException( | ||
code=FXExceptionCodes.TENANT_ALREADY_EXIST, | ||
message=f'Tenant already exists for given sub_domain: ({sub_domain}).', | ||
) |
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.
No need. The external key is a random number sometimes. We'll trust Route
and that's it
if TenantConfig.objects.filter(external_key=sub_domain).exists(): | |
raise FXCodedException( | |
code=FXExceptionCodes.TENANT_ALREADY_EXIST, | |
message=f'Tenant already exists for given sub_domain: ({sub_domain}).', | |
) |
@@ -71,3 +74,36 @@ def wrapped(*args: Any, **kwargs: Any) -> Dict[str, Any]: | |||
|
|||
return wrapped | |||
return decorator | |||
|
|||
|
|||
def invalidate_cache(cache_name: str) -> None: |
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 suggest that we use None
instead of __all__
. Because it's less error prune. So, invalidate_cache()
will invalidate everything, looks very clear to me. What do you think?
def invalidate_cache(cache_name: str) -> None: | |
def invalidate_cache(cache_name: str = None) -> None: |
3353162
to
7e7ea0e
Compare
Description:
New tenant creation API
Related Issue:
#225