Skip to content

Commit b5eb8ed

Browse files
author
Richard Jones
committed
@required in forms may now specify properties of linked items
(patch [SF#1507093])
1 parent 6ecdacb commit b5eb8ed

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Feature:
1010
- added StringHTMLProperty wrapped() method to wrap long lines in issue
1111
display
1212
- include the popcal in Date field editing and search fields by default
13+
- @required in forms may now specify properties of linked items (sf patch
14+
1507093)
1315

1416

1517
Fixed:

doc/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ Alexander Smishlajev,
150150
Nathaniel Smith,
151151
Maciej Starzyk,
152152
Mitchell Surface,
153+
Jon C. Thomason
153154
Mike Thompson,
154155
Michael Twomey,
155156
Karl Ulbrich,

roundup/cgi/form_parser.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,17 @@ def parse(self, create=0, num_re=re.compile('^\d+$')):
284284
'value "%(entry)s" not a designator') % locals()
285285
value.append((m.group(1), m.group(2)))
286286

287+
# get details of linked class
288+
lcn = m.group(1)
289+
lcl = self.db.classes[lcn]
290+
lnodeid = m.group(2)
291+
if not all_propdef.has_key(lcn):
292+
all_propdef[lcn] = lcl.getprops()
293+
if not all_props.has_key((lcn, lnodeid)):
294+
all_props[(lcn, lnodeid)] = {}
295+
if not got_props.has_key((lcn, lnodeid)):
296+
got_props[(lcn, lnodeid)] = {}
297+
287298
# make sure the link property is valid
288299
if (not isinstance(propdef[propname], hyperdb.Multilink) and
289300
not isinstance(propdef[propname], hyperdb.Link)):
@@ -296,7 +307,19 @@ def parse(self, create=0, num_re=re.compile('^\d+$')):
296307

297308
# detect the special ":required" variable
298309
if d['required']:
299-
all_required[this] = self.extractFormList(form[key])
310+
for entry in self.extractFormList(form[key]):
311+
m = self.FV_SPECIAL.match(entry)
312+
if not m:
313+
raise FormError, self._('The form action claims to '
314+
'require property "%(property)s" '
315+
'which doesn\'t exist') % {
316+
'property':propname}
317+
if m.group('classname'):
318+
this = (m.group('classname'), m.group('id'))
319+
entry = m.group('propname')
320+
if not all_required.has_key(this):
321+
all_required[this] = []
322+
all_required[this].append(entry)
300323
continue
301324

302325
# see if we're performing a special multilink action

test/test_cgi.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# but WITHOUT ANY WARRANTY; without even the implied warranty of
99
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1010
#
11-
# $Id: test_cgi.py,v 1.27 2006-01-25 02:24:28 richard Exp $
11+
# $Id: test_cgi.py,v 1.28 2006-08-11 00:18:59 richard Exp $
1212

1313
import unittest, os, shutil, errno, sys, difflib, cgi, re
1414

@@ -152,6 +152,10 @@ def testNothingWithRequired(self):
152152
{':required': 'status', 'status':''}, 'issue')
153153
self.assertRaises(FormError, self.parseForm,
154154
{':required': 'nosy', 'nosy':''}, 'issue')
155+
self.assertRaises(FormError, self.parseForm,
156+
{':required': 'msg-1@content', 'msg-1@content':''}, 'issue')
157+
self.assertRaises(FormError, self.parseForm,
158+
{':required': 'msg-1@content'}, 'issue')
155159

156160
#
157161
# Nonexistant edit

0 commit comments

Comments
 (0)