def issues_record(request, project_id, issues_id): """ 问题记录 & 评论 """ if request.method == "GET": reply_list = models.IssuesReply.objects.filter( issues_id=issues_id, issues__project=request.tracer.project) # queryset --> json data_list = [] for row in reply_list: data = { "id": row.id, "reply_type": row.get_reply_type_display(), "content": row.content, "creator": row.creator.name, "create_datetime": row.create_datetime, "reply_id": row.reply_id } data_list.append(data) return JsonResponse({"status": True, "data": data_list}) form = IssuesReplyModelForm(data=request.POST) if form.is_valid(): form.instance.reply_type = 2 form.instance.issues_id = issues_id form.instance.creator = request.tracer.user instance = form.save() info = { "id": instance.id, "reply_type": instance.get_reply_type_display(), "content": instance.content, "creator": instance.creator.name, "create_datetime": instance.create_datetime, "reply_id": instance.reply_id } return JsonResponse({"status": True, "data": info}) return JsonResponse({"status": False, "error": form.errors})
def issues_record(request, project_id, issues_id): if request.method == 'GET': reply_list = models.IssuesReply.objects.filter(issues_id=issues_id, issues__project=request.tracer.project) data_list = [] for row in reply_list: data = { 'id': row.id, 'reply_type_text': row.get_reply_type_display(), 'content': row.content, 'creator': row.creator.username, 'datetime': row.create_datetime.strftime('%Y-%m-%d %H:%M'), 'parent_id': row.reply_id } data_list.append(data) return JsonResponse({'status': True, 'data': data_list}) form = IssuesReplyModelForm(data=request.POST) if form.is_valid(): form.instance.issues_id = issues_id form.instance.reply_type = 2 form.instance.creator = request.tracer.user instance = form.save() info = { 'id': instance.id, 'reply_type_text': instance.get_reply_type_display(), 'content': instance.content, 'creator': instance.creator.username, 'datetime': instance.create_datetime.strftime('%Y-%m-%d %H:%M'), 'parent_id': instance.reply_id } return JsonResponse({'status': True, 'data': info}) return JsonResponse({'status': False, 'error': form.errors})
def issue_record(request, project_id, issue_id): """初始化操作记录""" if request.method == 'GET': reply_list = models.IssuesReply.objects.filter( issue_id=issue_id, issue__project=request.bug_mgt.project) # 将queryset转化为json格式 data_list = [] for row in reply_list: data = { 'id': row.id, 'reply_type': row.get_reply_type_display(), 'content': row.content, 'creator': row.creator.username, 'datetime': row.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': row.reply_id } data_list.append(data) return JsonResponse({'status': True, 'data': data_list}) form = IssuesReplyModelForm(data=request.POST) print(form) if form.is_valid(): form.instance.issue_id = issue_id form.instance.creator = request.bug_mgt.user form.instance.reply_type = 2 instance = form.save() info = { 'id': instance.id, 'reply_type': instance.get_reply_type_display(), 'content': instance.content, 'creator': instance.creator.username, 'datetime': instance.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': instance.reply_id } return JsonResponse({'status': True, 'data': info}) return JsonResponse({'status': False, 'error': form.errors})
def issues_record(request, project_id, issues_id): """ 初始化操作记录 """ # 判断是否可以评论和是否可以操作这个问题 # 目前的判断是:只要能进入这个项目就能评论这个问题 if request.method == "GET": reply_list = models.IssuesReply.objects.filter( issues_id=issues_id, issues__project=request.tracer.project) # 将queryset转换为json格式 data_list = [] for row in reply_list: data = { 'id': row.id, 'reply_type_text': row.get_reply_type_display(), 'content': row.content, 'creator': row.creator.username, 'datetime': row.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': row.reply_id } data_list.append(data) return JsonResponse({'status': True, 'data': data_list}) form = IssuesReplyModelForm(data=request.POST) if form.is_valid(): form.instance.issues_id = issues_id form.instance.reply_type = 2 form.instance.creator = request.tracer.user instance = form.save() info = { 'id': instance.id, 'reply_type_text': instance.get_reply_type_display(), 'content': instance.content, 'creator': instance.creator.username, 'datetime': instance.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': instance.reply_id } return JsonResponse({'status': True, 'data': info}) return JsonResponse({'status': False, 'error': form.errors})
def issues_record(request, project_id, issues_id): """问题的记录""" if request.method == "GET": reply_list = IssuesReply.objects.filter(issues__project_id=project_id, issues_id=issues_id) data_list = [] for row in reply_list: data = { 'id': row.id, 'reply_type_text': row.get_reply_type_display(), 'content': row.content, 'create_user': row.create_user.username, 'datetime': row.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': row.reply_id } data_list.append(data) return JsonResponse({'code': 200, 'msg': data_list}) if request.method == "POST": """评论回复""" form = IssuesReplyModelForm(request.POST) if form.is_valid(): form.instance.issues_id = issues_id form.instance.reply_type = 2 form.instance.create_user = request.tracer.user instance = form.save() data = { 'id': instance.id, 'reply_type_text': instance.get_reply_type_display(), 'content': instance.content, 'create_user': instance.create_user.username, 'datetime': instance.create_datetime.strftime("%Y-%m-%d %H:%M"), 'parent_id': instance.reply_id } return JsonResponse({'code': 200, 'msg': data}) return JsonResponse({'code': 416, 'msg': "评论失败"})
def issues_record(request, project_id, issues_id): """ 初始化操作记录 """ # 判断是否可以评论和是否可以操作这个问题 if request.method == "GET": reply_list = models.IssuesReply.objects.filter( issues_id=issues_id, issues__project=request.tracer.project) # 将queryset转换为json格式 data_list = [] for row in reply_list: data = { "id": row.id, "reply_type_text": row.get_reply_type_display(), "content": row.content, "creator": row.creator.username, "datetime": row.create_datetime.strftime("%Y-%m-%d %H:%M"), "parent_id": row.reply_id, } data_list.append(data) return JsonResponse({"status": True, "data": data_list}) form = IssuesReplyModelForm(data=request.POST) if form.is_valid(): form.instance.issues_id = issues_id form.instance.reply_type = 2 form.instance.creator = request.tracer.user instance = form.save() info = { "id": instance.id, "reply_type_text": instance.get_reply_type_display(), "content": instance.content, "creator": instance.creator.username, "datetime": instance.create_datetime.strftime("%Y-%m-%d %H:%M"), "parent_id": instance.reply_id, } return JsonResponse({"status": True, "data": info}) return JsonResponse({"status": False, "error": form.errors})