From 11d06b5e2b85b02835b7dd17ab90e8c402dd21c1 Mon Sep 17 00:00:00 2001 From: ibuler Date: Sun, 4 Sep 2016 16:02:51 +0800 Subject: [PATCH] Add asset group view and url --- apps/assets/urls.py | 31 ++++++++++++++------------- apps/assets/views.py | 50 +++++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 38 deletions(-) diff --git a/apps/assets/urls.py b/apps/assets/urls.py index 1517df165..875091a73 100644 --- a/apps/assets/urls.py +++ b/apps/assets/urls.py @@ -1,20 +1,23 @@ # coding:utf-8 from django.conf.urls import url,include -from .views import * -from .api import ( - AssetGroupViewSet,AssetViewSet,IDCViewSet -) -from rest_framework import routers -router = routers.DefaultRouter() -router.register(r'assetgroup', AssetGroupViewSet) -router.register(r'asset', AssetViewSet) -router.register(r'idc', IDCViewSet) +import views +# from rest_framework import routers +# router = routers.DefaultRouter() +# router.register(r'assetgroup', AssetGroupViewSet) +# router.register(r'asset', AssetViewSet) +# router.register(r'idc', IDCViewSet) app_name = 'assets' urlpatterns = [ - url(r'^add/$', AssetAddView.as_view(), name='asset-add'), - url(r'^$', AssetListView.as_view(), name='asset-list'), - url(r'^(?P[0-9]+)/delete/$', AssetDeleteView.as_view(), name='asset-list'), - url(r'^(?P[0-9]+)/detail/$', AssetDetailView.as_view(), name='asset-detail'), - url(r'^api/v1.0/', include(router.urls)), + url(r'^asset', views.AssetListView.as_view(), name='asset-list'), + url(r'^asset/add$', views.AssetAddView.as_view(), name='asset-add'), + url(r'^asset/(?P[0-9]+)$', views.AssetDetailView.as_view(), name='asset-detail'), + url(r'^asset/(?P[0-9]+)$/edit', views.AssetEditView.as_view(), name='asset-edit'), + url(r'^asset/(?P[0-9]+)/delete$', views.AssetDeleteView.as_view(), name='asset-delete'), + url(r'^asset-group', views.AssetGroupListView.as_view(), name='assetgroup-list'), + url(r'^asset-group/add$', views.AssetAddView.as_view(), name='asset-add'), + url(r'^asset-group/(?P[0-9]+)$', views.AssetDetailView.as_view(), name='asset-detail'), + url(r'^asset-group/(?P[0-9]+)$/edit', views.AssetEditView.as_view(), name='asset-edit'), + url(r'^asset-group/(?P[0-9]+)/delete$', views.AssetDeleteView.as_view(), name='asset-delete'), + # url(r'^api/v1.0/', include(router.urls)), ] diff --git a/apps/assets/views.py b/apps/assets/views.py index af451f4b7..12e4e6203 100644 --- a/apps/assets/views.py +++ b/apps/assets/views.py @@ -1,28 +1,11 @@ -from django.views.generic import ( - TemplateView, ListView -) +from __future__ import absolute_import, unicode_literals +from django.views.generic import TemplateView, ListView +from django.views.generic.edit import CreateView, DeleteView, FormView, UpdateView from django.urls import reverse_lazy - - -from django.views.generic.edit import ( - CreateView, DeleteView, FormView, UpdateView -) - - -from django.views.generic.detail import ( - DetailView -) - - -from .models import ( - Asset, AssetGroup, IDC, AssetExtend -) - - -from .forms import ( - AssetForm, -) +from django.views.generic.detail import DetailView +from .models import Asset, AssetGroup, IDC, AssetExtend +from .forms import AssetForm class AssetAddView(CreateView): @@ -32,7 +15,7 @@ class AssetAddView(CreateView): success_url = reverse_lazy('assets:asset-list') -class AssetEdit(): +class AssetEditView(UpdateView): pass @@ -52,3 +35,22 @@ class AssetDetailView(DetailView): context_object_name = 'asset' template_name = 'assets/asset_detail.html' + +class AssetGroupAddView(CreateView): + pass + + +class AssetGroupListView(ListView): + pass + + +class AssetGroupDetailView(DetailView): + pass + + +class AssetGroupEditView(UpdateView): + pass + + +class AssetGroupDeleteView(DeleteView): + pass