Kenneth Love avatar Kenneth Love committed 4023b02

pushing the delete view for chris

Comments (0)

Files changed (4)


 from django.conf.urls.defaults import patterns, url
-from talks.views import CreateTalkView, TalksView
+from talks.views import CreateTalkView, TalksView, DeleteTalkView
 urlpatterns = patterns('',
+    url(r'^delete/(?P<pk>\d+)/$', DeleteTalkView.as_view(), name='delete_talk'),
     url(r'^create/$', CreateTalkView.as_view(), name='create_talk'),
     url(r'^$', TalksView.as_view(), name='talks'),


 class DeleteTalkView(DeleteView):
-    pass
+    model = Talk
+    slug_field = 'pk'
+    @method_decorator(login_required)
+    def dispatch(self, *args, **kwargs):
+        return super(DeleteTalkView, self).dispatch(*args, **kwargs)
+    def get_queryset(self):
+        queryset = super(DeleteTalkView, self).get_queryset()
+        queryset = queryset.filter(user=self.request.user)
+        return queryset
+    def get_success_url(self):
+        return reverse('talks')
 class CreateTalkView(CreateView):


+{% extends "_layouts/base.html" %}
+{% block page_title %}Confirm deletion | {% endblock %}
+{% block page_content %}
+<form action="" method="POST">
+	{% csrf_token %}
+	<fieldset class="actions">
+		<p>Really delete "{{ object }}"?</p>
+		<input type="submit" class="btn primary" value="Yes">
+		<a class="btn" href="{% url talks %}">No</a>
+	</fieldset>
+{% endblock %}


 			{% oembed %}
 			{{ talk.url }}
 			{% endoembed %}
+			<div>
+				<a href="{% url delete_talk %}">Delete</a>
+			</div>
 		<div class="span8 columns">
 			Slides go here
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.