def get(request): frontend_data = FrontEndData() project_datas = [] b_projects = BProjectRepository.get().get_projects_for_user( request.user) for b_project in b_projects: project_datas.append({ 'id': b_project.id, 'name': b_project.name, 'description': b_project.description, 'isManagedByUser': b_project.is_managed_by_user, 'isStaredByUser': b_project.is_stared_by_user, 'createdAt': b_project.created_at.strftime('%Y年%m月%d日') }) frontend_data.add('projects', project_datas) c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'frontend_data': frontend_data }) return render_to_response('project/projects.html', c)
def get(request): project_id = request.GET['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) creater = b_project.creater members = [] for member in b_project.members: members.append({ 'id': member.id, 'name': member.name, 'thumbnail': member.thumbnail, 'isManager': member.is_manager, 'isCreater': member.id == creater.id }) frontend_data = FrontEndData() frontend_data.add('members', members) frontend_data.add('projectId', project_id) frontend_data.add_user_permissions( b_project.get_user_permissions(request.user)) c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'frontend_data': frontend_data }) return render_to_response('project/members.html', c)
def get(request): project_id = request.GET.get('id', None) b_project = BProjectRepository.get_project_by_id(project_id) c = RequestContext(request, {'first_nav_name': FIRST_NAV}) return render_to_response('project/project.html', c)
def api_delete(request): project_id = request.POST['id'] b_project = BProjectRepository.get().get_project_by_id(project_id) b_project.unstar_by_user(request.user) response = create_response(200) return response.get_response()
def api_post(request): project_id = request.POST['id'] b_project = BProjectRepository.get().get_project_by_id(project_id) b_project.update(request.POST['name'], request.POST['description']) response = create_response(200) return response.get_response()
def api_delete(request): project_id = request.POST['project_id'] member_id = request.POST['member_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) b_project.delete_member(member_id) response = create_response(200) return response.get_response()
def api_put(request): project_id = request.POST['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) user_ids = json.loads(request.POST['user_ids']) b_project.add_members(user_ids) response = create_response(200) return response.get_response()
def get(request): project_id = request.GET.get('id', None) b_project = BProjectRepository.get().get_project_by_id(project_id) frontend_data = FrontEndData() frontend_data.add('projectId', request.GET['project_id']) c = RequestContext(request, { 'first_nav_name': FIRST_NAV, 'frontend_data': frontend_data }) return render_to_response('project/kanban.html', c)
def api_get(request): project_id = request.GET['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) members = [] for member in b_project.candidate_members: members.append({'id': member.id, 'name': member.name}) response = create_response(200) response.data = {'members': members} return response.get_response()
def api_get(request): project_id = request.GET.get('id', None) b_project = BProjectRepository.get().get_project_by_id(project_id) response = create_response(200) response.data = { 'id': b_project.id, 'name': b_project.name, 'description': b_project.description } return response.get_response()
def api_put(request): project_id = request.POST['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) b_project.add_requirement({ "owner": request.user, "title": request.POST['title'], "importance": request.POST['importance'], "content": request.POST['content'] }) response = create_response(200) return response.get_response()
def get(request): project_id = request.GET['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) frontend_data = FrontEndData() frontend_data.add('projectId', project_id) frontend_data.add_user_permissions( b_project.get_user_permissions(request.user)) c = RequestContext( request, { 'first_nav_name': FIRST_NAV, 'second_navs': nav.get_requirement_second_navs(project_id), 'second_nav_name': 'project-business-requirements', 'frontend_data': frontend_data }) return render_to_response('project/business_requirements.html', c)
def api_post(request): requirement_id = request.POST['requirement_id'] b_project = BProjectRepository.get().get_project_by_id( request.POST['project_id']) field = FIELD_MAP.get(request.POST['field'], None) value = request.POST['value'] if not field: response = create_response(500) response.errMsg = u'不支持更新该属性' else: if not b_project.update_business_requirement( requirement_id, field, value): response = create_response(500) response.errMsg = u'更新属性失败' else: response = create_response(200) return response.get_response()
def api_get(request): project_id = request.GET['project_id'] b_project = BProjectRepository.get().get_project_by_id(project_id) cur_page = request.GET.get('page', 1) pageinfo, b_requirements = b_project.get_business_requirements( cur_page, request.GET) #组装数据 rows = [] for b_requirement in b_requirements: creater = b_requirement.creater rows.append({ 'id': b_requirement.id, 'title': b_requirement.title, 'importance': b_requirement.importance, 'creater': { "id": creater.id, "name": creater.name, "thumbnail": creater.thumbnail }, 'subRequirements': 0, 'storyPoint': 0, 'createdAt': b_requirement.created_at.strftime('%Y.%m.%d') }) data = {'rows': rows, 'pagination_info': pageinfo.to_dict()} #构造response response = create_response(200) response.data = data return response.get_response()