Permalink
Browse files

Ch09: Code and Route Tag Delete.

  • Loading branch information...
jambonrose committed Mar 10, 2015
1 parent 8191bf6 commit dc53479077259140c871064d9edfb3f1b64b85ee
Showing with 21 additions and 3 deletions.
  1. +4 −0 organizer/models.py
  2. +6 −2 organizer/urls.py
  3. +11 −1 organizer/views.py
@@ -24,6 +24,10 @@ def get_absolute_url(self):
return reverse('organizer_tag_detail',
kwargs={'slug': self.slug})
def get_delete_url(self):
return reverse('organizer_tag_delete',
kwargs={'slug': self.slug})
def get_update_url(self):
return reverse('organizer_tag_update',
kwargs={'slug': self.slug})
@@ -3,8 +3,9 @@
from .views import (
NewsLinkCreate, NewsLinkDelete,
NewsLinkUpdate, StartupCreate, StartupUpdate,
TagCreate, TagUpdate, startup_detail,
startup_list, tag_detail, tag_list)
TagCreate, TagDelete, TagUpdate,
startup_detail, startup_list, tag_detail,
tag_list)
urlpatterns = [
url(r'^newslink/create/$',
@@ -37,6 +38,9 @@
url(r'^tag/(?P<slug>[\w\-]+)/$',
tag_detail,
name='organizer_tag_detail'),
url(r'^tag/(?P<slug>[\w-]+)/delete/$',
TagDelete.as_view(),
name='organizer_tag_delete'),
url(r'^tag/(?P<slug>[\w\-]+)/update/$',
TagUpdate.as_view(),
name='organizer_tag_update'),
@@ -1,3 +1,4 @@
from django.core.urlresolvers import reverse_lazy
from django.shortcuts import (
get_object_or_404, redirect, render)
from django.views.generic import View
@@ -6,7 +7,8 @@
NewsLinkForm, StartupForm, TagForm)
from .models import NewsLink, Startup, Tag
from .utils import (
ObjectCreateMixin, ObjectUpdateMixin)
ObjectCreateMixin, ObjectDeleteMixin,
ObjectUpdateMixin)
class NewsLinkCreate(ObjectCreateMixin, View):
@@ -101,6 +103,14 @@ class TagCreate(ObjectCreateMixin, View):
template_name = 'organizer/tag_form.html'
class TagDelete(ObjectDeleteMixin, View):
model = Tag
success_url = reverse_lazy(
'organizer_tag_list')
template_name = (
'organizer/tag_confirm_delete.html')
def tag_detail(request, slug):
tag = get_object_or_404(
Tag, slug__iexact=slug)

0 comments on commit dc53479

Please sign in to comment.