pdf: hide fields mapping on create and edit views (#75078)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Thomas NOËL 2023-03-03 02:59:38 +01:00
parent 24a0491d7a
commit e34f385be2
2 changed files with 15 additions and 0 deletions

View File

@ -115,6 +115,11 @@ class Resource(BaseResource):
class Meta:
verbose_name = _('PDF')
@classmethod
def get_manager_form_class(cls, **kwargs):
kwargs['exclude'] = tuple(kwargs.get('exclude') or ()) + ('fields_mapping',)
return super().get_manager_form_class(**kwargs)
def run_pdftk(self, args):
args = [settings.PDFTK_PATH] + args + ['output', '-']
try:

View File

@ -213,3 +213,13 @@ def test_fill_form_ok(app, admin_user, pdf, cerfa_content):
pdf_ = PDF(resp.content)
page = pdf_.page(0)
assert not page.fields
def test_add_or_edit(app, admin_user, pdf, cerfa_content):
app = login(app)
resp = app.get('/manage/pdf/add')
assert b'fields_mapping' not in resp.content
pdf.fill_form_file.save('form.pdf', ContentFile(cerfa_content))
resp = app.get('/manage/pdf/test/edit')
assert b'fields_mapping' not in resp.content