Skip to content

Commit 7a7b486

Browse files
committed
doc: classhelper translation, advanced config w/ roles endpoint
Added info on how to translate default title and data-popup-title. Also added advanced config section on deploying a new roles rest endpoint and changing classhelper to use it.
1 parent 5bc0a31 commit 7a7b486

File tree

1 file changed

+70
-38
lines changed

1 file changed

+70
-38
lines changed

doc/admin_guide.txt

Lines changed: 70 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ handlers.
517517
Classhelper Web Component
518518
=========================
519519

520-
Version 2.4.0 provides a new classhelper popup written as a
521-
web component. By installing 3 files and adding a stanza to
522-
``interfaces.py`` you can enable the new component.
520+
Version 2.4.0 provides a new classhelper popup written as a web
521+
component. By installing 3 files and editing the tracker's templates
522+
you can enable the new component.
523523

524524
The `development of this component was done by team-03
525525
<https://github.com/UMB-CS-682-Team-03/tracker>`_ of the
@@ -543,41 +543,6 @@ path value of the classic template. If the path value is
543543

544544
to your tracker's html directory.
545545

546-
.. :
547-
remove in 2.5 release if /data/user/roles endpoint
548-
in rest.py is successful.
549-
550-
If you wish to search for user's by role, you have to do one more
551-
step. Because roles are not an actual class (e.g. like status or
552-
keyword), you have to set up a new REST endpoint for them. To do this,
553-
copy::
554-
555-
556-
from roundup.rest import Routing, RestfulInstance, _data_decorator
557-
558-
class RestfulInstance:
559-
560-
@Routing.route("/roles", 'GET')
561-
@_data_decorator
562-
def get_roles(self, input):
563-
"""Return all defined roles. The User class property
564-
roles is a string but simulate it as a MultiLink
565-
to an actual Roles class.
566-
"""
567-
return 200, {"collection":
568-
[{"id": rolename,"name": rolename}
569-
for rolename in list(self.db.security.role.keys())]}
570-
571-
into the file ``interfaces.py`` in your tracker's home
572-
directory. You can create this file if it doesn't exist.
573-
See the `REST documentation <rest.html>`_ for details on
574-
``interfaces.py``.
575-
576-
The classic tracker does not have the ``/roles`` REST endpoint
577-
configured. If you are creating a new tracker from the classic
578-
template, it will show a text based search not a select/dropdown based
579-
search. By modifying interfaces.py you will enable a dropdown search.
580-
581546
Wrapping the Classic Classhelper
582547
--------------------------------
583548

@@ -809,6 +774,24 @@ details refer to the `translation (i18n) section of the
809774
developers documentation
810775
<developers.html#extracting-translatable-messages>`_.
811776

777+
The default title used for read only popups can be changed by using
778+
the translation mechanism. Use the following::
779+
780+
msgid "Info on {className} - {itemDesignator} - Classhelper"
781+
msgstr "{itemDesignator} - info on {className}"
782+
783+
in ``en.po`` to reformat the title for the English language. Note that
784+
``{classname}`` is only supported in the default title.
785+
786+
In addition to the default template you can translate a title set
787+
using ``data-popup-title`` by matching the template as the msgid.
788+
Using an example above::
789+
790+
msgid "Nosy List Classhelper - {itemDesignator}"
791+
msgstr "Nosy List Klassenhelfer - {itemDesignator}"
792+
793+
placed in ``de.po`` will translate the title into German.
794+
812795
Troubleshooting
813796
---------------
814797

@@ -831,6 +814,55 @@ Also you can set ``DISABLE_CLASSHELP = true`` at the top of
831814
classhelper.js to disable the classhelper without having to make any
832815
changes to your templates.
833816

817+
Advanced Configuration
818+
----------------------
819+
820+
The classhelper.js file has a few tweakable options for use
821+
by advanced users. The endpoint for the roles list requires
822+
the user to have Admin rights. You can add your own roles
823+
endpoint with a different authorization mechanism. The
824+
following code can be added to your tracker's interfaces.py.
825+
You can create this file if it doesn't exist. This code
826+
creates a new REST endpoint at '/rest/roles'::
827+
828+
from roundup.rest import Routing, RestfulInstance, _data_decorator
829+
830+
class RestfulInstance:
831+
832+
@Routing.route("/roles", 'GET')
833+
@_data_decorator
834+
def get_roles(self, input):
835+
"""Return all defined roles. The User class property
836+
roles is a string but simulate it as a MultiLink
837+
to an actual Roles class.
838+
"""
839+
return 200, {"collection":
840+
[{"id": rolename,"name": rolename}
841+
for rolename in list(self.db.security.role.keys())]}
842+
843+
844+
See the `REST documentation <rest.html>`_ for details on
845+
using ``interfaces.py`` to add new REST endpoints.
846+
847+
The code above allows any user with REST access to see all
848+
the roles defined in the tracker.
849+
850+
To make classhelper.js use this new endpoint, look for::
851+
852+
853+
const ALTERNATIVE_DROPDOWN_PATHNAMES = {
854+
"roles": "/rest/data/user/roles"
855+
}
856+
857+
and change it to::
858+
859+
const ALTERNATIVE_DROPDOWN_PATHNAMES = {
860+
"roles": "/rest/roles"
861+
}
862+
863+
Users may have to perform a hard reload to cache this change
864+
on their system.
865+
834866
Configuring native-fts Full Text Search
835867
=======================================
836868

0 commit comments

Comments
 (0)