1#!/usr/bin/env python3
2
3"""Standard Django file to map database view URLs to functions."""
4
5from django.urls import re_path
6from django.urls import path
7from django.views.generic import TemplateView
8
9import chart.db.views
10
11app_name = 'db'
12
13urlpatterns = [
14 # all tables
15 path(r'',
16 chart.db.views.index,
17 name='index'),
18
19 # search results
20 path('search',
21 chart.db.views.search,
22 name='search'),
23
24 # Javascript support
25 path('index.js',
26 TemplateView.as_view(template_name='db/index.js',
27 content_type='text/javascript'),
28 name='js'),
29
30 # single ts table
31 re_path(r'ts/(?P<table_name>\w+)$',
32 chart.db.views.view_table,
33 name='table'),
34
35 # table js support
36 path('table.js',
37 TemplateView.as_view(template_name='db/table.js',
38 content_type='text/javascript'),
39 name='table/js'),
40
41 # single field
42 re_path(r'ts/(?P<table_name>\w+)/(?P<field_name>\w+)$',
43 chart.db.views.view_field,
44 name='field'),
45
46 # single field js
47 path('field.js',
48 TemplateView.as_view(template_name='db/field.js',
49 content_type='text/javascript'), # pylint:disable=E1120
50 name='field/js'),
51
52 # calibration curve image
53 re_path(r'cal/(?P<table_name>\w+)/(?P<field_name>\w+)/(?P<size>[0-9]+)$',
54 chart.db.views.calibration_curve,
55 name='field/calibration_curve'),
56
57 # single sys table
58 re_path(r'sys/(?P<table_name>\w+)$',
59 chart.db.views.systable,
60 name='systable'),
61
62 # all packets, for SCOS-based projects
63 path('packet',
64 chart.db.views.packets,
65 name='packets'),
66
67 # single packet, for SCOS-based projects
68 re_path(r'packet/(?P<packet_name>\w+)$',
69 chart.db.views.packet,
70 name='packet'),
71
72 # all sid packets
73 path('sid_packets',
74 chart.db.views.sid_packets,
75 name='sid_packets'),
76]