Skip to content
Snippets Groups Projects
Commit c66ef3da authored by Dominik Seeger's avatar Dominik Seeger
Browse files

empty comments are no longer possible

parent 5a0d6732
No related branches found
No related tags found
1 merge request!186Resolve "Empty comments can be created which are not deletable, Feedback can be submitted"
Pipeline #107804 passed
......@@ -163,6 +163,11 @@ class FeedbackSerializer(DynamicFieldsModelSerializer):
for comment in data.get('feedback_lines', {}):
lines_in_submission = len(submission.text.split('\n'))
if comment['text'] == '' and 'labels' not in comment:
raise serializers.ValidationError(
"Cannot create feedback with an empty comment attached to it"
)
if not 0 < comment['of_line'] <= lines_in_submission:
raise serializers.ValidationError(
"Cannot comment line number %d of %d" % (
......
......@@ -104,11 +104,18 @@ export default class CommentForm extends mixins(commentLabelSelector) {
}
submitFeedback () {
const text = this.currentFeedback
const labels = this.labelsUnchanged.concat(this.labelsAdded)
if (text === "" && labels.length === 0) {
return this.collapseTextField()
}
const payload = {
lineNo: Number(this.lineNo),
comment: {
text: this.currentFeedback,
labels: this.labelsUnchanged.concat(this.labelsAdded),
text: text,
labels: labels,
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment