pedagogy: base for uv comment moderation

This commit is contained in:
2019-06-20 01:29:12 +02:00
parent 437af4dd04
commit 3d0f5c0a15
6 changed files with 87 additions and 21 deletions

View File

@ -27,7 +27,7 @@ from django import forms
from core.views.forms import MarkdownInput
from core.models import User
from pedagogy.models import UV, UVComment
from pedagogy.models import UV, UVComment, UVCommentReport
class UVForm(forms.ModelForm):
@ -100,3 +100,25 @@ class UVCommentForm(forms.ModelForm):
self.fields["author"].initial = author_id
self.fields["uv"].queryset = UV.objects.filter(id=uv_id).all()
self.fields["uv"].initial = uv_id
class UVCommentReportForm(forms.ModelForm):
"""
Form handeling creation and edit of an UVReport
"""
class Meta:
model = UVCommentReport
fields = ("comment", "reporter", "reason")
widgets = {
"comment": forms.HiddenInput,
"reporter": forms.HiddenInput,
"reason": MarkdownInput,
}
def __init__(self, reporter_id, comment_id, *args, **kwargs):
super(UVCommentReportForm, self).__init__(*args, **kwargs)
self.fields["reporter"].queryset = User.objects.filter(id=reporter_id).all()
self.fields["reporter"].initial = reporter_id
self.fields["comment"].queryset = UVComment.objects.filter(id=comment_id).all()
self.fields["comment"].initial = comment_id