Permalink
Browse files

views are loading the jetpack and version, switch between base and ve…

…rsion pages
  • Loading branch information...
1 parent d6c1b0b commit 496e0330e0dee5e18710f807e836d0484d7fab7a @zalun zalun committed Feb 10, 2010
Showing with 35 additions and 3 deletions.
  1. +11 −0 flightdeck/jetpack/models.py
  2. +20 −1 flightdeck/jetpack/views.py
  3. +4 −2 flightdeck/urls.py
@@ -21,6 +21,10 @@ class Jetpack(models.Model):
public_permission = models.IntegerField(choices=PERMISSIONS_CHOICES, default=2, blank=True)
group_permission = models.IntegerField(choices=PERMISSIONS_CHOICES, default=2, blank=True)
+ @models.permalink
+ def get_absolute_url(self):
+ return ('jetpack_edit_base',[self.slug])
+
def set_slug(self):
from utils import random_string
check_slug = True
@@ -62,6 +66,13 @@ class Version(models.Model):
published = models.BooleanField(default=False, blank=True)
is_base = models.BooleanField(default=False, blank=True)
+ def __unicode__(self):
+ return "%s v%s" % (self.jetpack.name, self.name)
+
+ @models.permalink
+ def get_absolute_url(self):
+ return ('jetpack_edit_version',[self.jetpack.slug, self.name])
+
def default_name(instance, **kwargs):
"""
@@ -1 +1,20 @@
-# Create your views here.
+from django.shortcuts import render_to_response, get_object_or_404
+from django.http import Http404, HttpResponseRedirect, HttpResponse
+from django.template import Template,RequestContext
+
+from jetpack.models import Jetpack, Version
+from jetpack.default_settings import settings
+
+def edit_base(r, slug):
+ jetpack = get_object_or_404(Jetpack, slug=slug)
+ version = jetpack.base_version
+ jetpack_page = True
+ return render_to_response('edit.html', locals(),
+ context_instance=RequestContext(r))
+
+def edit_version(r, slug, version):
+ version = get_object_or_404(Version, jetpack__slug=slug, name=version)
+ jetpack = version.jetpack
+ return render_to_response('edit.html', locals(),
+ context_instance=RequestContext(r))
+
View
@@ -17,9 +17,11 @@
# Example:
url(r'^$',base_views.placeholder, name='placeholder'),
- # docutils
+ # admin
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
- # application
(r'^admin/', include(admin.site.urls)),
+
+ # Jetpack
+ (r'^', include('jetpack.urls')),
])
urlpatterns = patterns('', *urls)

0 comments on commit 496e033

Please sign in to comment.