Merged [3380] from esanchez@yaco.es:

Check for missed files on staging area. Fixes #707
 - Legacy-Id: 3447
Note: SVN reference [3380] has been migrated to Git commit 0d241bd7c0abf8942d5c121aa9dda5ee34cf75ae
This commit is contained in:
Henrik Levkowetz 2011-10-13 15:38:50 +00:00
parent 1e27d3b619
commit 34dfae8d23
4 changed files with 33 additions and 7 deletions

View file

@ -4,6 +4,9 @@ from django import template
from django.conf import settings
from django.utils.html import mark_safe, escape
from ietf.submit.utils import POSTED, POSTED_BY_SECRETARIAT
register = template.Library()
@ -11,10 +14,15 @@ register = template.Library()
def show_submission_files(context, submission):
result = []
for ext in submission.file_type.split(','):
exists = False
source = os.path.join(settings.IDSUBMIT_STAGING_PATH, '%s-%s%s' % (submission.filename, submission.revision, ext))
if os.path.exists(source):
result.append({'name': '[%s version ]' % ext[1:].capitalize(),
'url': '%s%s-%s%s' % (settings.IDSUBMIT_STAGING_URL, submission.filename, submission.revision, ext)})
exists = True
elif submission.status_id in [POSTED, POSTED_BY_SECRETARIAT]:
continue
result.append({'name': '[%s version ]' % ext[1:].capitalize(),
'exists': exists,
'url': '%s%s-%s%s' % (settings.IDSUBMIT_STAGING_URL, submission.filename, submission.revision, ext)})
return {'files': result}
def show_two_pages(context, two_pages, validation):

View file

@ -273,6 +273,16 @@ class DraftValidation(object):
self.validate_abstract()
self.validate_creation_date()
self.validate_wg()
self.validate_files()
def validate_files(self):
if self.draft.status_id in [POSTED, POSTED_BY_SECRETARIAT]:
return
for ext in self.draft.file_type.split(','):
source = os.path.join(settings.STAGING_PATH, '%s-%s%s' % (self.draft.filename, self.draft.revision, ext))
if not os.path.exists(source):
self.add_warning('document_files', 'Some files are not found on staging area.<br />We recommend you that you cancel this submission and upload your files again.')
break
def validate_title(self):
if not self.draft.id_document_name:

View file

@ -138,11 +138,15 @@ returned to the submitter.
{% endif %}
<table class="metadata-table">
<tr><th>Document</th><td>
{% ifequal status.status_value "Posted" %}<a href="http://www.ietf.org/id/{{ detail.filename }}-{{detail.revision}}.txt">{{ detail.filename }}</a>{% else %}{{ detail.filename }}{% endifequal %}
<br/><a class="twopages_trigger" href="#">[View first two pages]</a>
{% show_submission_files detail %}
</td></tr>
<tr{% if validation.warnings.document_files %} class="warning"{% endif %}>
<th>Document</th>
<td>
{% ifequal status.status_value "Posted" %}<a href="http://www.ietf.org/id/{{ detail.filename }}-{{detail.revision}}.txt">{{ detail.filename }}</a>{% else %}{{ detail.filename }}{% endifequal %}
<br/><a class="twopages_trigger" href="#">[View first two pages]</a>
{% show_submission_files detail %}
<div class="warn_message">{{ validation.warnings.document_files|safe }}</div>
</td>
</tr>
<tr{% if validation.warnings.revision %} class="warning"{% endif %}><th>Revision</th><td>{{ detail.revision }}<div class="warn_message">{{ validation.warnings.revision }}{% if validation.warnings.revision %}<br /><a class="twopages_trigger" href="#">[View error]</a>{% endif %}</div></td></tr>
<tr{% if validation.warnings.group %} class="warning"{% endif %}><th>WG</th><td>{{ validation.wg|default:"Individual Submission" }}<div class="warn_message">{{ validation.warnings.group }}</div></td></tr>
<tr{% if validation.warnings.creation_date %} class="warning"{% endif %}><th>Document date</th><td>{{ detail.creation_date }}<div class="warn_message">{{ validation.warnings.creation_date }}</div></td></tr>

View file

@ -1,7 +1,11 @@
{% if files %}
<ul>
{% for file in files %}
{% if file.exists %}
<li><a href="{{ file.url }}" target="_blank">{{ file.name }}</a></li>
{% else %}
<li style="color: red;"><span style="text-decoration: line-through;">{{ file.name }}</span> This file is not found on staging area</li>
{% endif %}
{% endfor %}
</ul>
{% endif %}