Moved some path checks from SubmissionUploadForm to the ietf/checks.py.

- Legacy-Id: 10753
This commit is contained in:
Henrik Levkowetz 2016-01-28 16:09:44 +00:00
parent 041532dc5e
commit 289d9ebef6
2 changed files with 29 additions and 6 deletions

View file

@ -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",
))

View file

@ -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: