Commit a14d96fb authored by dani2612's avatar dani2612
Browse files

inizio creazione delle action per la modifica delle things

e completamento index
parent e2fa6632
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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>
+4 −2
Original line number Diff line number Diff line
@@ -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'),
]
+28 −8
Original line number Diff line number Diff line
@@ -2,13 +2,16 @@ 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):
@@ -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