<s> from functools import wraps <EOL> from corehq . apps . users . models import Permissions <EOL> from corehq . apps . domain . decorators import login_and_domain_required <EOL> from corehq . apps . users . decorators import require_permission <EOL> def require_cloudcare_access_ex ( ) : <EOL> """<STR_LIT>""" <EOL> def decorator ( view_func ) : <EOL> @ wraps ( view_func ) <EOL> def _inner ( request , domain , * args , ** kwargs ) : <EOL> if hasattr ( request , "<STR_LIT>" ) : <EOL> if request . couch_user . is_web_user ( ) : <EOL> return require_permission ( Permissions . edit_data ) ( view_func ) ( request , domain , * args , ** kwargs ) <EOL> else : <EOL> assert request . couch_user . is_commcare_user ( ) , "<STR_LIT>" <EOL> return login_and_domain_required ( view_func ) ( request , domain , * args , ** kwargs ) <EOL> return login_and_domain_required ( view_func ) ( request , domain , * args , ** kwargs ) <EOL> return _inner <EOL> return decorator <EOL> require_cloudcare_access = require_cloudcare_access_ex ( ) </s>
