from itertools import chain from django.urls import path, register_converter from c3nav.site.converters import AtPositionConverter, CoordinatesConverter, IsEmbedConverter from c3nav.site.views import (about_view, access_redeem_view, account_manage, account_view, api_secret_create, api_secret_list, change_password_view, choose_language, delete_account_view, login_view, logout_view, map_index, position_create, position_detail, position_list, position_set, qr_code, register_view, report_create, report_detail, report_list) register_converter(CoordinatesConverter, 'coords') register_converter(AtPositionConverter, 'at_pos') register_converter(IsEmbedConverter, 'is_embed') embed = '' pos = '' def index_paths(pre, suf): return [ path(f'{pre}l//{suf}', map_index, {'mode': 'l', 'details': False, 'nearby': False}, name='site.index'), path(f'{pre}l//details/{suf}', map_index, {'mode': 'l', 'details': True}, name='site.index'), path(f'{pre}l//nearby/{suf}', map_index, {'mode': 'l', 'nearby': True}, name='site.index'), path(f'{pre}o//{suf}', map_index, {'mode': 'o'}, name='site.index'), path(f'{pre}d//{suf}', map_index, {'mode': 'd'}, name='site.index'), path(f'{pre}r/{suf}', map_index, {'mode': 'r'}, name='site.index'), path(f'{pre}r///{suf}', map_index, {'mode': 'r', 'details': False, 'options': False}, name='site.index'), path(f'{pre}r///details/{suf}', map_index, {'mode': 'r', 'details': True}, name='site.index'), path(f'{pre}r///options/{suf}', map_index, {'mode': 'r', 'options': True}, name='site.index'), path(f'{pre}{suf}', map_index, name='site.index'), ] urlpatterns = [ *chain(*(index_paths(pre, suf) for pre in ('', embed) for suf in ('', pos))), path('qr/', qr_code, name='site.qr'), path('login', login_view, name='site.login'), path('logout', logout_view, name='site.logout'), path('register', register_view, name='site.register'), path('account/', account_view, name='site.account'), path('account/manage/', account_manage, name='site.account.manage'), path('account/change_password/', change_password_view, name='site.account.change_password'), path('account/delete/', delete_account_view, name='site.account.delete'), path('access/', access_redeem_view, name='site.access.redeem'), path('lang/', choose_language, name='site.language'), path('about/', about_view, name='site.about'), path('reports/open/', report_list, {'filter': 'open'}, name='site.report_list'), path('reports/all/', report_list, {'filter': 'all'}, name='site.report_list'), path('reports//', report_detail, name='site.report_detail'), path('reports///', report_detail, name='site.report_detail'), path('report/l//', report_create, name='site.report_create'), path('report/l//', report_create, name='site.report_create'), path('report/r////', report_create, name='site.report_create'), path('positions/', position_list, name='site.position_list'), path('positions/create/', position_create, name='site.position_create'), path('positions//', position_detail, name='site.position_detail'), path('positions/set//', position_set, name='site.position_set'), path('api-secrets/', api_secret_list, name='site.api_secret_list'), path('api-secrets/create/', api_secret_create, name='site.api_secret_create'), ]