Commit a14d96fb authored by dani2612's avatar dani2612

inizio creazione delle action per la modifica delle things

e completamento index
parent e2fa6632
......@@ -7,6 +7,7 @@
<table class="table table-dark">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Id</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
......@@ -19,7 +20,9 @@
</thead>
<tbody>
{% for obj in thing %}
<tr>
<tr scope="row">
<td><a href='{% url 'things:edit' obj.id %}'>
<a href='{% url 'things:delete' obj.id %}'> </td>
<td >{{ obj.id }}</td>
<td >{{ obj.name }}</td>
<td >{{ obj.description }}</td>
......
......@@ -3,6 +3,8 @@ from . import views
app_name = 'things'
urlpatterns = [
url(r'^$', views.ThingListView.as_view()),
url(r'^new', views.ThingCreateView.as_view()),
url(r'^$', views.ThingListView.as_view(),name='index'),
url(r'^new', views.ThingCreateView.as_view(),name='create'),
url(r'^(?P<pk>[0-9]+)', views.ThingUpdateView.as_view(),name='update'),
url(r'^(?P<pk>[0-9]+)/delete/', views.ThingDeleteView.as_view(),name='delete'),
]
......@@ -2,14 +2,17 @@ from django.shortcuts import get_object_or_404, render
from django.views import View, generic
from django import forms
from .models import Thing,Category
from django.urls.base import reverse_lazy
class CategoryListView(generic.ListView):
model = Category
class ThingDeleteView(generic.ListView):
model = Thing
success_url=reverse_lazy('things:index')
class ThingCreateView(generic.CreateView):
model = Thing
......@@ -33,12 +36,30 @@ class ThingCreateView(generic.CreateView):
'parent',
]
class ThingUpdateView(generic.UpdateView):
model=Thing
fields = [
'id',
'name',
'description',
'categories',
'state',
'metadata',
# Ownership info
'owner',
'borrowable',
'private',
'expiry_date',
# Quantity info
'quantity',
'consumable',
# Localization
'location',
'parent',
]
class ThingListView(generic.ListView):
model = Thing
class ThingView(View):
def get(self, request, uuid):
......@@ -46,6 +67,5 @@ class ThingView(View):
return render(request, {'thing': thing})
class ThingListView(generic.ListView):
model = Thing
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment