def create(self, request): """ Creates a new Page, either placed in the same level before or after a certain Page, or as last child below a certain parent Page. """ attrs = self.flatten_dict(request.POST) try: page_title = attrs['title'] page_relative_url = attrs['relative_url'] except KeyError: return rc.BAD_REQUEST page = Page(title=page_title, relative_url=page_relative_url) if 'before_page_id' in attrs: before_page = Page.objects.get(pk=int(attrs['before_page_id'])) page.parent = before_page.parent page.insert_at(before_page, position='left', save=False) elif 'below_page_id' in attrs: below_page = Page.objects.get(pk=int(attrs['below_page_id'])) page.parent = below_page page.insert_at(below_page, position='last-child', save=False) page.save() return rc.CREATED
def create_django_page_tree(): mainmenu=Page(title='mainmenu') mainmenu.save() home = Page.objects.create(title='home', parent=mainmenu, url='home', template_name='base/home.html') detail = Page.objects.create(title='detail', parent=home, url='home/detail', template_name='base/detail.html') join = Page.objects.create(title='join', parent=home, url='join', template_name='base/join.html') members = Page.objects.create(title='members', parent=home, url='members', template_name='base/members.html') meetings = Page.objects.create(title='meetings', parent=mainmenu, url='meetings', template_name='')
def create_django_page_tree(): mainmenu=Page(title='mainmenu') mainmenu.save() home=Page(title='home', parent=mainmenu, url='home', template_name='base/home.html') home.save() join=Page(title='join', parent=home, url='join', template_name='base/join.html') join.save() members=Page(title='members', parent=home, url='members', template_name='base/members') members.save() meetings = Page(title='meetings', parent=mainmenu, url='meetings', template_name='') meetings.save()
def create_fiber_page(self): # TODO add handler if meetings page does not exist. # A method to automatically build the necessary blank fiber page for a meeting instance # Requires that a meetings page exists. Meeting detail pages are # created under the meetings page meetings_page = Page.objects.get(title="meetings") # test if a meeting detail page already exists try: Page.objects.get(title=self.title) # if it doesn't exist, create a new page except ObjectDoesNotExist: # it not there create it p = Page(title=self.title, parent=meetings_page, url=self.year) p.show_in_menu=False p.save() else: print("Page already exists")
def index(request): materials = Material.objects.all() try: fiber_page = Page.objects.get(url__exact='/materials') except Page.DoesNotExist: # if there is no page, just make it page = Page(url='/materials', title="Materials") page.save() fiber_page = page t = loader.get_template('index.html') c = RequestContext(request, { 'fiber_page': fiber_page, 'materials': materials }) return HttpResponse(t.render(c))
def create_django_page_tree(): mainmenu = Page(title='mainmenu') mainmenu.save() home = Page(title='home', parent=mainmenu, url='home', template_name='arcana_home.html') home.save() about = Page(title='about', parent=mainmenu, url='about', template_name='arcana_2col_left.html') about.save() workshops=Page(title='workshops', parent=mainmenu, url='workshops', template_name='') workshops.save() data = Page(title='data', parent=mainmenu, url='data', template_name='') data.save() tools = Page(title='tools', parent=mainmenu, url='tools', template_name='') tools.save() standards = Page(title='standards', parent=mainmenu, url='standards', template_name='') standards.save()
def create_django_page_tree(): mainmenu = Page(title='mainmenu') mainmenu.save() Home = Page(title='Home', parent=mainmenu, url='home', template_name='arcana_home.html') Home.save() data = Page(title='Data', parent=Home, url='data', template_name='') data.save() MLP = Page(title='MLP', parent=Home, url='mlp', template_name='') data.save() Upload = Page(title='Upload', parent=MLP, url='upload', template_name='') data.save() kml = Page(title='Data', parent=Upload, url='kml', template_name='') data.save()
def create_fiber_page_tree(): mainmenu = Page(title='mainmenu') mainmenu.save()
def create_django_page_tree(): mainmenu = Page(title='mainmenu') mainmenu.save() home = Page(title='home', parent=mainmenu, url='home', template_name='arcana_home.html') home.save() data = Page(title='Data', parent=home, url='data', template_name='') data.save() san_francisco = Page(title='san_francisco', parent=home, url='san_francisco', template_name='') data.save() upload = Page(title='upload', parent=san_francisco, url='upload', template_name='') data.save() kml = Page(title='Data', parent=upload, url='kml', template_name='') kml.save() data.save()
def create_fiber_page_tree(): mainmenu=Page(title='mainmenu') mainmenu.save()
def create_django_page_tree(): mainmenu=Page(title='mainmenu') mainmenu.save() Home = Page(title='Home', parent=mainmenu, url='home', template_name='arcana_home.html') Home.save() data = Page(title='Data', parent=Home, url='data', template_name='') data.save() MLP = Page(title='MLP', parent=Home, url='mlp', template_name='') data.save() Upload = Page(title='Upload', parent=MLP, url='upload', template_name='') data.save() kml = Page(title='Data', parent=Upload, url='kml', template_name='') data.save()
def create_django_page_tree(): mainmenu = Page(title='mainmenu') mainmenu.save() home = Page(title='home', parent=mainmenu, url='home', template_name='arcana_home.html') home.save() data = Page(title='Data', parent=home, url='data', template_name='') data.save() mlp = Page(title='mlp', parent=home, url='mlp', template_name='') data.save() upload = Page(title='upload', parent=mlp, url='upload', template_name='') data.save() kml = Page(title='Data', parent=upload, url='kml', template_name='') kml.save() data.save()