def get_all_installed_url_patterns(): """ Returns a list of urlpatterns that are defined in base urls.py """ allowed_urls = [] root_urls = get_root_urls() for url_pattern in root_urls.urlpatterns: if is_in_installed_apps(url_pattern): allowed_urls.append(url_pattern) return allowed_urls
def get_non_django_installed_url_patterns(): """ Get all the non django urlpatterns defined in base urls.py """ allowed_urls = [] root_urls = get_root_urls() installed_apps = get_non_django_installed_apps() for url_pattern in root_urls.urlpatterns: pkg_name = get_pattern_package_name(url_pattern) if pkg_name in installed_apps: allowed_urls.append(url_pattern) return allowed_urls
def get_extra_urls_from_root_urls(): """ Extra urls are the ones defined without an app in the Root urls.py. """ root_urls = get_root_urls() list_of_RegexURLPattern = [] urls_and_regex = {} for url_pattern in root_urls.urlpatterns: if isinstance(url_pattern, RegexURLPattern): list_of_RegexURLPattern.append(url_pattern) for url_pattern in list_of_RegexURLPattern: urls_and_regex[url_pattern._regex] = {'name': url_pattern.name} return urls_and_regex
def get_extra_urls_from_root_urls(): """ Extra urls are the ones defined without an app in the Root urls.py. """ root_urls = get_root_urls() list_of_RegexURLPattern = [] urls_and_regex = {} for url_pattern in root_urls.urlpatterns: if isinstance(url_pattern, RegexURLPattern): list_of_RegexURLPattern.append(url_pattern) for url_pattern in list_of_RegexURLPattern: urls_and_regex[url_pattern._regex] = {'name': url_pattern.name } return urls_and_regex
def get_base_url_pattern_by_app(app_name): """ Given the app_name to the method, it searches for the package name it belongs too. Once the package name is retrieved the corresponding REGEXURLResolver instance is returned. That is essentially the URL Pattern This particular method doesn't allow Admin app for now """ root_urls = get_root_urls() for url_pattern in root_urls.urlpatterns: pkg_name = get_pattern_package_name(url_pattern) if pkg_name == app_name: return url_pattern elif app_name == 'admin': return get_admin_url_pattern() return None
def get_admin_url_pattern(): if admin_app_is_installed(): for url_pattern in get_root_urls().urlpatterns: if get_pattern_package_name(url_pattern) == 'admin': return url_pattern return None