Refactored all_id.txt/1id-index.txt/1id-abstracts.txt code (abstracts HTML page generation still missing)
- Legacy-Id: 1735
This commit is contained in:
parent
d6fa5e851f
commit
445bb44e30
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from ietf.idtracker.models import IDInternal
|
||||
from ietf.idtracker.models import InternetDraft
|
||||
from ietf.idtracker.models import IDStatus
|
||||
|
||||
|
||||
# This block feels to me like it still knows _way_ too much about the insides of the model - should all of it be moved into the model itself?
|
||||
# select_related actually causes the wrong thing to happen because of reference problems in the tables
|
||||
#all_ids = InternetDraft.objects.order_by('filename').select_related(depth=1)
|
||||
all_ids = InternetDraft.objects.order_by('filename')
|
||||
in_track_ids = all_ids.filter(idinternal__rfc_flag=0).exclude(idinternal__cur_state__in=IDInternal.INACTIVE_STATES)
|
||||
exclude_ids = [item.id_document_tag for item in in_track_ids]
|
||||
not_in_track = all_ids.exclude(id_document_tag__in=exclude_ids)
|
||||
active = not_in_track.filter(status__status_id=IDInternal.ACTIVE)
|
||||
published = not_in_track.filter(status__status_id=IDInternal.PUBLISHED)
|
||||
expired = not_in_track.filter(status__status_id=IDInternal.EXPIRED)
|
||||
withdrawn_submitter = not_in_track.filter(status__status_id=IDInternal.WITHDRAWN_SUBMITTER)
|
||||
withdrawn_ietf = not_in_track.filter(status__status_id=IDInternal.WITHDRAWN_IETF)
|
||||
replaced = not_in_track.filter(status__status_id=IDInternal.REPLACED)
|
||||
|
||||
# If all of that moved, then this file would just be the following line, with, for example, the bare
|
||||
# in_track_ids turned into something like InternetDraft.in_track_ids()
|
||||
|
||||
print render_to_string("idindex/all_ids.txt",{ 'in_track_ids':in_track_ids,
|
||||
'active':active,
|
||||
'published':published,
|
||||
'expired':expired,
|
||||
'withdrawn_submitter':withdrawn_submitter,
|
||||
'withdrawn_ietf':withdrawn_ietf,
|
||||
'replaced':replaced})
|
38
ietf/idindex/generate_all_id_txt.py
Normal file
38
ietf/idindex/generate_all_id_txt.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Portions Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
||||
from ietf.idindex.views import all_id_txt
|
||||
print all_id_txt(),
|
38
ietf/idindex/generate_id_abstracts_txt.py
Normal file
38
ietf/idindex/generate_id_abstracts_txt.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Portions Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
||||
from ietf.idindex.views import id_abstracts_txt
|
||||
print id_abstracts_txt(),
|
38
ietf/idindex/generate_id_index_txt.py
Normal file
38
ietf/idindex/generate_id_index_txt.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Portions Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from ietf import settings
|
||||
from django.core import management
|
||||
management.setup_environ(settings)
|
||||
|
||||
from ietf.idindex.views import id_index_txt
|
||||
print id_index_txt(),
|
|
@ -23,3 +23,6 @@
|
|||
200 /drafts/?first_name=joe
|
||||
200 /drafts/?other_group=irtf
|
||||
200 /drafts/?wg_id=1682
|
||||
200 /drafts/_test/all_id.txt
|
||||
200 /drafts/_test/id_index.txt
|
||||
200 /drafts/_test/id_abstracts.txt
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.defaults import patterns
|
||||
from ietf.idtracker.models import InternetDraft
|
||||
from ietf.idindex import views
|
||||
|
@ -32,3 +33,10 @@ urlpatterns = patterns('',
|
|||
(r'^all_id.html$', views.all_id, { 'template_name': 'idindex/all_id.html' }),
|
||||
(r'^$', views.search),
|
||||
)
|
||||
|
||||
if settings.SERVER_MODE != 'production':
|
||||
urlpatterns += patterns('',
|
||||
(r'^_test/all_id.txt$', views.test_all_id_txt),
|
||||
(r'^_test/id_index.txt$', views.test_id_index_txt),
|
||||
(r'^_test/id_abstracts.txt$', views.test_id_abstracts_txt)
|
||||
)
|
||||
|
|
|
@ -1,5 +1,37 @@
|
|||
# Copyright The IETF Trust 2007, All Rights Reserved
|
||||
|
||||
# Portions Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
# All rights reserved. Contact: Pasi Eronen <pasi.eronen@nokia.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
#
|
||||
# * Neither the name of the Nokia Corporation and/or its
|
||||
# subsidiary(-ies) nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
from django.http import HttpResponse, HttpResponsePermanentRedirect
|
||||
from django.views.generic.list_detail import object_list
|
||||
from django.db.models import Q
|
||||
|
@ -8,7 +40,7 @@ from django.template import RequestContext, loader
|
|||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.views.generic.list_detail import object_detail
|
||||
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, Rfc
|
||||
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, Rfc, IDInternal
|
||||
from ietf.idindex.forms import IDIndexSearchForm
|
||||
from ietf.idindex.models import alphabet, orgs, orgs_dict
|
||||
from ietf.utils import orl, flattenl, normalize_draftname
|
||||
|
@ -171,6 +203,42 @@ def all_id(request, template_name):
|
|||
return render_to_response(template_name, {'object_list': object_list},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def all_id_txt():
|
||||
all_ids = InternetDraft.objects.order_by('filename')
|
||||
in_track_ids = all_ids.filter(idinternal__rfc_flag=0).exclude(idinternal__cur_state__in=IDInternal.INACTIVE_STATES)
|
||||
exclude_ids = [item.id_document_tag for item in in_track_ids]
|
||||
not_in_track = all_ids.exclude(id_document_tag__in=exclude_ids)
|
||||
active = not_in_track.filter(status__status_id=IDInternal.ACTIVE)
|
||||
published = not_in_track.filter(status__status_id=IDInternal.PUBLISHED)
|
||||
expired = not_in_track.filter(status__status_id=IDInternal.EXPIRED)
|
||||
withdrawn_submitter = not_in_track.filter(status__status_id=IDInternal.WITHDRAWN_SUBMITTER)
|
||||
withdrawn_ietf = not_in_track.filter(status__status_id=IDInternal.WITHDRAWN_IETF)
|
||||
replaced = not_in_track.filter(status__status_id=IDInternal.REPLACED)
|
||||
|
||||
return loader.render_to_string("idindex/all_ids.txt",
|
||||
{ 'in_track_ids':in_track_ids,
|
||||
'active':active,
|
||||
'published':published,
|
||||
'expired':expired,
|
||||
'withdrawn_submitter':withdrawn_submitter,
|
||||
'withdrawn_ietf':withdrawn_ietf,
|
||||
'replaced':replaced})
|
||||
|
||||
def id_index_txt():
|
||||
groups = IETFWG.objects.all()
|
||||
return loader.render_to_string("idindex/id_index.txt", {'groups':groups})
|
||||
|
||||
def id_abstracts_txt():
|
||||
groups = IETFWG.objects.all()
|
||||
return loader.render_to_string("idindex/id_abstracts.txt", {'groups':groups})
|
||||
|
||||
def test_all_id_txt(request):
|
||||
return HttpResponse(all_id_txt(), mimetype='text/plain')
|
||||
def test_id_index_txt(request):
|
||||
return HttpResponse(id_index_txt(), mimetype='text/plain')
|
||||
def test_id_abstracts_txt(request):
|
||||
return HttpResponse(id_abstracts_txt(), mimetype='text/plain')
|
||||
|
||||
def related_docs(startdoc):
|
||||
related = []
|
||||
processed = []
|
||||
|
|
|
@ -749,6 +749,8 @@ class IDAuthor(models.Model):
|
|||
return self.person.emailaddress_set.filter(type='I-D').get(priority=self.document_id).address
|
||||
except EmailAddress.DoesNotExist:
|
||||
return None
|
||||
def id_index_sort_key(self):
|
||||
return "%08d%08d" % (self.author_order, self.person_id)
|
||||
class Meta:
|
||||
db_table = 'id_authors'
|
||||
verbose_name = "I-D Author"
|
||||
|
|
|
@ -4,7 +4,7 @@ import textwrap
|
|||
import django
|
||||
from django import template
|
||||
from django.utils.html import escape, fix_ampersands, linebreaks
|
||||
from django.template.defaultfilters import linebreaksbr
|
||||
from django.template.defaultfilters import linebreaksbr, wordwrap
|
||||
try:
|
||||
from email import utils as emailutils
|
||||
except ImportError:
|
||||
|
@ -313,6 +313,34 @@ def wrap_long_lines(text):
|
|||
filled += [ line.rstrip() ]
|
||||
return "\n".join(filled)
|
||||
|
||||
@register.filter(name="id_index_file_types")
|
||||
def id_index_file_types(text):
|
||||
r = ".txt"
|
||||
if text.find("txt") < 0:
|
||||
return r
|
||||
if text.find("ps") >= 0:
|
||||
r = r + ",.ps"
|
||||
if text.find("pdf") >= 0:
|
||||
r = r + ",.pdf"
|
||||
return r
|
||||
|
||||
@register.filter(name="id_index_wrap")
|
||||
def id_index_wrap(text):
|
||||
x = wordwrap(text, 72)
|
||||
x = x.replace("\n", "\n ")
|
||||
return " "+x.strip()
|
||||
|
||||
@register.filter(name="id_abstracts_wrap")
|
||||
def id_abstracts_wrap(text):
|
||||
text = text.replace("\n", " ")
|
||||
x = wordwrap(text, 70)
|
||||
x = x.replace("\n", "\n ")
|
||||
return " "+x.strip()
|
||||
|
||||
@register.filter(name="id_index_underline")
|
||||
def id_index_underline(text):
|
||||
return "-"*len(text.strip())
|
||||
|
||||
@register.filter(name='greater_than')
|
||||
def greater_than(x, y):
|
||||
return x > int(y)
|
||||
|
|
9
ietf/templates/idindex/id_abstracts.txt
Normal file
9
ietf/templates/idindex/id_abstracts.txt
Normal file
|
@ -0,0 +1,9 @@
|
|||
{% extends "idindex/id_index.txt" %}{% load ietf_filters %} {% block intro %} Current Internet-Drafts
|
||||
|
||||
This summary sheet provides a short synopsis of each Internet-Draft
|
||||
available within the "internet-drafts" directory at the shadow
|
||||
sites directory. These drafts are listed alphabetically by working
|
||||
group acronym and start date.
|
||||
{% endblock %}{% block abstract %}
|
||||
|
||||
{{ draft.abstract.strip|id_abstracts_wrap }}{% endblock %}
|
15
ietf/templates/idindex/id_index.txt
Normal file
15
ietf/templates/idindex/id_index.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
{% load ietf_filters %}{% block intro %} Current Internet-Drafts
|
||||
This summary sheet provides an index of each Internet-Draft
|
||||
These drafts are listed alphabetically by Working Group acronym and
|
||||
initial post date.
|
||||
{% endblock %}
|
||||
{% for group in groups|dictsort:"group_acronym.acronym" %}{% if group.active_drafts %}
|
||||
{{ group.group_acronym.name }} ({{ group.group_acronym.acronym}})
|
||||
{% filter id_index_underline %}
|
||||
{{ group.group_acronym.name }} ({{ group.group_acronym.acronym}})
|
||||
{% endfilter %}
|
||||
{% for draft in group.active_drafts|dictsort:"start_date" %}
|
||||
{% filter id_index_wrap %}
|
||||
"{{draft.title.strip}}", {% for author in draft.authors.all|dictsort:"id_index_sort_key" %}{{author.person}}, {% endfor %}{{draft.revision_date|date:"j-M-y"}}, <{{draft.filename}}-{{draft.revision}}{{draft.file_type|id_index_file_types}}>
|
||||
{% endfilter %}{% block abstract %}{% endblock %}
|
||||
{% endfor %}{%endif %}{% endfor %}
|
Loading…
Reference in a new issue