From e6b2d01532dae54f8e832a63f4c92a12caa5a344 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 21 Oct 2001 07:26:35 +0000 Subject: [PATCH] feature #473127: Filenames. I modified the file.index and htmltemplate source so that the filename is used in the link and the creation information is displayed. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@323 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 3 ++ roundup/cgi_client.py | 110 ++++++++++++++++++++++------------------ roundup/htmltemplate.py | 39 +++++++++++--- roundup/roundupdb.py | 11 ++-- 4 files changed, 102 insertions(+), 61 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 23bcb26..6215187 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -4,6 +4,9 @@ are given with the most recent entry first. 2001-10-?? - 0.3.0 Feature: . MailGW now moves 'unread' to 'chatting' on receiving e-mail for an issue. + . feature #473127: Filenames. I modified the file.index and htmltemplate + source so that the filename is used in the link and the creation + information is displayed. Admin Tool (roundup-admin): . Interactive mode for running multiple (independant at present) commands. . Tabular display of nodes. diff --git a/roundup/cgi_client.py b/roundup/cgi_client.py index e46098b..3f7b4cc 100644 --- a/roundup/cgi_client.py +++ b/roundup/cgi_client.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: cgi_client.py,v 1.36 2001-10-21 04:44:50 richard Exp $ +# $Id: cgi_client.py,v 1.37 2001-10-21 07:26:35 richard Exp $ import os, cgi, pprint, StringIO, urlparse, re, traceback, mimetypes import base64, Cookie, time @@ -618,57 +618,64 @@ class Client: path = self.split_path if not path or path[0] in ('', 'index'): self.index() - elif len(path) == 1: - if path[0] == 'list_classes': - self.classes() - return - if path[0] == 'login': - self.login() - return - if path[0] == 'login_action': - self.login_action() - return - if path[0] == 'newuser_action': - self.newuser_action() - return - if path[0] == 'logout': - self.logout() - return - m = dre.match(path[0]) - if m: - self.classname = m.group(1) - self.nodeid = m.group(2) - try: - cl = self.db.classes[self.classname] - except KeyError: - raise NotFound - try: - cl.get(self.nodeid, 'id') - except IndexError: - raise NotFound - try: - func = getattr(self, 'show%s'%self.classname) - except AttributeError: - raise NotFound - func() - return - m = nre.match(path[0]) - if m: - self.classname = m.group(1) - try: - func = getattr(self, 'new%s'%self.classname) - except AttributeError: - raise NotFound - func() - return - self.classname = path[0] + elif not path: + raise 'ValueError', 'Path not understood' + + # + # Everthing ignores path[1:] + # + # The file download link generator actually relies on this - it + # appends the name of the file to the URL so the download file name + # is correct, but doesn't actually use it. + action = path[0] + if action == 'list_classes': + self.classes() + return + if action == 'login': + self.login() + return + if action == 'login_action': + self.login_action() + return + if action == 'newuser_action': + self.newuser_action() + return + if action == 'logout': + self.logout() + return + m = dre.match(action) + if m: + self.classname = m.group(1) + self.nodeid = m.group(2) try: - self.db.getclass(self.classname) + cl = self.db.classes[self.classname] except KeyError: raise NotFound - self.list() - else: - raise 'ValueError', 'Path not understood' + try: + cl.get(self.nodeid, 'id') + except IndexError: + raise NotFound + try: + func = getattr(self, 'show%s'%self.classname) + except AttributeError: + raise NotFound + func() + return + m = nre.match(action) + if m: + self.classname = m.group(1) + try: + func = getattr(self, 'new%s'%self.classname) + except AttributeError: + raise NotFound + func() + return + self.classname = action + try: + self.db.getclass(self.classname) + except KeyError: + raise NotFound + self.list() def __del__(self): self.db.close() @@ -808,6 +815,11 @@ def parsePropsFromForm(db, cl, form, nodeid=0): # # $Log: not supported by cvs2svn $ +# Revision 1.36 2001/10/21 04:44:50 richard +# bug #473124: UI inconsistency with Link fields. +# This also prompted me to fix a fairly long-standing usability issue - +# that of being able to turn off certain filters. +# # Revision 1.35 2001/10/21 00:17:54 richard # CGI interface view customisation section may now be hidden (patch from # Roch'e Compaan.) diff --git a/roundup/htmltemplate.py b/roundup/htmltemplate.py index c720bb1..8d73e48 100644 --- a/roundup/htmltemplate.py +++ b/roundup/htmltemplate.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: htmltemplate.py,v 1.30 2001-10-21 04:44:50 richard Exp $ +# $Id: htmltemplate.py,v 1.31 2001-10-21 07:26:35 richard Exp $ import os, re, StringIO, urllib, cgi, errno @@ -210,11 +210,16 @@ class Menu(Base): #XXX deviates from spec class Link(Base): - ''' for a Link or Multilink property, display the names of the linked - nodes, hyperlinked to the item views on those nodes - for other properties, link to this node with the property as the text + '''For a Link or Multilink property, display the names of the linked + nodes, hyperlinked to the item views on those nodes. + For other properties, link to this node with the property as the + text. + + If is_download is true, append the property value to the generated + URL so that the link may be used as a download link and the + downloaded file name is correct. ''' - def __call__(self, property=None, **args): + def __call__(self, property=None, is_download=0): if not self.nodeid and self.form is None: return '[Link: not called from item]' propclass = self.properties[property] @@ -230,7 +235,11 @@ class Link(Base): linkcl = self.db.classes[linkname] k = linkcl.labelprop() linkvalue = linkcl.get(value, k) - return '%s'%(linkname, value, linkvalue) + if is_download: + return '%s'%(linkname, value, + linkvalue, linkvalue) + else: + return '%s'%(linkname, value, linkvalue) if isinstance(propclass, hyperdb.Multilink): linkname = propclass.classname linkcl = self.db.classes[linkname] @@ -239,11 +248,20 @@ class Link(Base): l = [] for value in value: linkvalue = linkcl.get(value, k) - l.append('%s'%(linkname, value, linkvalue)) + if is_download: + l.append('%s'%(linkname, value, + linkvalue, linkvalue)) + else: + l.append('%s'%(linkname, value, + linkvalue)) return ', '.join(l) if isinstance(propclass, hyperdb.String): if value == '': value = '[no %s]'%property.capitalize() - return '%s'%(self.classname, self.nodeid, value) + if is_download: + return '%s'%(self.classname, self.nodeid, + value, value) + else: + return '%s'%(self.classname, self.nodeid, value) class Count(Base): ''' for a Multilink property, display a count of the number of links in @@ -815,6 +833,11 @@ def newitem(client, templates, db, classname, form, replace=re.compile( # # $Log: not supported by cvs2svn $ +# Revision 1.30 2001/10/21 04:44:50 richard +# bug #473124: UI inconsistency with Link fields. +# This also prompted me to fix a fairly long-standing usability issue - +# that of being able to turn off certain filters. +# # Revision 1.29 2001/10/21 00:17:56 richard # CGI interface view customisation section may now be hidden (patch from # Roch'e Compaan.) diff --git a/roundup/roundupdb.py b/roundup/roundupdb.py index d70404c..546e746 100644 --- a/roundup/roundupdb.py +++ b/roundup/roundupdb.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: roundupdb.py,v 1.13 2001-10-21 00:45:15 richard Exp $ +# $Id: roundupdb.py,v 1.14 2001-10-21 07:26:35 richard Exp $ import re, os, smtplib, socket @@ -49,6 +49,9 @@ _marker = [] class Class(hyperdb.Class): # Overridden methods: def __init__(self, db, classname, **properties): + if (properties.has_key('creation') or properties.has_key('activity') + or properties.has_key('creator')): + raise ValueError, '"creation", "activity" and "creator" are reserved' hyperdb.Class.__init__(self, db, classname, **properties) self.auditors = {'create': [], 'set': [], 'retire': []} self.reactors = {'create': [], 'set': [], 'retire': []} @@ -210,9 +213,6 @@ class IssueClass(Class): properties['nosy'] = hyperdb.Multilink("user") if not properties.has_key('superseder'): properties['superseder'] = hyperdb.Multilink(classname) - if (properties.has_key('creation') or properties.has_key('activity') - or properties.has_key('creator')): - raise ValueError, '"creation", "activity" and "creator" are reserved' Class.__init__(self, db, classname, **properties) # New methods: @@ -303,6 +303,9 @@ Roundup issue tracker # # $Log: not supported by cvs2svn $ +# Revision 1.13 2001/10/21 00:45:15 richard +# Added author identification to e-mail messages from roundup. +# # Revision 1.12 2001/10/04 02:16:15 richard # Forgot to pass the protected flag down *sigh*. # -- 2.30.2