From f760caa421bf3ad4dfb73c782685b3b05f3cbc53 Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Fri, 12 Mar 2010 07:39:36 +0000 Subject: [PATCH] Cleaned away unused code - Legacy-Id: 2065 --- ietf/idindex/views.py | 50 +-------------------- ietf/idrfc/idrfc_wrapper.py | 2 +- ietf/idtracker/models.py | 8 ---- ietf/idtracker/templatetags/ietf_filters.py | 27 ----------- ietf/idtracker/views.py | 14 ------ ietf/ietfauth/auth.py | 2 +- ietf/ipr/new.py | 1 - ietf/ipr/tests.py | 2 +- ietf/mailinglists/urls.py | 2 +- ietf/middleware.py | 29 ------------ ietf/redirects/tests.py | 1 - ietf/templates/iesg/agenda_doc.html | 2 +- ietf/utils/__init__.py | 1 - ietf/utils/listop.py | 21 --------- ietf/utils/test_runner.py | 2 - 15 files changed, 6 insertions(+), 158 deletions(-) delete mode 100644 ietf/utils/listop.py diff --git a/ietf/idindex/views.py b/ietf/idindex/views.py index 0b98fbaf1..a749dc5fd 100644 --- a/ietf/idindex/views.py +++ b/ietf/idindex/views.py @@ -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) diff --git a/ietf/idrfc/idrfc_wrapper.py b/ietf/idrfc/idrfc_wrapper.py index e4a1a9a8e..70b0a7357 100644 --- a/ietf/idrfc/idrfc_wrapper.py +++ b/ietf/idrfc/idrfc_wrapper.py @@ -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 diff --git a/ietf/idtracker/models.py b/ietf/idtracker/models.py index 5df82cf21..dec50c76b 100644 --- a/ietf/idtracker/models.py +++ b/ietf/idtracker/models.py @@ -160,12 +160,6 @@ class InternetDraft(models.Model): else: css="active" return '' + self.filename + '' - def displayname_current(self): - if self.status.status == "Replaced": - css="replaced" - else: - css="active" - return '%s-%s' % (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 '%s' % ( 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): diff --git a/ietf/idtracker/templatetags/ietf_filters.py b/ietf/idtracker/templatetags/ietf_filters.py index 33852f42e..d130214ec 100644 --- a/ietf/idtracker/templatetags/ietf_filters.py +++ b/ietf/idtracker/templatetags/ietf_filters.py @@ -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 "%s" % ( 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() - diff --git a/ietf/idtracker/views.py b/ietf/idtracker/views.py index 6671b754c..3c56fe124 100644 --- a/ietf/idtracker/views.py +++ b/ietf/idtracker/views.py @@ -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 diff --git a/ietf/ietfauth/auth.py b/ietf/ietfauth/auth.py index d55761c18..7e12e393d 100644 --- a/ietf/ietfauth/auth.py +++ b/ietf/ietfauth/auth.py @@ -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 diff --git a/ietf/ipr/new.py b/ietf/ipr/new.py index 6579f0625..0917ef62d 100644 --- a/ietf/ipr/new.py +++ b/ietf/ipr/new.py @@ -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 diff --git a/ietf/ipr/tests.py b/ietf/ipr/tests.py index 6f561b3c0..88547f042 100644 --- a/ietf/ipr/tests.py +++ b/ietf/ipr/tests.py @@ -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 diff --git a/ietf/mailinglists/urls.py b/ietf/mailinglists/urls.py index f544ebdad..acef9834e 100644 --- a/ietf/mailinglists/urls.py +++ b/ietf/mailinglists/urls.py @@ -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' }), diff --git a/ietf/middleware.py b/ietf/middleware.py index a89a1ca64..427daef5a 100644 --- a/ietf/middleware.py +++ b/ietf/middleware.py @@ -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: diff --git a/ietf/redirects/tests.py b/ietf/redirects/tests.py index 5bc00699f..31b7cd9c7 100644 --- a/ietf/redirects/tests.py +++ b/ietf/redirects/tests.py @@ -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 diff --git a/ietf/templates/iesg/agenda_doc.html b/ietf/templates/iesg/agenda_doc.html index 8b5340ef5..b97cf112d 100644 --- a/ietf/templates/iesg/agenda_doc.html +++ b/ietf/templates/iesg/agenda_doc.html @@ -98,7 +98,7 @@ Some parts Copyright (c) 2009 The IETF Trust, all rights reserved. {{doc.obj.document.filename}} [txt] {% else %} -{{doc.obj.document.displayname_current|safe}} +{{doc.obj.document.displayname|safe}} [txt] {% endif %} diff --git a/ietf/utils/__init__.py b/ietf/utils/__init__.py index d82e7519e..19ad8d4e9 100644 --- a/ietf/utils/__init__.py +++ b/ietf/utils/__init__.py @@ -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 diff --git a/ietf/utils/listop.py b/ietf/utils/listop.py deleted file mode 100644 index 498fadd1a..000000000 --- a/ietf/utils/listop.py +++ /dev/null @@ -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 [] \ No newline at end of file diff --git a/ietf/utils/test_runner.py b/ietf/utils/test_runner.py index 7803bf799..b3952619a 100644 --- a/ietf/utils/test_runner.py +++ b/ietf/utils/test_runner.py @@ -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 = []