Re: How to set a default priority

Ralf Schlatterbeck <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
On Wed, Apr 22, 2020 at 11:29:03AM +0200, R. Diez via Roundup-users wrote:
> Hi all:
> 
> I am evaluating the Roundup Issue Tracker. It has landed on my shortlist
> because it looks sensible, which is no small feat in this day and age of
> garbage software.  8-)

Thanks for considering roundup.

> The only thing that bothers me is that the priority field is required when
> entering a new issue. I would like the priority to have a default value, so
> that creating an issue requires one less mouse click. I am not sure I will
> be using it anyway.

You can remove the 'priority' from the list of required attributes in
the @required list in html/issue.item.html (search for the string
"@required"). And you probably want to update the style so that the
fieldname is not printed in bold by removing the 'class="required"' from
the Priority header (search for the string "Priority")

Now for setting a default: You can add an auditor to a new file in the
"detectors" directory. Something along the lines of (untested):

def add_prio_if_empty (db, cl, nodeid, newvalues):
    if 'priority' not in newvalues:
        newvalues ['priority'] = '1' # or whatever default you want

def init(db):
    db.issue.audit('create', add_prio_if_empty)

> I have looked around, but the answer to this simple question is not
> documented (or I have not found it yet).
Well, there *is* a user_guide.txt and a customizing.txt in the docs,
some of the above (like the use of detectors) should be covered there.

> I found file demo/html/issue.item.html , and this snippet inside it:
> 
> <tr>
>  <th class="required" i18n:translate="">Priority</th>
>  <td tal:content="structure context/priority/menu">priority</td>
> 
> I would have to change the way in which context/priority/menu
> generates the menu.

I think as long as the user doesn't select anything from the menu the
field will be left empty which is then caught by the proposed auditor.

> Now that I am here, I have another question. I wonder what would happen if
> people start attaching large files. Is there a way to list all issues with
> big attachments, and maybe delete the files if they become too big?

I do have another auditor that limits the size of files (there is a
'file' class in the database similar to what I'm doing to 'issue' above
and the property of the content of the file is named 'content', so you
can check the size of this and raise 'Reject ("your error message here")'
if it gets too big). But at that point it is quite late :-) another
option could be to limit the size of post requests (probably possible in
the webserver if you're running behind apache or nginx) but that leaves
the user with no clear idea of what went wrong.

Ah, when using 'Reject' you want to import the Reject exception with
from roundup.exceptions import Reject
at the top of your detectors file.

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]
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.