Author: jtauber
Date: Mon Oct 13 03:01:06 2008
New Revision: 1034
Modified:
trunk/apps/local_apps/tribes/urls.py
trunk/apps/local_apps/tribes/views.py
Log:
added view for tribe deletion
Modified: trunk/apps/local_apps/tribes/urls.py
==============================================================================
--- trunk/apps/local_apps/tribes/urls.py (original)
+++ trunk/apps/local_apps/tribes/urls.py Mon Oct 13 03:01:06 2008
@@ -17,6 +17,7 @@
url(r'^create/$', 'tribes.views.create', name="tribe_create"),
url(r'^your_tribes/$', 'tribes.views.your_tribes',
name="your_tribes"),
url(r'^tribe/(\w+)/$', 'tribes.views.tribe', name="tribe_detail"),
+ url(r'^tribe/(\w+)/delete/$', 'tribes.views.delete',
name="tribe_delete"),
# topics
url(r'^tribe/(\w+)/topics/$', 'tribes.views.topics',
name="tribe_topics"),
Modified: trunk/apps/local_apps/tribes/views.py
==============================================================================
--- trunk/apps/local_apps/tribes/views.py (original)
+++ trunk/apps/local_apps/tribes/views.py Mon Oct 13 03:01:06 2008
@@ -63,6 +63,22 @@
"tribe_form": tribe_form,
}, context_instance=RequestContext(request))
+
+def delete(request, slug, redirect_url=None):
+ tribe = get_object_or_404(Tribe, slug=slug)
+ if not redirect_url:
+ redirect_url = "/tribes/" # @@@ can't use reverse("tribes") --
what is URL name using things?
+
+ # @@@ eventually, we'll remove restriction that tribe.creator can't
leave tribe but we'll still require tribe.members.all().count() == 1
+ if request.user.is_authenticated() and request.method == "POST" and
request.user == tribe.creator and tribe.members.all().count() == 1:
+ tribe.deleted = True
+ tribe.save()
+ request.user.message_set.create(message="Tribe %s deleted." %
tribe)
+ # @@@ no notification as the deleter must be the only member
+
+ return HttpResponseRedirect(redirect_url)
+
+
def your_tribes(request, template_name="tribes/your_tribes.html"):
return render_to_response(template_name, {
"tribes": Tribe.objects.filter(deleted=False,
members=request.user).order_by("name"),
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---