Create the @feature_lock decorator
This commit is contained in:
		@@ -140,3 +140,25 @@ def beta(func):
 | 
			
		||||
        return func(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
    return decorated
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def feature_lock(feature):  # pylint: disable=missing-return-doc,missing-return-type-doc
 | 
			
		||||
    """Decorator to lock a feature
 | 
			
		||||
 | 
			
		||||
    :param feature: the name of a feature
 | 
			
		||||
    :type feature: str
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def decorator(func):  # pylint: disable=missing-docstring
 | 
			
		||||
        @wraps(func)
 | 
			
		||||
        def decorated(*args, **kwargs):  # pylint: disable=missing-docstring
 | 
			
		||||
            from calsocial.models import AppState
 | 
			
		||||
 | 
			
		||||
            if AppState[f'feature:{feature}'] == 'true':
 | 
			
		||||
                return func(*args, **kwargs)
 | 
			
		||||
 | 
			
		||||
            return 'Feature locked'
 | 
			
		||||
 | 
			
		||||
        return decorated
 | 
			
		||||
 | 
			
		||||
    return decorator
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user