Added asset model and basic views
This commit is contained in:
25
asset/views.py
Normal file
25
asset/views.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic.edit import CreateView, DeleteView, UpdateView
|
||||
from django.views import generic
|
||||
from asset.models import Asset
|
||||
|
||||
class AssetCreateView(CreateView):
|
||||
model = Asset
|
||||
#fields = ['name']
|
||||
|
||||
class AssetUpdateView(UpdateView):
|
||||
model = Asset
|
||||
#fields = ['name']
|
||||
|
||||
class AssetDeleteView(DeleteView):
|
||||
model = Asset
|
||||
success_url = reverse_lazy('asset-list')
|
||||
|
||||
class AssetIndexView(generic.ListView):
|
||||
template_name = 'asset/asset_index.html'
|
||||
context_object_name = 'asset_list'
|
||||
|
||||
def get_queryset(self):
|
||||
# Return the last 20 created containers
|
||||
return Asset.objects.order_by('-created_ts')[:20]
|
||||
|
||||
Reference in New Issue
Block a user