views are loading the jetpack and version, switch between base and version pages

This commit is contained in:
zalun 2010-02-10 14:23:40 +00:00
Родитель d6c1b0bdce
Коммит 496e0330e0
3 изменённых файлов: 35 добавлений и 3 удалений

Просмотреть файл

@ -21,6 +21,10 @@ class Jetpack(models.Model):
public_permission = models.IntegerField(choices=PERMISSIONS_CHOICES, default=2, blank=True) public_permission = models.IntegerField(choices=PERMISSIONS_CHOICES, default=2, blank=True)
group_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): def set_slug(self):
from utils import random_string from utils import random_string
check_slug = True check_slug = True
@ -62,6 +66,13 @@ class Version(models.Model):
published = models.BooleanField(default=False, blank=True) published = models.BooleanField(default=False, blank=True)
is_base = 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): 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))

Просмотреть файл

@ -17,9 +17,11 @@ urls.extend([
# Example: # Example:
url(r'^$',base_views.placeholder, name='placeholder'), url(r'^$',base_views.placeholder, name='placeholder'),
# docutils # admin
(r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# application
(r'^admin/', include(admin.site.urls)), (r'^admin/', include(admin.site.urls)),
# Jetpack
(r'^', include('jetpack.urls')),
]) ])
urlpatterns = patterns('', *urls) urlpatterns = patterns('', *urls)