From a29ebc0eb30d47ccbfad10f9833ec1895c320999 Mon Sep 17 00:00:00 2001 From: Christophe Boulanger Date: Thu, 20 Apr 2017 13:33:56 +0200 Subject: [PATCH] Add Motivations and Destinations update function (template, view, urls) --- .../imiots1datasources_detail.html | 4 ++-- passerelle_imio_ts1_datasources/urls.py | 10 ++++++-- passerelle_imio_ts1_datasources/views.py | 24 ++++++++++++++++++- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/passerelle_imio_ts1_datasources/templates/passerelle_imio_ts1_datasources/imiots1datasources_detail.html b/passerelle_imio_ts1_datasources/templates/passerelle_imio_ts1_datasources/imiots1datasources_detail.html index 9b0272a..bf30e24 100644 --- a/passerelle_imio_ts1_datasources/templates/passerelle_imio_ts1_datasources/imiots1datasources_detail.html +++ b/passerelle_imio_ts1_datasources/templates/passerelle_imio_ts1_datasources/imiots1datasources_detail.html @@ -10,7 +10,7 @@ {% for destination in object.get_destination_terms %} -{{destination.text}}{{destination.price}}{{destination.description}} +{{destination.text}}{{destination.price}}{{destination.description}} {{destination.paymentrequired}} @@ -29,7 +29,7 @@ {% for motivation in object.get_motivation_terms %} -{{motivation.text}}{{motivation.price}}{{motivation.description}} +{{motivation.text}}{{motivation.price}}{{motivation.description}} {% endfor %} diff --git a/passerelle_imio_ts1_datasources/urls.py b/passerelle_imio_ts1_datasources/urls.py index 82113cc..1641610 100644 --- a/passerelle_imio_ts1_datasources/urls.py +++ b/passerelle_imio_ts1_datasources/urls.py @@ -2,8 +2,10 @@ from django.conf.urls import patterns, include, url from .views import (DatasourcesView, MotivationtermAddView, MotivationtermDeleteView, + MotivationtermUpdateView, DestinationtermAddView, - DestinationtermDeleteView) + DestinationtermDeleteView, + DestinationtermUpdateView) urlpatterns = patterns('', @@ -15,8 +17,12 @@ management_urlpatterns = patterns('', MotivationtermAddView.as_view(), name='motivationterm-add'), url(r'^(?P[\w,-]+)/motivationterm/(?P[\w,-]+)/delete/', MotivationtermDeleteView.as_view(), name='motivationterm-delete'), + url(r'^(?P[\w,-]+)/motivationterm/(?P[\w,-]+)/update/', + MotivationtermUpdateView.as_view(), name='motivationterm-update'), url(r'^(?P[\w,-]+)/destinationterm/add/', DestinationtermAddView.as_view(), name='destinationterm-add'), url(r'^(?P[\w,-]+)/destinationterm/(?P[\w,-]+)/delete/', - DestinationtermDeleteView.as_view(), name='destinationterm-delete') + DestinationtermDeleteView.as_view(), name='destinationterm-delete'), + url(r'^(?P[\w,-]+)/destinationterm/(?P[\w,-]+)/update/', + DestinationtermUpdateView.as_view(), name='destinationterm-update') ) diff --git a/passerelle_imio_ts1_datasources/views.py b/passerelle_imio_ts1_datasources/views.py index a0bb64a..36a754e 100644 --- a/passerelle_imio_ts1_datasources/views.py +++ b/passerelle_imio_ts1_datasources/views.py @@ -1,4 +1,4 @@ -from django.views.generic import View, CreateView, DeleteView +from django.views.generic import View, CreateView, DeleteView, UpdateView from django.views.generic.detail import SingleObjectMixin from django.core.urlresolvers import reverse @@ -31,6 +31,17 @@ class MotivationtermDeleteView(DeleteView): 'slug': connector.slug}) +class MotivationtermUpdateView(UpdateView): + model = MotivationTerm + fields = '__all__' + + def get_success_url(self): + connector = ImioTs1Datasources.objects.get(slug=self.kwargs['connector_slug']) + return reverse('view-connector', + kwargs={'connector': connector.get_connector_slug(), + 'slug': connector.slug}) + + class DestinationtermAddView(CreateView): model = DestinationTerm fields = '__all__' @@ -51,3 +62,14 @@ class DestinationtermDeleteView(DeleteView): return reverse('view-connector', kwargs={'connector': connector.get_connector_slug(), 'slug': connector.slug}) + + +class DestinationtermUpdateView(UpdateView): + model = DestinationTerm + fields = '__all__' + + def get_success_url(self): + connector = ImioTs1Datasources.objects.get(slug=self.kwargs['connector_slug']) + return reverse('view-connector', + kwargs={'connector': connector.get_connector_slug(), + 'slug': connector.slug})