def new(self, format='html'): """GET /projects/new: Form to create a new item""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance' c.debug = is_debug_mode() return render('/new_project.html')
def show(self, id, format='html'): """GET /projects/id: Show a specific item""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance' c.project = read_project(id) return render('/show_project.html')
def index(self, format='html'): """GET /projects: All items in the collection""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance' sub = get_project_subdir_names() c.subdirs = [get_project_summary_tuple(i) for i in sub] return render('/projects.html')
def delete(self, id): """DELETE /projects/id: Delete an existing item""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance' # Forms posted to this method should contain a hidden field: # <input type="hidden" name="_method" value="DELETE" /> # Or using helpers: # h.form(url('project', id=ID), # method='delete') # url('project', id=ID) return u'blah delete'
def create(self): """POST /projects: Create a new item""" # Figure out what the next number to use for the subdirectory -- not guaranteed to be unique across instances, so this is not too crucial if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance' schema = NewProjectForm() try: c.form_result = schema.to_python(dict(request.params)) except formencode.Invalid, error: c.form_result = error.value c.form_errors = error.error_dict or {} html = render('/new_project.html') return htmlfill.render( html, defaults=c.form_result, errors=c.form_errors )
def edit(self, id, format='html'): """GET /projects/id/edit: Form to edit an existing item""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance'
def update(self, id): """PUT /projects/id: Update an existing item""" if not serves_projects(): response.status = '403 Forbidden (projects not enabled for this phyloplumber instance)' return 'Projects not enabled for this phyloplumber instance'
def index(self): if serves_projects(): redirect(url(controller='projects', action='index')) else: redirect(url(controller='services', action='index'))