Re: Creating an auditor to prevent some users from deleting issues/messages/files

Ralf Schlatterbeck <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
On Wed, Mar 04, 2015 at 05:39:49PM -0800, Dan Tenenbaum wrote:
> Similarly, how would I create an auditor to reject new issues that
> have the same title as an existing issue?

You check 'newvalues' for the 'title' property in an auditor and search
for this title in the existing issues, e.g.

new_title = newvalues.get ('title')
if new_title is None:
    return
for id in db.issue.filter (None, dict (title = new_title)):
    t = db.issue.get (id, 'title')
    if t == new_title:
        raise...

Note that since filter can only search for substrings you have to
compare all found issues for an exact match. There currently is no way
(except by resorting to sql) to search for exact matches. In one of the
latest patches the search has also been made case-insensistive for all
the sql backends.

You would have to register this auditor for the 'set' and 'create'
actions.

(I don't know if it's a good idea to not allow duplicate titles in
issues)

Ralf

-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   http://www.runtux.com
Reichergasse 131, A-3411 Weidling       email: [email protected]
allmenda.com member                     email: [email protected]

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.