summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Hostbase/hostbase/urls.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Hostbase/hostbase/urls.py')
-rw-r--r--src/lib/Server/Hostbase/hostbase/urls.py64
1 files changed, 39 insertions, 25 deletions
diff --git a/src/lib/Server/Hostbase/hostbase/urls.py b/src/lib/Server/Hostbase/hostbase/urls.py
index 0e4588446..0ee204abe 100644
--- a/src/lib/Server/Hostbase/hostbase/urls.py
+++ b/src/lib/Server/Hostbase/hostbase/urls.py
@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
+from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse
+from django.views.generic.create_update import create_object, update_object, delete_object
+from django.views.generic.list_detail import object_detail, object_list
-from models import Host, Zone
+from models import Host, Zone, Log
host_detail_dict = {
'queryset':Host.objects.all(),
@@ -10,45 +13,56 @@ host_detail_dict = {
'template_object_name':'host',
}
+host_delete_dict = {
+ 'model':Host,
+ 'post_delete_redirect':'/',
+}
+
+host_log_detail_dict = host_detail_dict.copy()
+host_log_detail_dict['template_name'] = 'logviewer.html'
+
+host_dns_detail_dict = host_detail_dict.copy()
+host_dns_detail_dict['template_name'] = 'dns.html'
+
zone_new_dict = {
'model':Zone,
'template_name':'zonenew.html',
- 'post_save_redirect':'/hostbase/zones',
+ 'post_save_redirect':'../%(id)s',
}
+
zones_list_dict = {
'queryset':Zone.objects.all(),
'template_name':'zones.html',
'template_object_name':'zone',
}
+
zone_detail_dict = {
'queryset':Zone.objects.all(),
'template_name':'zoneview.html',
'template_object_name':'zone',
}
-urlpatterns = patterns('django.views.generic.list_detail',
- (r'^(?P<object_id>\d+)/$', 'object_detail', host_detail_dict, 'host_detail'),
- (r'^zones/$', 'object_list', zones_list_dict, 'zone_list'),
- (r'^zones/(?P<object_id>\d+)/$', 'object_detail', zone_detail_dict, 'zone_detail'),
-)
-
-urlpatterns += patterns('django.views.generic.create_update',
- (r'^zones/new/$', 'create_object', zone_new_dict, 'zone_new'),
- (r'^zones/(?P<object_id>\d+)/edit', 'update_object', zone_new_dict, 'zone_edit'),
+urlpatterns = patterns('',
+ (r'^(?P<object_id>\d+)/$', object_detail, host_detail_dict, 'host_detail'),
+ (r'^zones/new/$', login_required(create_object), zone_new_dict, 'zone_new'),
+ (r'^zones/(?P<object_id>\d+)/edit', login_required(update_object), zone_new_dict, 'zone_edit'),
+ (r'^zones/$', object_list, zones_list_dict, 'zone_list'),
+ (r'^zones/(?P<object_id>\d+)/$', object_detail, zone_detail_dict, 'zone_detail'),
+ (r'^zones/(?P<object_id>\d+)/$', object_detail, zone_detail_dict, 'zone_detail'),
+ (r'^\d+/logs/(?P<object_id>\d+)/', object_detail, { 'queryset':Log.objects.all() }, 'log_detail'),
+ (r'^(?P<object_id>\d+)/logs/', object_detail, host_log_detail_dict, 'host_log_list'),
+ (r'^(?P<object_id>\d+)/dns', object_detail, host_dns_detail_dict, 'host_dns_list'),
+ (r'^(?P<object_id>\d+)/remove', login_required(delete_object), host_delete_dict, 'host_delete'),
)
urlpatterns += patterns('Bcfg2.Server.Hostbase.hostbase.views',
- (r'^$', 'search'),
- (r'^(?P<host_id>\d+)/edit', 'edit'),
- (r'^(?P<host_id>\d+)/remove', 'remove'),
- (r'^(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
- (r'^(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/(?P<name_id>\d+)/confirm', 'confirm'),
- (r'^(?P<host_id>\d+)/dns/edit', 'dnsedit'),
- (r'^(?P<host_id>\d+)/dns', 'dns'),
- (r'^(?P<host_id>\d+)/logs/(?P<log_id>\d+)', 'printlog'),
- (r'^(?P<host_id>\d+)/logs', 'logs'),
- (r'^new', 'new'),
- (r'^(?P<host_id>\d+)/copy', 'copy'),
-# (r'^hostinfo', 'hostinfo'),
- (r'^zones/(?P<zone_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
- )
+ (r'^$', 'search'),
+ (r'^(?P<host_id>\d+)/edit', 'edit'),
+ (r'^(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
+ (r'^(?P<host_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/(?P<name_id>\d+)/confirm', 'confirm'),
+ (r'^(?P<host_id>\d+)/dns/edit', 'dnsedit'),
+ (r'^new', 'new'),
+ (r'^(?P<host_id>\d+)/copy', 'copy'),
+# (r'^hostinfo', 'hostinfo'),
+ (r'^zones/(?P<zone_id>\d+)/(?P<item>\D+)/(?P<item_id>\d+)/confirm', 'confirm'),
+)