Files
edx-platform/openedx/core/lib/mobile_utils.py
Michael Terry c2033f9667 Small PLS courseware banner fixes
- Hide the submit-button CTA link to reset dates in the mobile
  app. They are working on their own solution.
- Don't show the dates_banner.html code in the courseware. It has
  new CTA banner support with updated wording.
2020-08-10 09:44:43 -04:00

27 lines
656 B
Python

"""
Common utilities related to the mobile apps.
"""
import re
from django.conf import settings
def is_request_from_mobile_app(request):
"""
Returns whether the given request was made by an open edX mobile app,
either natively or through the mobile web view.
Args:
request (HttpRequest)
"""
if getattr(settings, 'MOBILE_APP_USER_AGENT_REGEXES', None):
user_agent = request.META.get('HTTP_USER_AGENT')
if user_agent:
for user_agent_regex in settings.MOBILE_APP_USER_AGENT_REGEXES:
if re.search(user_agent_regex, user_agent):
return True
return False