This commit is contained in:
wrmswindmill 2018-09-16 23:05:14 +08:00
parent 5109e58554
commit dbc50e39f9
3 changed files with 68 additions and 37 deletions

View File

@ -17,7 +17,7 @@ Including another URLconf
from django.urls import path
from .views import ShowIssueQuestionView, ShowAnnotationView, ShowNavigationView
from .views import AddAnnotationView, AddArticleView, AddQuestionView, AddIssueAnswerView, AddCommentView,Collect_Search_Answer
from .views import UpdateAnnotationView, UpdateArticleView, UpdateQuestionView, UpdateAnswerView, UpdateCommentView,RightView,GetJstreeIdView
from .views import UpdateAnnotationView, UpdateArticleView, UpdateQuestionView, UpdateAnswerView, UpdateCommentView,RightView,GetJstreeIdView,DeleteView
from .views import AddVoteView, AcceptAnswerView, ShowMethodInfo, GetHotestIssuesView, Get_CodeReading_Content_View, AddQuestionAnswerView, GetAddtabParasView,ModifyAnnotationView
app_name = "operations"
@ -46,4 +46,5 @@ urlpatterns = [
path('right/',RightView.as_view(),name='right/'),
path('get_jstree_id/',GetJstreeIdView.as_view(),name='get_jstree_id/'),
path('submit_search_answer/',Collect_Search_Answer.as_view(),name='submit_search_answer/'),
path('delete/',DeleteView.as_view(),name="delete/")
]

View File

@ -11,7 +11,7 @@ from django.db.models import Count
from .models import Annotation, Question, QuestionAnswer, Article, Issue, IssueAnswer, IssueStandardAnswers, IssueChoices,Search_Answer
from .models import AnnotationComment, QuestionComment, QuestionAnswerComment, ArticleComment, IssueComment, AnnotationStrategy,Competition
from .models import AnnotationComment, QuestionAnswerComment, ArticleComment, IssueComment, AnnotationStrategy,Competition
from .models import Vote
from users.models import User
from .forms import NewArticleForm
@ -435,6 +435,30 @@ def get_currentfile_language(file):
return "txt"
class DeleteView(View):
def post(self,request):
try:
object_id = request.POST.get("object_id","")
object_type = request.POST.get("object_type","")
if object_type=="Annotation":
annotation = Annotation.objects.get(id=object_id,is_latest=1)
annotation.is_latest = 0
annotation.save()
elif object_type == "Question":
Question.objects.filter(id=object_id).delete()
elif object_type == "QuestionAnswer":
QuestionAnswer.objects.filter(id=object_id).delete()
elif object_type == "AnnotationComment":
AnnotationComment.objects.filter(id=object_id).delete()
elif object_type == "IssueComment":
IssueComment.objects.filter(id=object_id).delete()
elif object_type == 'QuestionAnswerComment':
QuestionAnswerComment.objects.filter(id=object_id).delete()
return HttpResponse('{"status":"success","msg":"删除成功"}', content_type='application/json')
except:
return HttpResponse('{"status":"fail","msg":"删除失败"}', content_type='application/json')
class ModifyAnnotationView(View):
"""
@ -475,7 +499,7 @@ class ModifyAnnotationView(View):
# 把之前的is_latest设置为0
annotation.is_latest = 0
annotation.save()
anno_content = get_currentfile_comment_anno(file,content)
anno_content = get_currentfile_QuestionAnswerComment_anno(file,content)
return HttpResponse(json.dumps({"status": "success", "msg":"修改成功","anno_content":anno_content}), content_type='application/json')
else:
return HttpResponse(json.dumps({"status": "fail", "msg":"修改失败"}), content_type='application/json')

View File

@ -151,6 +151,7 @@ function modify_anno(file_id,line_num,anno_id){
});
}
// FIXME
function show_issue_question(file_id, line_num, issue_ids) {
issueid_str=issue_ids.toString()
@ -777,45 +778,50 @@ function url_deal(path,archor){
// 打开一个已经存在的标签页
// 注意这个还得将对应的路径更改了
function open_tab(path,archor) {
try{
// console.log(window.location.pathname); 端口号后面的路径
path_input=path
path = path_predeal(path)
path_input=path
path = path_predeal(path)
$('#jstree').jstree("deselect_all", true);
$('#jstree').jstree("select_node", tree_nodes[path]);
$('#jstree').jstree("deselect_all", true);
$('#jstree').jstree("select_node", tree_nodes[path]);
var tabcontent = document.getElementsByClassName("codereading");
for (var i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
var tabcontent = document.getElementsByClassName("codereading");
for (var i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
var tab_items = document.getElementsByClassName("tab_item");
for (var i = 0; i < tab_items.length; i++) {
// debugger;
tab_items[i].className = tab_items[i].className.replace(" active", "");
}
document.getElementById("code_" + path).style.display = "block";
document.getElementById("tab_" + path).style.display = "block";
document.getElementById("tab_" + path).className += " active";
url_deal(path_input,archor)
document.getElementsByClassName("filename")[0].innerHTML = path_input;
if((path in right_map)){
$("#right_panel").html(right_map[path]);
}
// if(!issue_map.has(path)){
// window.setTimeout(function () { $("#hotest_issue").html(issue_map[path]) }, 3000);
// }else{
// $("#hotest_issue").html(issue_map[path]);
// }
show_navigation();
}catch(error) {
console.error(error);
// expected output: SyntaxError: unterminated string literal
// Note - error messages will vary depending on browser
}
var tab_items = document.getElementsByClassName("tab_item");
for (var i = 0; i < tab_items.length; i++) {
// debugger;
tab_items[i].className = tab_items[i].className.replace(" active", "");
}
document.getElementById("code_" + path).style.display = "block";
document.getElementById("tab_" + path).style.display = "block";
document.getElementById("tab_" + path).className += " active";
url_deal(path_input,archor)
document.getElementsByClassName("filename")[0].innerHTML = path_input;
if(!path in right_map){
window.setTimeout(function () { $("#right_panel").html(right_map[path]) }, 3000);
}else{
$("#right_panel").html(right_map[path]);
}
// if(!issue_map.has(path)){
// window.setTimeout(function () { $("#hotest_issue").html(issue_map[path]) }, 3000);
// }else{
// $("#hotest_issue").html(issue_map[path]);
// }
show_navigation();
}
function generate_codereading_content(lines,self_annos,fileid,annos_count,issues_count,questions_count,issues,language){