def create_page_post(context, request): data = request.POST page = Page(data['title']) page.layout_template = u'master.html' for behaviour in data.getall('behaviour'): page.update(behaviour, data, behaviour + '.') context[data['uid']] = page location = model_url(page, request) return HTTPFound(location = location)
def rebuild(wipe_sysgen=False): ''' Designed to be run from shell. Will wipe DB and load data from file system. ''' url_list = [] for root, dirs, files in os.walk(PAGE_PATH): head = root.replace(PAGE_PATH, '') path = head.split(os.sep) for file in files: url = '/'.join(path + [file]) if url[-1:] == '_': url = url[:-1] else: url = url + '/' print url url_list.append(url) confirm = raw_input('About to create {} pages. Ready to wipe DB ([y]/n)? '.format(len(url_list))) if confirm and confirm.upper() != 'Y': print 'Aborting...' sys.exit() print 'Deleting all Page data' Page.objects.all().delete() if wipe_sysgen: print 'Wiping sysgen' for file in os.listdir(SYSGEN_PATH): file_path = os.path.join(SYSGEN_PATH, file) if os.isdir(file_path): shutil.rmtree(file_path) else: os.unlink(file_path) for url in sorted(url_list): print 'Creating: ', url page = Page(url=url) page.update()
def rebuild(pull_docinfo=True, wipe_sysgen=False): ''' Designed to be run from shell. Will wipe DB and load data from file system. ''' pg_list = [] for root, dirs, files in os.walk(wiki_pages_path): head = root.replace(wiki_pages_path, '') path = head.split(os.sep) for file in files: pg = '/'.join(path + [file]) if pg[-1:] == '_': pg = pg[:-1] else: pg = pg + '/' print pg pg_list.append(pg) confirm = raw_input('About to create {} pages. Ready to wipe DB ([y]/n)? '.format(len(pg_list))) if confirm and confirm.upper() != 'Y': print 'Aborting...' sys.exit() print 'Deleting all Page data' Page.objects.all().delete() if wipe_sysgen: print 'Wiping sysgen' for file in os.listdir(SYSGEN_FOLDER): file_path = os.path.join(SYSGEN_FOLDER, file) if os.isdir(file_path): shutil.rmtree(file_path) else: os.unlink(file_path) for pg in sorted(pg_list): print 'Creating: ', pg page = Page(pg=pg) page.update(pull_docinfo=pull_docinfo)