Add Motivations and Destinations update function (template, view, urls)
This commit is contained in:
parent
3eb41b991b
commit
a29ebc0eb3
|
@ -10,7 +10,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for destination in object.get_destination_terms %}
|
||||
<tr><td>{{destination.text}}</td><td>{{destination.price}}</td><td>{{destination.description}}</td>
|
||||
<tr><td><a href="{% url 'destinationterm-update' pk=destination.id connector_slug=object.slug %}">{{destination.text}}</a></td><td>{{destination.price}}</td><td>{{destination.description}}</td>
|
||||
<td>{{destination.paymentrequired}}</td>
|
||||
<td><a rel="popup" href="{% url 'destinationterm-delete' pk=destination.id connector_slug=object.slug %}" class="icon-remove-sign"></a></td>
|
||||
</tr>
|
||||
|
@ -29,7 +29,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for motivation in object.get_motivation_terms %}
|
||||
<tr><td>{{motivation.text}}</td><td>{{motivation.price}}</td><td>{{motivation.description}}</td>
|
||||
<tr><td><a href="{% url 'motivationterm-update' pk=motivation.id connector_slug=object.slug %}">{{motivation.text}}</a></td><td>{{motivation.price}}</td><td>{{motivation.description}}</td>
|
||||
<td><a rel="popup" href="{% url 'motivationterm-delete' pk=motivation.id connector_slug=object.slug %}" class="icon-remove-sign"></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -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<connector_slug>[\w,-]+)/motivationterm/(?P<pk>[\w,-]+)/delete/',
|
||||
MotivationtermDeleteView.as_view(), name='motivationterm-delete'),
|
||||
url(r'^(?P<connector_slug>[\w,-]+)/motivationterm/(?P<pk>[\w,-]+)/update/',
|
||||
MotivationtermUpdateView.as_view(), name='motivationterm-update'),
|
||||
url(r'^(?P<connector_slug>[\w,-]+)/destinationterm/add/',
|
||||
DestinationtermAddView.as_view(), name='destinationterm-add'),
|
||||
url(r'^(?P<connector_slug>[\w,-]+)/destinationterm/(?P<pk>[\w,-]+)/delete/',
|
||||
DestinationtermDeleteView.as_view(), name='destinationterm-delete')
|
||||
DestinationtermDeleteView.as_view(), name='destinationterm-delete'),
|
||||
url(r'^(?P<connector_slug>[\w,-]+)/destinationterm/(?P<pk>[\w,-]+)/update/',
|
||||
DestinationtermUpdateView.as_view(), name='destinationterm-update')
|
||||
)
|
||||
|
|
|
@ -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})
|
||||
|
|
Loading…
Reference in New Issue