Skip to content

Commit 418281c

Browse files
author
sumandari
authored
Merge pull request #230 from sumandari/229_fix_comment_textholder
fixed comment placeholder text
2 parents 9debebd + 03ff279 commit 418281c

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

qgis-app/base/forms/processing_forms.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ class ResourceBaseReviewForm(forms.Form):
1010
APPROVAL_OPTIONS = [('approve', 'Approve'), ('reject', 'Reject')]
1111
approval = forms.ChoiceField(required=True, choices=APPROVAL_OPTIONS,
1212
widget=forms.RadioSelect, initial='approve')
13-
comment = forms.CharField(widget=forms.Textarea(
14-
attrs={'placeholder': _('Please provide clear feedback if you decided '
15-
'to not approve this GeoPackage.'),
16-
'rows': "5"}))
13+
comment = forms.CharField()
14+
15+
def __init__(self, *args, **kwargs):
16+
self.resource_name = kwargs.pop('resource_name', 'resource')
17+
super(ResourceBaseReviewForm, self).__init__(*args, **kwargs)
18+
self.fields['comment'].widget = forms.Textarea(
19+
attrs={
20+
'placeholder': _(
21+
'Please provide clear feedback if you decided to not '
22+
'approve this %s.') % self.resource_name,
23+
'rows': "5"})
24+
1725

1826

1927
class ResourceBaseSearchForm(forms.Form):

qgis-app/base/views/processing_view.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,9 @@ def get_context_data(self, **kwargs):
299299
.username
300300
context['reviewer'] = reviewer
301301
if user.is_staff or is_resources_manager(user):
302-
context['form'] = ResourceBaseReviewForm()
302+
context['form'] = ResourceBaseReviewForm(
303+
resource_name=self.resource_name
304+
)
303305
if self.is_3d_model:
304306
context['url_viewer'] = "%s_viewer" % self.resource_name_url_base
305307
return context
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from django.test import TestCase
2+
3+
from base.forms.processing_forms import ResourceBaseReviewForm
4+
5+
6+
class TestFormResourceBaseReviewForm(TestCase):
7+
def test_review_form_comment_includes_resource_name(self):
8+
form = ResourceBaseReviewForm(resource_name='test resource')
9+
self.assertIn(
10+
'placeholder="Please provide clear feedback if you decided to not '
11+
'approve this test resource." required id="id_comment"',
12+
form.as_table()
13+
)

0 commit comments

Comments
 (0)