def _q_index(request): context = {} current_user = request.user if current_user and request.method == "POST": name = request.get_form_var('name') description = request.get_form_var('description') p = Project.add(name=name, description=description, owner_id=current_user.id, creator_id=current_user.id) if p: return request.redirect('%s' % p.repo_name) has_proj = Project.get_by_name_and_owner(name, current_user.id) default_error = 'Create Failure. Please contact the administrator!' if has_proj is not None: context['error'] = 'Project has exists, Please confirm!' else: context['error'] = default_error context['current_user'] = current_user return st('/errors/common.html', **context) projects = Project.gets_by() context['projects'] = projects context['current_user'] = current_user return st('projects/index.html', **context)
def _q_index(request): context = {} current_user = request.user if current_user and request.method == "POST": name = request.get_form_var('name') description = request.get_form_var('description') p = Project.add(name=name, description=description, owner_id=current_user.id, creator_id=current_user.id) if p: return request.redirect('projects/%s' % p.name) context['project'] = p return st('projects/index.html', **context) projects = Project.gets_by() context['projects'] = projects context['current_user'] = current_user return st('projects/index.html', **context)
def _q_index(request): context = {} current_user = request.user if current_user and request.method == "POST": name = request.get_form_var('name') description = request.get_form_var('description') p = Project.add(name=name, description=description, owner_id=current_user.id, creator_id=current_user.id) if p: return request.redirect('%s' % p.repo_name) context['project'] = p return st('projects/index.html', **context) projects = Project.gets_by() context['projects'] = projects context['current_user'] = current_user return st('projects/index.html', **context)
def test_add(self): proj_name = "test_project" proj = Project.add(name=proj_name, owner_id=1, creator_id=1) assert proj.name == proj_name