Refined the URL patterns and handling of alternative meeting material file formats, which were broken by an earlier refactoring (v6.57.0). Fixes issue #2436.
- Legacy-Id: 14521
This commit is contained in:
parent
87f4997bf5
commit
07fd714c88
|
@ -551,18 +551,16 @@ def document_main(request, name, rev=None):
|
|||
content = None
|
||||
other_types = []
|
||||
globs = glob.glob(pathname + ".*")
|
||||
url = doc.href()
|
||||
urlbase, urlext = os.path.splitext(url)
|
||||
for g in globs:
|
||||
extension = os.path.splitext(g)[1]
|
||||
t = os.path.splitext(g)[1].lstrip(".")
|
||||
url = doc.href()
|
||||
if not url.endswith("/") and not url.endswith(extension):
|
||||
urlbase, urlext = os.path.splitext(url)
|
||||
url = urlbase + extension
|
||||
|
||||
if extension == ".txt":
|
||||
content = doc.text_or_error() # pyflakes:ignore
|
||||
t = "plain text"
|
||||
|
||||
other_types.append((t, url))
|
||||
|
||||
return render(request, "doc/document_material.html",
|
||||
|
|
|
@ -61,7 +61,7 @@ type_ietf_only_patterns = [
|
|||
type_interim_patterns = [
|
||||
url(r'^agenda/(?P<session>[A-Za-z0-9-]+)-drafts.pdf$', views.session_draft_pdf),
|
||||
url(r'^agenda/(?P<session>[A-Za-z0-9-]+)-drafts.tgz$', views.session_draft_tarfile),
|
||||
url(r'^materials/%(document)s/?$' % settings.URL_REGEXPS, views.materials_document),
|
||||
url(r'^materials/%(document)s((?P<ext>\.[a-z0-9]+)|/)?$' % settings.URL_REGEXPS, views.materials_document),
|
||||
]
|
||||
|
||||
type_ietf_only_patterns_id_optional = [
|
||||
|
@ -80,7 +80,7 @@ type_ietf_only_patterns_id_optional = [
|
|||
url(r'^week-view(?:.html)?/?$', views.week_view),
|
||||
url(r'^room-view(?:.html)?/?$', views.room_view),
|
||||
url(r'^materials(?:.html)?/?$', views.materials),
|
||||
url(r'^materials/%(document)s/?$' % settings.URL_REGEXPS, views.materials_document),
|
||||
url(r'^materials/%(document)s((?P<ext>\.[a-z0-9]+)|/)?$' % settings.URL_REGEXPS, views.materials_document),
|
||||
url(r'^session/?$', views.materials_editable_groups),
|
||||
url(r'^proceedings(?:.html)?/?$', views.proceedings),
|
||||
url(r'^proceedings(?:.html)?/finalize/?$', views.finalize_proceedings),
|
||||
|
|
|
@ -156,7 +156,7 @@ def current_materials(request):
|
|||
raise Http404('No such meeting')
|
||||
|
||||
@cache_page(1 * 60)
|
||||
def materials_document(request, document, num=None, ):
|
||||
def materials_document(request, document, num=None, ext=None):
|
||||
if num is None:
|
||||
num = get_meeting(num).number
|
||||
doc = get_object_or_404(Document, name=document)
|
||||
|
@ -165,7 +165,10 @@ def materials_document(request, document, num=None, ):
|
|||
if not doc.session_set.filter(meeting__number=num).exists():
|
||||
raise Http404("No such document for meeting %s" % num)
|
||||
filename = doc.get_file_name()
|
||||
basename = doc.get_base_name()
|
||||
if ext and not filename.endswith(ext):
|
||||
name, _ = os.path.splitext(filename)
|
||||
filename = name + ext
|
||||
_, basename = os.path.split(filename)
|
||||
if not os.path.exists(filename):
|
||||
raise Http404("File not found: %s" % filename)
|
||||
with open(filename, 'rb') as file:
|
||||
|
|
|
@ -594,9 +594,9 @@ DOC_HREFS = {
|
|||
}
|
||||
|
||||
MEETING_DOC_HREFS = {
|
||||
"agenda": "/meeting/{meeting.number}/materials/{doc.name}/",
|
||||
"minutes": "/meeting/{meeting.number}/materials/{doc.name}/",
|
||||
"slides": "/meeting/{meeting.number}/materials/{doc.name}/",
|
||||
"agenda": "/meeting/{meeting.number}/materials/{doc.name}",
|
||||
"minutes": "/meeting/{meeting.number}/materials/{doc.name}",
|
||||
"slides": "/meeting/{meeting.number}/materials/{doc.name}",
|
||||
"recording": "{doc.external_url}",
|
||||
"bluesheets": "https://www.ietf.org/proceedings/{meeting.number}/bluesheets/{doc.external_url}",
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue