20 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
36c4bc30fb
context_processors: Use breadcrumbs to highlight current section
- We were using hacky logic of assuming that if a page using the URL
/plinth/sys/..., then it belongs to 'system' section based on the URL match.
This won't work when the URL does not follow this pattern for any reason.

- Instead use the breadcrumbs mechanism which uses menu items and URL names to
determine the section a page belongs to.

Tests:

- Visit page, apps page, system page, help pages, an app page in apps sections,
an app page in system section, backups -> create backup page and notice that the
correct section is highlighted.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2024-12-25 12:24:29 +02:00
Sunil Mohan Adapa
3f20c1668d
ui: Allow users to provide a CSS file to customize styling
- Don't include the file if it does not exist to avoid a 404 error every time a
page it loaded.

- Load the file from a know path under the already known custom static path.

Tests:

- When the user.css file is created, it added to the web page. It is prioritized
over the main.css with CSS cascading rules.

- When the user.css file does not exist on the filesystem, it is not added to
the web page.

- When custom static directory (/var/www/plint) does not exist on the
filesystem, a debug log message is printed that this directory is not served.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2024-12-01 16:47:34 -05:00
Sunil Mohan Adapa
7e2b365bac
*: Remove unused imports to fix flake8 errors
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-10-19 09:32:09 -07:00
Sunil Mohan Adapa
44aab658ed
context_processors: Stop adding unused 'submenu' to context
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-10-16 21:08:07 -07:00
Sunil Mohan Adapa
d605907bbe
context_processors: Use active menu urls to decide what to highlight
- We are using submenu.url to check for specific URLs and then highlight a menu
item. This is somewhat incorrect due to string search and not generic enough. We
have another mechanism 'active_menu_urls' to perform this. Improve and use this
instead.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2024-10-16 21:08:00 -07:00
Sunil Mohan Adapa
74214c18ae
*: Use Django gettext functions instead of ugettext
- ugettext functions will be removed in Django 4.0. Each use emits a warning
when running with Django 3.2. Since we have warnings enabled in developer mode,
we see quite a few messages because of this.

- ugettext is already a simple alias of gettext. So, no regressions are
expected.

Tests:

- Accessing an affected app in UI with Django 3.2 and Django 2.2 works fine.

- Using Django 3.2 there are no warnings related to removal of ugettext
functions.

- Ran regular unit tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-09-20 16:50:16 -04:00
Sunil Mohan Adapa
5a126e62a8
notifications: Fix issue with redirection on dismiss
The request variable is not available when a custom template is used to render a
notification. Fix this by passing the template rendering context additional
request variable.

Closes: #1887.

Tests:

- Reduce the version number in data for 'upgrades-new-release' notification
in the plinth_storednotification table in the DB. Start FreedomBox. New release
message will appear. Go to page other than home page. The dismiss button has
next= parameter filled properly with current URL. Dismiss the notification and
notice that page URL stays the same.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-27 16:03:12 -04:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Sunil Mohan Adapa
8529022f63
notification: Show a drop down from main navbar for notifications
Closes: #1042.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-10 18:13:28 -05:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Sunil Mohan Adapa
b96d901071
Introduce component architecture and menu component
- Introduce base class for all apps that will contain components. With
  unittests.

- Introduce base classes for components. With unittests.

- Turn Menu class into an app component.

  - Further cleanup Menu class.

  - Update tests.

  - Maintain a global list of menu items and look them up easily. Generalize
    such that subsubmenus can later be merged into Menu class.

  - Cleanup scope of main menu initialization.

  - Use None instead of empty strings for various values. Ensure that
    printing short_description does not show 'None' in output.

  - Use enable/disable instead of promote/demote.

- Use menu component in all apps.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-06-07 11:48:04 -07:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Sunil Mohan Adapa
ee7cc98fee
apps, system: Remove modules and merge into main
- Remove apps and system modules and merge their views into main views.

- Move main_menu from cfg into menu.py.

- Remove dependencies of other modules on apps and system modules.

- Update tests.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-05-05 22:31:45 -04:00
Soumya97
6a53dd015e
context_processor: Cache whether user is admin (Closes: #781) 2017-04-18 16:01:48 +05:30
Rahul De
3248c2573d
Hide apps and sys icons if user is not an admin 2017-03-29 19:12:11 +05:30
Sunil Mohan Adapa
a48068f775
Ability to localize brand name in templates
- Take the value from the configuration and run it throught the Django
  translate method and make it available in Context.

- Use a no-op translate method to translate the text 'FreedomBox'.
2016-01-24 00:22:26 +05:30
Sunil Mohan Adapa
cf1bb65a0c tests: Minor styling fixes and updates
- Add module level comments.

- Add comments to reflect docstring styling.

- Since most tests can no longer be run directly, remove __main__
  invocation uniformly from all the tests.

- Remove unnecessary test settings and let them take default values.

- Add license header to test settings module.

- Fix a minor issue actions test tear down.

- Improve key/value store tests.
2015-05-24 12:16:51 +05:30
Bob Girard
5cadd223d5 Add support for testing Django-dependent modules
- Add django-test-settings.py for Django settings
- Add runtests.py for setting up Django test environment
- Add Django test setup support to setup.py and coverage.py
- Add new test module test_kvstore.py
- Enable existing Django-dependent tests in test_context_processors.py and test_menu.py
2015-05-23 13:59:49 +05:30
Sunil Mohan Adapa
20dab06ea3 Eliminate implicit relative imports
Convert to either absolute imports or explicit relative imports
2014-09-19 19:09:49 +05:30
Sunil Mohan Adapa
65fa648d9f Reorganize python sources into 'plinth' package 2014-08-29 12:57:27 +05:30