base page
This commit is contained in:
parent
3558441b43
commit
aa5f443442
2 changed files with 19 additions and 8 deletions
|
@ -13,14 +13,20 @@ class UserAdmin(UserAdmin, ModelAdmin): pass
|
|||
class GroupAdmin(GroupAdmin, ModelAdmin): pass
|
||||
|
||||
@admin.register(Site)
|
||||
class SiteAdmin(ModelAdmin): pass
|
||||
class SiteAdmin(ModelAdmin):
|
||||
list_display = ["domain","base_page"]
|
||||
list_editable = ["base_page"]
|
||||
|
||||
@admin.register(Page)
|
||||
class PageAdmin(ModelAdmin): pass
|
||||
|
||||
@admin.register(Url)
|
||||
class UrlAdmin(ModelAdmin): pass
|
||||
class UrlAdmin(ModelAdmin):
|
||||
list_display = ["site","page","path"]
|
||||
list_display_links = ["path"]
|
||||
list_editable = ["site","page"]
|
||||
|
||||
@admin.register(Variable)
|
||||
class VariableAdmin(ModelAdmin): pass
|
||||
|
||||
class VariableAdmin(ModelAdmin):
|
||||
list_display = ["name","value"]
|
||||
list_editable = ["value"]
|
|
@ -7,12 +7,17 @@ from django.http import HttpResponse
|
|||
context = template.Context({})
|
||||
class MainView(View):
|
||||
def get(self,request):
|
||||
site = get_object_or_404(Site,domain=request.META["HTTP_HOST"])
|
||||
t = template.Template(site.base_page.content)
|
||||
return HttpResponse(t.render(context))
|
||||
return PageView.get(self,request,'root')
|
||||
|
||||
class PageView(View):
|
||||
def get(self,request,page):
|
||||
r = get_object_or_404(Url,path=page)
|
||||
s = get_object_or_404(Site,domain=request.META["HTTP_HOST"])
|
||||
r = get_object_or_404(Url,path=page,site=s)
|
||||
t = template.Template(r.page.content)
|
||||
content = t.render(context)
|
||||
context.update({
|
||||
"content": content,
|
||||
"title": r.page.title
|
||||
})
|
||||
t = template.Template(s.base_page.content)
|
||||
return HttpResponse(t.render(context))
|
Loading…
Reference in a new issue