Cleaned away unused code

- Legacy-Id: 2065
This commit is contained in:
Pasi Eronen 2010-03-12 07:39:36 +00:00
parent cc13817101
commit f760caa421
15 changed files with 6 additions and 158 deletions

View file

@ -35,7 +35,7 @@
from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.template import loader
from django.shortcuts import get_object_or_404
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, Rfc, IDInternal
from ietf.idtracker.models import Acronym, IETFWG, InternetDraft, IDInternal
def all_id_txt():
all_ids = InternetDraft.objects.order_by('filename')
@ -73,54 +73,6 @@ def test_id_index_txt(request):
def test_id_abstracts_txt(request):
return HttpResponse(id_abstracts_txt(), mimetype='text/plain')
def related_docs(startdoc):
related = []
processed = []
def handle(otherdoc,status,doc,skip=(0,0,0)):
new = (otherdoc, status, doc)
if otherdoc in processed:
return
related.append(new)
process(otherdoc,skip)
def process(doc, skip=(0,0,0)):
processed.append(doc)
if type(doc) == InternetDraft:
if doc.replaced_by_id != 0 and not(skip[0]):
handle(doc.replaced_by, "that replaces", doc, (0,1,0))
if not(skip[1]):
for replaces in doc.replaces_set.all():
handle(replaces, "that was replaced by", doc, (1,0,0))
if doc.rfc_number != 0 and not(skip[0]):
# should rfc be an FK in the model?
try:
handle(Rfc.objects.get(rfc_number=doc.rfc_number), "which came from", doc, (1,0,0))
# In practice, there are missing rows in the RFC table.
except Rfc.DoesNotExist:
pass
if type(doc) == Rfc:
if not(skip[0]):
try:
draft = InternetDraft.objects.get(rfc_number=doc.rfc_number)
handle(draft, "that was published as", doc, (0,0,1))
except InternetDraft.DoesNotExist:
pass
# The table has multiple documents published as the same RFC.
# This raises an AssertionError because using get
# presumes there is exactly one.
except AssertionError:
pass
if not(skip[1]):
for obsoleted_by in doc.updated_or_obsoleted_by.all():
handle(obsoleted_by.rfc, "that %s" % obsoleted_by.action.lower(), doc)
if not(skip[2]):
for obsoletes in doc.updates_or_obsoletes.all():
handle(obsoletes.rfc_acted_on, "that was %s by" % obsoletes.action.lower().replace("tes", "ted"), doc)
process(startdoc, (0,0,0))
return related
def redirect_id(request, object_id):
'''Redirect from historical document ID to preferred filename url.'''
doc = get_object_or_404(InternetDraft, id_document_tag=object_id)

View file

@ -30,7 +30,7 @@
# (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.idtracker.models import InternetDraft, IDInternal, BallotInfo, IESGDiscuss, IESGComment, IESGLogin
from ietf.idtracker.models import InternetDraft, IDInternal, BallotInfo, IESGDiscuss, IESGLogin
from ietf.idrfc.models import RfcEditorQueue
import re
from datetime import date

View file

@ -160,12 +160,6 @@ class InternetDraft(models.Model):
else:
css="active"
return '<span class="' + css + '">' + self.filename + '</span>'
def displayname_current(self):
if self.status.status == "Replaced":
css="replaced"
else:
css="active"
return '<span class="%s">%s-%s</span>' % (css, self.filename, self.revision)
def displayname_with_link(self):
if self.status.status == "Replaced":
css="replaced"
@ -174,8 +168,6 @@ class InternetDraft(models.Model):
return '<a class="' + css + '" href="%s">%s</a>' % ( self.doclink(), self.filename )
def doclink(self):
return "http://" + settings.TOOLS_SERVER + "/html/%s" % ( self.filename )
def doclink_current(self):
return "http://%s/html/%s-%s" % (settings.TOOLS_SERVER, self.filename, self.revision)
def group_acronym(self):
return self.group.acronym
def __str__(self):

View file

@ -1,7 +1,6 @@
# Copyright The IETF Trust 2007, All Rights Reserved
import textwrap
import django
from django import template
from django.utils.html import escape, fix_ampersands
from django.template.defaultfilters import linebreaksbr, wordwrap, stringfilter
@ -92,26 +91,6 @@ def make_one_per_line(value):
else:
return value
@register.filter(name='link_if_url')
def link_if_url(value):
"""
If the argument looks like a url, return a link; otherwise, just
return the argument."""
if (re.match('(https?|mailto):', value)):
return "<a href=\"%s\">%s</a>" % ( fix_ampersands(value), escape(value) )
else:
return escape(value)
# This replicates the nwg_list.cgi method.
# It'd probably be better to check for the presence of
# a scheme with a better RE.
@register.filter(name='add_scheme')
def add_scheme(value):
if (re.match('www', value)):
return "http://" + value
else:
return value
@register.filter(name='timesum')
def timesum(value):
"""
@ -171,11 +150,6 @@ def fill(text, width):
wrapped.append(para)
return "\n\n".join(wrapped)
@register.filter(name='allononeline')
def allononeline(text):
"""Simply removes CRs, LFs, leading and trailing whitespace from the given string."""
return text.replace("\r", "").replace("\n", "").strip()
@register.filter(name='allononelinew')
def allononelinew(text):
"""Map runs of whitespace to a single space and strip leading and trailing whitespace from the given string."""
@ -374,4 +348,3 @@ def _test():
if __name__ == "__main__":
_test()

View file

@ -6,25 +6,12 @@ from django import forms
from django.template import RequestContext
from django.shortcuts import get_object_or_404, render_to_response
from django.db.models import Q
from django.core.urlresolvers import reverse
from django.views.generic.list_detail import object_detail, object_list
from ietf.idtracker.models import InternetDraft, IDInternal, IDState, IDSubState, Rfc, DocumentWrapper
from ietf.idtracker.forms import IDSearch
from ietf.utils import normalize_draftname
import re
# Override default form field mappings
# group_acronym: CharField(max_length=10)
# note: CharField(max_length=100)
def myfields(f):
if f.name == "group":
return forms.CharField(max_length=10,
widget=forms.TextInput(attrs={'size': 5}))
if f.name == "note":
return forms.CharField(max_length=100,
widget=forms.TextInput(attrs={'size': 100}))
return f.formfield()
def search(request):
# for compatability with old tracker form, which has
# "all substates" = 6.
@ -219,4 +206,3 @@ def view_comment(*args, **kwargs):
def view_ballot(*args, **kwargs):
return object_detail(*args, **kwargs)
# changes done by convert-096.py:changed newforms to forms

View file

@ -35,7 +35,7 @@
from django.contrib.auth.backends import RemoteUserBackend
from django.contrib.auth.models import Group
from ietf.idtracker.models import IESGLogin, Role, PersonOrOrgInfo
from ietf.ietfauth.models import LegacyWgPassword, IetfUserProfile
from ietf.ietfauth.models import IetfUserProfile
from ietf.utils import log

View file

@ -14,7 +14,6 @@ from ietf.utils import log
from ietf.utils.mail import send_mail
from ietf.ipr.view_sections import section_table
from ietf.idtracker.models import Rfc, InternetDraft
import django
# ----------------------------------------------------------------
# Create base forms from models

View file

@ -30,7 +30,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import os, re
import os
import unittest
from django.test.client import Client
from django.conf import settings

View file

@ -1,7 +1,7 @@
# Copyright The IETF Trust 2007, All Rights Reserved
from django.conf.urls.defaults import patterns
from ietf.idtracker.models import Area, IETFWG
from ietf.idtracker.models import IETFWG
urlpatterns = patterns('django.views.generic.list_detail',
(r'^wg/$', 'object_list', { 'queryset': IETFWG.objects.filter(email_archive__startswith='http'), 'template_name': 'mailinglists/wgwebmail_list.html' }),

View file

@ -1,10 +1,5 @@
# Copyright The IETF Trust 2007, All Rights Reserved
try:
import tidy
tidyavail = True
except ImportError:
tidyavail = False
from django.db import connection
from django.shortcuts import render_to_response
from django.template import RequestContext
@ -15,30 +10,6 @@ import smtplib
import sys
import traceback
options = dict(
output_xhtml=True,
# add_xml_decl=True,
# doctype='transitional',
indent=True,
tidy_mark=False,
# hide_comments=True,
wrap=100)
class PrettifyMiddleware(object):
"""Prettify middleware
From http://www.djangosnippets.org/snippets/172/
Uses python-utidylib, http://utidylib.berlios.de/,
which uses HTML Tidy, http://tidy.sourceforge.net/
"""
def process_response(self, request, response):
if tidyavail and response.headers['Content-Type'].split(';', 1)[0] in ['text/html']:
content = response.content
content = str(tidy.parseString(content, **options))
response.content = content
return response
class SQLLogMiddleware(object):
def process_response(self, request, response):
for q in connection.queries:

View file

@ -31,7 +31,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import unittest, os, re
import django
from django.test.client import Client
from django.conf import settings
from ietf.utils.test_utils import SimpleUrlTestCase, RealDatabaseTest, split_url, read_testurls

View file

@ -98,7 +98,7 @@ Some parts Copyright (c) 2009 The IETF Trust, all rights reserved.
<a href="{{ doc.obj.document.doclink }}">{{doc.obj.document.filename}}</a>
<a href="http://tools.ietf.org/rfc/{{ doc.obj.document.filename }}">[txt]</a>
{% else %}
<a href="{{ doc.obj.document.doclink_current }}">{{doc.obj.document.displayname_current|safe}}</a>
<a href="{{ doc.obj.document.doclink }}">{{doc.obj.document.displayname|safe}}</a>
<!-- <a href="http://www.ietf.org/internet-draft/{{ doc.obj.document.filename }}-{{ doc.obj.document.revision }}.txt">[txt]</a> -->
<a href="http://tools.ietf.org/id/{{ doc.obj.document.filename }}-{{ doc.obj.document.revision }}.txt">[txt]</a>
{% endif %}

View file

@ -1,6 +1,5 @@
# Copyright The IETF Trust 2007, All Rights Reserved
from listop import orl, flattenl
from log import log
from cache_foreign_key import FKAsOneToOne
from draft_search import normalize_draftname

View file

@ -1,21 +0,0 @@
# Copyright The IETF Trust 2007, All Rights Reserved
import operator
def orl(list):
""" Return the "or" of every element in a list.
Used to generate "or" queries with a list of Q objects. """
if list:
return reduce(operator.__or__, list)
else:
return None
def flattenl(list):
""" Flatten a list one level, e.g., turn
[ ['a'], ['b'], ['c', 'd'] ] into
[ 'a', 'b', 'c', 'd' ]
"""
if list:
return reduce(operator.__concat__, list)
else:
return []

View file

@ -32,10 +32,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys
import socket
from django.conf import settings
import django
from django.template import TemplateDoesNotExist
mail_outbox = []