From e6b43dd8cd77a742fa4647b70cf979ee3d173b68 Mon Sep 17 00:00:00 2001 From: wrmswindmill Date: Tue, 7 Aug 2018 21:12:32 +0800 Subject: [PATCH] Merge And Solve Conflict --- apps/operations/views.py | 22 ++++++++++++++++++++-- apps/projects/views.py | 1 - templates/projects/filesub/annotation.html | 15 --------------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/apps/operations/views.py b/apps/operations/views.py index f593c4f..ce84e77 100644 --- a/apps/operations/views.py +++ b/apps/operations/views.py @@ -732,13 +732,26 @@ class Get_CodeReading_Content_View(View): return HttpResponse(json.dumps({"status": "success", "html_str": html_str}), content_type='application/json') # 根据path确定它是不是文件 # (目前的判断方法是查看File_Anno_Issue_Summary表中是否有parentDir为传入的path,如果有说明是文件夹) - isDir = (len(FileAnnoIssueSummary.objects.filter(project_id=project_id,parent_path=path))>0) if isDir: + isDir = (len(FileSummary.objects.filter(project_id=project_id,parent_path=path))>0) + if isDir: html_str = get_dir_info(project_id,path) return HttpResponse(json.dumps({"status": "success", "html_str": html_str,"is_dir":"1"}), content_type='application/json') else: html_str = get_code(request,project_id,path) return HttpResponse(json.dumps({"status": "success", "html_str": html_str,"is_dir":"0"}), content_type='application/json') # html_str = html_str.replace('style="background-color: white;"',"") +def get_self_annos_by_fileid(user_id,file_id): + self_anno_map = {} + try: + annos = Annotation.objects.filter(file_id=file_id,user_id=user_id) + for anno in annos: + self_anno_map[str(anno.linenum)] = anno.content + return self_anno_map + except: + return self_anno_map + + +def get_code(request,project_id,path): project = Project.objects.filter(id=project_id).first() file = File.objects.filter(path=path, project_id=project_id).first() @@ -758,6 +771,11 @@ class Get_CodeReading_Content_View(View): questions_count = {} for i in questions: questions_count[str(i['linenum'])] = i['nums'] + + if request.user.is_authenticated: + self_annos = get_self_annos_by_fileid(request.user.pk,fileid) + else: + self_annos = {} html_str = render_to_string('projects/filesub/code-reading.html', locals()) return html_str @@ -793,7 +811,7 @@ def get_project_info(project_id): usersum = len(annos.values('user_id').annotate(user_num=Count('user_id'))) anno_filenum = len(annos.values( 'file_id').annotate(file_num=Count('file_id'))) - anno_issue_summarys = FileAnnoIssueSummary.objects.filter( + anno_issue_summarys = FileSummary.objects.filter( project_id=project_id, parent_path="") #当前文件夹下所有的file_ids以及fileid与filename的映射 diff --git a/apps/projects/views.py b/apps/projects/views.py index d6acc8d..ea9214b 100644 --- a/apps/projects/views.py +++ b/apps/projects/views.py @@ -41,7 +41,6 @@ class NewProjectView(View): stragegy.project = project stragegy.choice = 1 - return HttpResponse("Scanner Done!!") # logging.info(str(datetime.now()) + '导入工程完成') all_projects = Project.objects.all() return render(request, 'projects/list.html', locals()) diff --git a/templates/projects/filesub/annotation.html b/templates/projects/filesub/annotation.html index ed32c5d..25aa641 100644 --- a/templates/projects/filesub/annotation.html +++ b/templates/projects/filesub/annotation.html @@ -3,20 +3,6 @@

该代码块共有{{annos|length}}个注释

-
-
- - {% if comment.annotation.pk == self_anno.pk %} -
- {{ comment.content }} - {{ comment.user.nick_name }} -
-
- {% endif %} - {% endfor %} - - {% else %} -
其他人的注释:
{% for anno in annos%} {% if self_anno is None or anno.id != self_anno.id %}
@@ -52,6 +38,5 @@
{% endif %} {% endfor %} - {% endif %} \ No newline at end of file