feat: Style comment field

This commit is contained in:
moanos [he/him] 2024-05-30 14:39:28 +02:00
parent aebbe0f6c6
commit ae57d90cf3
4 changed files with 42 additions and 14 deletions

View File

@ -40,7 +40,6 @@ class AdoptionNoticeForm(forms.ModelForm):
fields = ['name', "group_only", "further_information", "description", "searching_since"] fields = ['name', "group_only", "further_information", "description", "searching_since"]
class ImageForm(forms.ModelForm): class ImageForm(forms.ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -59,11 +58,19 @@ class ReportForm(forms.ModelForm):
model = Report model = Report
fields = ('reported_broken_rules', 'comment') fields = ('reported_broken_rules', 'comment')
class CommentForm(forms.ModelForm): class CommentForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-comments'
self.helper.add_input(Submit('submit', _('Kommentieren')))
class Meta: class Meta:
model = Comment model = Comment
fields = ('text',) fields = ('text',)
class ModerationActionForm(forms.ModelForm): class ModerationActionForm(forms.ModelForm):
class Meta: class Meta:
model = ModerationAction model = ModerationAction

View File

@ -84,7 +84,7 @@ h1, h2 {
border-radius: 4px; border-radius: 4px;
} }
.header a, form { .header a, .header form {
float: left; float: left;
padding: 5px 12px 5px 12px; padding: 5px 12px 5px 12px;
line-height: 25px; line-height: 25px;
@ -383,13 +383,11 @@ h1, h2 {
padding: 5px; padding: 5px;
} }
form { #form-adoption-notice {
padding: 20px;
}
.form-group { .form-group {
margin: 30px; margin: 30px;
} }
}
.detail-adoption-notice-header h1 { .detail-adoption-notice-header h1 {
width: 50%; width: 50%;
@ -428,3 +426,20 @@ form {
background: var(--background-three); background: var(--background-three);
color: var(--text-two); color: var(--text-two);
} }
.container-comment-form {
width: 80%;
color: var(--text-one);
}
textarea {
border-radius: 10px;
width: 100%;
margin: 5px;
}
.form-comments {
.btn {
margin: 5px;
}
}

View File

@ -1,7 +1,13 @@
{% load i18n %} {% load i18n %}
{% load crispy_forms_tags %}
<div class="container-comment-form">
<p>
<b>
{% blocktrans %}
Als {{ user }} kommentieren
{% endblocktrans %}
</b>
<form method="post" enctype="multipart/form-data"> {% crispy comment_form %}
{% csrf_token %} </p>
{{ comment_form.as_p }} </div>
<button class="button-report" type="submit">{% translate "Kommentieren" %}</button>
</form>

View File

@ -57,7 +57,7 @@ def adoption_notice_detail(request, adoption_notice_id):
raise PermissionDenied raise PermissionDenied
else: else:
comment_form = CommentForm(instance=adoption_notice) comment_form = CommentForm(instance=adoption_notice)
context = {"adoption_notice": adoption_notice, "comment_form": comment_form} context = {"adoption_notice": adoption_notice, "comment_form": comment_form, "user": request.user}
return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context) return render(request, 'fellchensammlung/details/detail_adoption_notice.html', context=context)