From ae57d90cf337d55b34e999e397929e120c97b354 Mon Sep 17 00:00:00 2001 From: moanos Date: Thu, 30 May 2024 14:39:28 +0200 Subject: [PATCH] feat: Style comment field --- src/fellchensammlung/forms.py | 9 +++++- .../static/fellchensammlung/css/styles.css | 29 ++++++++++++++----- .../fellchensammlung/forms/form-comment.html | 16 ++++++---- src/fellchensammlung/views.py | 2 +- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/fellchensammlung/forms.py b/src/fellchensammlung/forms.py index 70ecb92..9901fb2 100644 --- a/src/fellchensammlung/forms.py +++ b/src/fellchensammlung/forms.py @@ -40,7 +40,6 @@ class AdoptionNoticeForm(forms.ModelForm): fields = ['name', "group_only", "further_information", "description", "searching_since"] - class ImageForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -59,11 +58,19 @@ class ReportForm(forms.ModelForm): model = Report fields = ('reported_broken_rules', 'comment') + 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: model = Comment fields = ('text',) + class ModerationActionForm(forms.ModelForm): class Meta: model = ModerationAction diff --git a/src/fellchensammlung/static/fellchensammlung/css/styles.css b/src/fellchensammlung/static/fellchensammlung/css/styles.css index bcbed39..2be60f7 100644 --- a/src/fellchensammlung/static/fellchensammlung/css/styles.css +++ b/src/fellchensammlung/static/fellchensammlung/css/styles.css @@ -84,7 +84,7 @@ h1, h2 { border-radius: 4px; } -.header a, form { +.header a, .header form { float: left; padding: 5px 12px 5px 12px; line-height: 25px; @@ -383,12 +383,10 @@ h1, h2 { padding: 5px; } -form { - padding: 20px; -} - -.form-group { - margin: 30px; +#form-adoption-notice { + .form-group { + margin: 30px; + } } .detail-adoption-notice-header h1 { @@ -427,4 +425,21 @@ form { padding: 5px; background: var(--background-three); 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; + } } \ No newline at end of file diff --git a/src/fellchensammlung/templates/fellchensammlung/forms/form-comment.html b/src/fellchensammlung/templates/fellchensammlung/forms/form-comment.html index 7c06780..2b4ab33 100644 --- a/src/fellchensammlung/templates/fellchensammlung/forms/form-comment.html +++ b/src/fellchensammlung/templates/fellchensammlung/forms/form-comment.html @@ -1,7 +1,13 @@ {% load i18n %} +{% load crispy_forms_tags %} +
+

+ + {% blocktrans %} + Als {{ user }} kommentieren + {% endblocktrans %} + -

- {% csrf_token %} - {{ comment_form.as_p }} - -
\ No newline at end of file + {% crispy comment_form %} +

+
\ No newline at end of file diff --git a/src/fellchensammlung/views.py b/src/fellchensammlung/views.py index 8de6f24..f981a02 100644 --- a/src/fellchensammlung/views.py +++ b/src/fellchensammlung/views.py @@ -57,7 +57,7 @@ def adoption_notice_detail(request, adoption_notice_id): raise PermissionDenied else: 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)