Skip to content

Commit

Permalink
commit comment code
Browse files Browse the repository at this point in the history
  • Loading branch information
Liiuliu committed Sep 24, 2021
1 parent f136d5d commit 7f01364
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 8 deletions.
7 changes: 1 addition & 6 deletions vulfocus-api/layout_image/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1527,8 +1527,7 @@ def get_layout_det(req):
layout_dict['layout_name'] = layout_info.layout_name
layout_dict['layout_desc'] = layout_info.layout_desc
layout_dict['layout_raw_content'] = layout_info.raw_content
# layout_dict['image_name'] = 'http://vulfocus.fofa.so/images/'+layout_info.image_name
layout_dict['image_name'] = 'http://vulfocus.fofa.so/images/'+layout_info.image_name # 测试
layout_dict['image_name'] = 'http://vulfocus.fofa.so/images/'+layout_info.image_name
data = layout_dict
else:
data = []
Expand All @@ -1545,15 +1544,13 @@ def download_official_website_layout(request):
data = request.data
id = data['layout_id'] # 真实官网id
user = request.user
# id = 'c4a22b44-e4d9-460d-b650-4cb94b08c055' # 测试id
url = "http://vulfocus.fofa.so/api/layoutinfodet?layout_id={}".format(id)
res = requests.get(url, verify=False).content
req = json.loads(res)
raw_data = req['data']['layout_raw_content']
raw_data = yaml.load(raw_data, Loader=yaml.Loader)
static_url = os.path.join(BASE_DIR, "static")
img_url = req['data']['image_name'] # 官网图片
# img_url = 'http://vulfocus.fofa.so/images/51880ddc18b8461aa14ec79264f7fcf5.jpg' # 测试拼接照片地址
con = requests.get(img_url, verify=False).content # 下载官网图片写入文件夹
imagename = str(uuid.uuid4()) # 图片名称随机uuid
if not os.path.exists(static_url):
Expand Down Expand Up @@ -1783,8 +1780,6 @@ def get_official_website_layout(request):
'''
获取官网编排场景信息(社区)
'''

# url = "http://vulfocus.fofa.so/api/get/layoutinfo/" # 官网地址
url = "http://vulfocus.fofa.so/api/get/layoutinfo/"
try:
res = requests.get(url, verify=False).content
Expand Down
14 changes: 14 additions & 0 deletions vulfocus-api/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,20 @@ def create(self, request, *args, **kwargs):
comment_info.save()
return JsonResponse({"status": 200, "message": '评论成功'})

@action(methods=["get"], detail=True, url_path="delete")
def del_comment(self, request, pk=None):
user = request.user
if not pk:
return JsonResponse(R.build(msg="参数不能为空"))
comment_info = Comment.objects.filter(comment_id=pk).first()
if not comment_info:
return JsonResponse(R.build(msg="评论不存在"))
if not user.is_superuser and comment_info.user != user:
return JsonResponse(R.build(msg="权限不足"))
comment_info.delete()
return JsonResponse(R.ok())



@api_view(http_method_names=["POST"])
def upload_user_img(request):
Expand Down
9 changes: 9 additions & 0 deletions vulfocus-frontend/src/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,13 @@ export function getComment(sceneId) {
})
}

/**
* 删除评论
*/
export function CommentDelete(id) {
return request({
url: '/comment/'+id+'/delete/'
})
}


26 changes: 24 additions & 2 deletions vulfocus-frontend/src/views/scene/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
<el-main>
<el-row>
<span class="span2">环境描述</span>
<!-- <el-link type="primary" size="mini">编辑</el-link>-->
</el-row>
<el-row style="margin-top: 24px">
<span class="span3"> {{layout.desc}} </span>
Expand Down Expand Up @@ -134,6 +135,9 @@
</el-row>
<el-row style="margin-top: 5px">
<span>{{item.content}}</span>
<el-button size="mini" v-if="isAdmin===true || userAuth===item.username" @click="delComment(item.comment_id)" style="float: right;margin-top: -5px">
删除
</el-button>
</el-row>
</el-main>
</el-container>
Expand Down Expand Up @@ -207,7 +211,7 @@
import { mapGetters } from 'vuex'
import {sceneGet, sceneStart, sceneStop,sceneFlag, sceneRank} from '@/api/scene'
import { commitComment, getComment } from '@/api/user'
import { commitComment, getComment, CommentDelete } from '@/api/user'
import CountDown from "vue2-countdown";
import verification from "./verification";
Expand Down Expand Up @@ -253,6 +257,7 @@ export default {
dialogVisible:false,
verificationCode:"",
commentCode:"",
userAuth:"",
}
},
computed: {
Expand All @@ -267,6 +272,7 @@ export default {
if (this.roles.length >0 &&this.roles[0] === "admin"){
this.isAdmin = true
}
this.userAuth = this.name
this.initModelInfo()
this.handleRank(1)
this.initComment()
Expand Down Expand Up @@ -520,7 +526,23 @@ export default {
getComment(sceneId).then(response=>{
this.contentList = response.data.results
})
}
},
delComment(id){
CommentDelete(id).then(response=>{
if (response.data.status === 200){
this.$message({
message: "删除成功",
type: 'success'
})
this.initComment()
}else {
this.$message({
message: response.data.msg,
type: "error",
})
}
})
},
}
}
</script>
Expand Down

0 comments on commit 7f01364

Please sign in to comment.