From 1778dac9fd39dae75c55bf2cf836cdd488dbc265 Mon Sep 17 00:00:00 2001 From: Alexandru DAMIAN Date: Wed, 3 Jun 2015 12:36:30 +0100 Subject: toaster: toastertables REST refactoring This patch refactors the ToasterTables to bring them in line with REST principles - - all table pages now support the "format=json" GET parameter that returns the data in JSON format - the tables themselves This cleans up the URL namespace by aleviating the need to have two URLS for each table (one for the template and one for the data loading), and fixes minor things in the ToasterTable implementation. Signed-off-by: Alexandru DAMIAN --- lib/toaster/toastergui/urls.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'lib/toaster/toastergui/urls.py') diff --git a/lib/toaster/toastergui/urls.py b/lib/toaster/toastergui/urls.py index 4e328dae1..e10e0bb15 100644 --- a/lib/toaster/toastergui/urls.py +++ b/lib/toaster/toastergui/urls.py @@ -20,8 +20,7 @@ from django.conf.urls import patterns, include, url from django.views.generic import RedirectView, TemplateView from django.http import HttpResponseBadRequest -import tables -from widgets import ToasterTemplateView +from toastergui import tables urlpatterns = patterns('toastergui.views', # landing page @@ -81,32 +80,46 @@ urlpatterns = patterns('toastergui.views', url(r'^project/(?P\d+)/configuration$', 'projectconf', name='projectconf'), url(r'^project/(?P\d+)/builds/$', 'projectbuilds', name='projectbuilds'), - url(r'^project/(?P\d+)/layer/(?P\d+)$', - ToasterTemplateView.as_view(template_name='layerdetails.html'), - name='layerdetails'), url(r'^project/(?P\d+)/layer/$', lambda x,pid: HttpResponseBadRequest(), name='base_layerdetails'), # the import layer is a project-specific functionality; url(r'^project/(?P\d+)/importlayer$', 'importlayer', name='importlayer'), + + # the table pages that have been converted to ToasterTable widget url(r'^project/(?P\d+)/machines/$', - ToasterTemplateView.as_view(template_name="generic-toastertable-page.html"), + tables.MachinesTable.as_view(template_name="generic-toastertable-page.html"), { 'table_name': tables.MachinesTable.__name__.lower(), 'title' : 'All compatible machines' }, name="all-machines"), url(r'^project/(?P\d+)/recipes/$', - ToasterTemplateView.as_view(template_name="generic-toastertable-page.html"), + tables.RecipesTable.as_view(template_name="generic-toastertable-page.html"), { 'table_name': tables.RecipesTable.__name__.lower(), 'title' : 'All compatible recipes' }, name="all-targets"), url(r'^project/(?P\d+)/layers/$', - ToasterTemplateView.as_view(template_name="generic-toastertable-page.html"), + tables.LayersTable.as_view(template_name="generic-toastertable-page.html"), { 'table_name': tables.LayersTable.__name__.lower(), 'title' : 'All compatible layers' }, name="all-layers"), + url(r'^project/(?P\d+)/layer/(?P\d+)$', + tables.LayerDetails.as_view(template_name='layerdetails.html'), + name='layerdetails'), + + url(r'^project/(?P\d+)/layer/(?P\d+)/recipes/$', + tables.LayerRecipesTable.as_view(template_name="generic-toastertable-page.html"), + { 'table_name': tables.LayerRecipesTable.__name__.lower(), + 'title' : 'All recipes in layer' }, + name=tables.LayerRecipesTable.__name__.lower()), + + url(r'^project/(?P\d+)/layer/(?P\d+)/machines/$', + tables.LayerMachinesTable.as_view(template_name="generic-toastertable-page.html"), + { 'table_name': tables.LayerMachinesTable.__name__.lower(), + 'title' : 'All machines in layer' }, + name=tables.LayerMachinesTable.__name__.lower()), url(r'^xhr_projectbuild/(?P\d+)$', 'xhr_projectbuild', name='xhr_projectbuild'), url(r'^xhr_projectinfo/$', 'xhr_projectinfo', name='xhr_projectinfo'), @@ -116,7 +129,6 @@ urlpatterns = patterns('toastergui.views', url(r'^xhr_datatypeahead/(?P\d+)$', 'xhr_datatypeahead', name='xhr_datatypeahead'), url(r'^xhr_importlayer/$', 'xhr_importlayer', name='xhr_importlayer'), url(r'^xhr_updatelayer/$', 'xhr_updatelayer', name='xhr_updatelayer'), - url(r'^xhr_tables/project/(?P\d+)/', include('toastergui.tables')), # dashboard for failed build requests url(r'^project/(?P\d+)/buildrequest/(?P\d+)$', 'buildrequestdetails', name='buildrequestdetails'), -- cgit 1.2.3-korg