Mercurial > p > roundup > code
comparison doc/admin_guide.txt @ 7974:4dcc64d0138e
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.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 21 May 2024 20:03:56 -0400 |
| parents | fe0348bbe45b |
| children | 16c2e2849fd6 |
comparison
equal
deleted
inserted
replaced
| 7973:ab3506b9e315 | 7974:4dcc64d0138e |
|---|---|
| 515 .. _CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP | 515 .. _CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP |
| 516 | 516 |
| 517 Classhelper Web Component | 517 Classhelper Web Component |
| 518 ========================= | 518 ========================= |
| 519 | 519 |
| 520 Version 2.4.0 provides a new classhelper popup written as a | 520 Version 2.4.0 provides a new classhelper popup written as a web |
| 521 web component. By installing 3 files and adding a stanza to | 521 component. By installing 3 files and editing the tracker's templates |
| 522 ``interfaces.py`` you can enable the new component. | 522 you can enable the new component. |
| 523 | 523 |
| 524 The `development of this component was done by team-03 | 524 The `development of this component was done by team-03 |
| 525 <https://github.com/UMB-CS-682-Team-03/tracker>`_ of the | 525 <https://github.com/UMB-CS-682-Team-03/tracker>`_ of the |
| 526 Spring 2024 CS682 graduate software engineering SDL capstone | 526 Spring 2024 CS682 graduate software engineering SDL capstone |
| 527 class at the University of Massachusetts - Boston. Their | 527 class at the University of Massachusetts - Boston. Their |
| 540 /path/to/template/html/classhelper.js | 540 /path/to/template/html/classhelper.js |
| 541 /path/to/template/html/classhelper.css | 541 /path/to/template/html/classhelper.css |
| 542 /path/to/template/html/_generic.translation | 542 /path/to/template/html/_generic.translation |
| 543 | 543 |
| 544 to your tracker's html directory. | 544 to your tracker's html directory. |
| 545 | |
| 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 | 545 |
| 581 Wrapping the Classic Classhelper | 546 Wrapping the Classic Classhelper |
| 582 -------------------------------- | 547 -------------------------------- |
| 583 | 548 |
| 584 To allow your users to select items in the web interface | 549 To allow your users to select items in the web interface |
| 807 This should display the missing translations, for more | 772 This should display the missing translations, for more |
| 808 details refer to the `translation (i18n) section of the | 773 details refer to the `translation (i18n) section of the |
| 809 developers documentation | 774 developers documentation |
| 810 <developers.html#extracting-translatable-messages>`_. | 775 <developers.html#extracting-translatable-messages>`_. |
| 811 | 776 |
| 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 | |
| 812 Troubleshooting | 795 Troubleshooting |
| 813 --------------- | 796 --------------- |
| 814 | 797 |
| 815 The roundup-classhelper will fallback to using the classic | 798 The roundup-classhelper will fallback to using the classic |
| 816 classhelper if: | 799 classhelper if: |
| 828 the web component from starting up. | 811 the web component from starting up. |
| 829 | 812 |
| 830 Also you can set ``DISABLE_CLASSHELP = true`` at the top of | 813 Also you can set ``DISABLE_CLASSHELP = true`` at the top of |
| 831 classhelper.js to disable the classhelper without having to make any | 814 classhelper.js to disable the classhelper without having to make any |
| 832 changes to your templates. | 815 changes to your templates. |
| 816 | |
| 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. | |
| 833 | 865 |
| 834 Configuring native-fts Full Text Search | 866 Configuring native-fts Full Text Search |
| 835 ======================================= | 867 ======================================= |
| 836 | 868 |
| 837 Roundup release 2.2.0 supports database-native full text search. | 869 Roundup release 2.2.0 supports database-native full text search. |
