From 289d9ebef6e13899da59b3a8c5dd8d148f8420bb Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 28 Jan 2016 16:09:44 +0000 Subject: [PATCH] Moved some path checks from SubmissionUploadForm to the ietf/checks.py. - Legacy-Id: 10753 --- ietf/checks.py | 29 +++++++++++++++++++++++++++++ ietf/submit/forms.py | 6 ------ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/ietf/checks.py b/ietf/checks.py index 4036d3720..70ae3daf8 100644 --- a/ietf/checks.py +++ b/ietf/checks.py @@ -67,3 +67,32 @@ def check_doc_email_aliases_exists(app_configs, **kwargs): return errors +@checks.register('directories') +def check_id_submission_directories(app_configs, **kwargs): + errors = [] + for s in ("IDSUBMIT_STAGING_PATH", "IDSUBMIT_REPOSITORY_PATH", "INTERNET_DRAFT_ARCHIVE_DIR"): + p = getattr(settings, s) + if not os.path.exists(p): + errors.append(checks.Critical( + "A directory used by the ID submission tool does not exist at the path given\n" + "in the settings file. The setting is:\n" + " %s = %s" % (s, p), + hint = ("Please either update the local settings to point at the correct directory," + "or if the setting is correct, create the directory."), + id = "datatracker.E0006", + )) + +@checks.register('files') +def check_id_submission_directories(app_configs, **kwargs): + errors = [] + for s in ("IDSUBMIT_IDNITS_BINARY", ): + p = getattr(settings, s) + if not os.path.exists(p): + errors.append(checks.Critical( + "A file used by the ID submission tool does not exist at the path given\n" + "in the settings file. The setting is:\n" + " %s = %s" % (s, p), + hint = ("Please either update the local settings to point at the correct file," + "or if the setting is correct, make sure the file is in place and has the right permissions."), + id = "datatracker.E0007", + )) diff --git a/ietf/submit/forms.py b/ietf/submit/forms.py index abf0716fe..efe05e25d 100644 --- a/ietf/submit/forms.py +++ b/ietf/submit/forms.py @@ -118,12 +118,6 @@ class SubmissionUploadForm(forms.Form): if self.shutdown and not has_role(self.request.user, "Secretariat"): raise forms.ValidationError('The submission tool is currently shut down') - # sanity check that paths exist (for development servers) - for s in ("IDSUBMIT_STAGING_PATH", "IDSUBMIT_IDNITS_BINARY", - "IDSUBMIT_REPOSITORY_PATH", "INTERNET_DRAFT_ARCHIVE_DIR"): - if not os.path.exists(getattr(settings, s)): - raise forms.ValidationError('%s defined in settings.py does not exist' % s) - for ext in ['txt', 'pdf', 'xml', 'ps']: f = self.cleaned_data.get(ext, None) if not f: