Compare commits

...

286 Commits

Author SHA1 Message Date
Joel Falknau
4210b2eabc Version Bump 4.4.0 2024-10-21 13:00:43 +10:00
Ariel Rin
225e68647e Merge branch 'add-missing-mumble-migration' into 'master'
[ADD] Missing Mumble migration

See merge request allianceauth/allianceauth!1655
2024-10-18 02:37:50 +00:00
Ariel Rin
7e2f864ebf Merge branch 'optimer-fix' into 'master'
Fix maximum character limit for duration in the optimer form

See merge request allianceauth/allianceauth!1656
2024-10-18 02:37:19 +00:00
Ariel Rin
f2384ba45b Merge branch 'master' into 'master'
Use https where applicable

See merge request allianceauth/allianceauth!1657
2024-10-18 02:29:33 +00:00
salartarium
c5918b9b3c Use https where applicable 2024-10-18 02:29:33 +00:00
Aaron Kable
ffedc4103d fix max chars on duration 2024-10-14 19:22:46 +08:00
Peter Pfeufer
0467b23a1a [ADD] Missing Mumble migration
Running migrations:
  No migrations to apply.
  Your models in app(s): 'mumble' have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.
2024-10-07 15:42:51 +02:00
Ariel Rin
cda5ce739f Merge branch 'mumbleconnectionhistory' into 'master'
Mumble Connection History Page

See merge request allianceauth/allianceauth!1648
2024-10-04 12:12:17 +00:00
Ariel Rin
e5c8426ea3 Merge branch 'fixing-bs3-side-menu' into 'master'
[REMOVE] Duplicate menu item

See merge request allianceauth/allianceauth!1654
2024-10-04 12:07:22 +00:00
Ariel Rin
b2bd489ddc Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1653
2024-10-04 12:06:53 +00:00
Ariel Rin
6397cf358a Updates for project Alliance Auth 2024-10-04 12:06:53 +00:00
Ariel Rin
90fcc4a811 Merge branch 'master' into 'master'
Add an example to the notification documentation

See merge request allianceauth/allianceauth!1652
2024-10-04 12:05:17 +00:00
Ariel Rin
ec7472fe22 Merge branch 'bootstrap-dark-fixes' into 'master'
[FIX] Re-add the dark bootstrap html tag

See merge request allianceauth/allianceauth!1651
2024-10-04 12:03:25 +00:00
Peter Pfeufer
5148b1914d [REMOVE] Duplicate menu item 2024-10-04 13:56:57 +02:00
Ariel Rin
2e0716f5ae Merge branch 'mumbleconnectionhistory-improvements' into 'mumbleconnectionhistory'
[CHANGE] Some improvements

See merge request soratidus999/allianceauth!12
2024-09-23 23:33:01 +00:00
Peter Pfeufer
1fb091acb2 [CHANGE] Some improvements
- Fixed Bootstraps cards, rows and cols
- Replaced style argument with Bootstrap class
- Removed unused Django templatetag
- JS modernized and moved to its own script tag instead of concatenating it with other more or less "global" scripts
- Fixed Bootstrap classes
2024-09-23 15:09:35 +02:00
r0kym
07c62ed32a Add an example to the notification documentation 2024-09-23 13:15:19 +02:00
Aaron Kable
660fe79d08 re-add the dark bootstrap html tag 2024-09-17 21:24:01 +08:00
Joel Falknau
42ee06470c Version Bump 4.3.1 2024-09-13 20:22:31 +10:00
Joel Falknau
69aaa9652f compilemessages 2024-09-13 20:09:46 +10:00
Ariel Rin
1ccfff50e5 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1649
2024-09-13 10:09:10 +00:00
Ariel Rin
57a39557fd Updates for project Alliance Auth 2024-09-13 10:09:09 +00:00
Joel Falknau
c36dea08e3 compilemessages 2024-09-13 20:01:33 +10:00
Joel Falknau
d3acd821b7 remove excess translations 2024-09-13 20:01:20 +10:00
Joel Falknau
0a17427169 update language codes 2024-09-13 19:59:40 +10:00
Ariel Rin
ce8935e621 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1647
2024-09-13 08:55:07 +00:00
Ariel Rin
efff946a56 Updates for project Alliance Auth 2024-09-13 08:55:07 +00:00
Joel Falknau
1dea92ed76 add Connection History 2024-09-12 15:54:14 +10:00
Joel Falknau
3f54d49d8b update help text from mumble definition 2024-09-12 15:54:06 +10:00
Joel Falknau
77da6928b2 add Chart.js 4.4.1 to Bundles 2024-09-12 15:53:53 +10:00
Joel Falknau
bd17b95cac Version Bump 4.3.0 2024-09-09 14:05:58 +10:00
Joel Falknau
4ed1c5b7c4 bring test celery in line with project 2024-09-09 13:59:43 +10:00
Ariel Rin
271fd8e8c4 Merge branch 'docs-user-creation-fix' into 'master'
[Docs] Add shell option to adduser command for Ubuntu install docs

See merge request allianceauth/allianceauth!1622
2024-09-09 03:58:47 +00:00
colcrunch
9b4321281a [Docs] Add shell option to adduser command for Ubuntu install docs 2024-09-09 03:58:47 +00:00
Ariel Rin
052c35c8e5 Merge branch 'metenox' into 'master'
Timerboard Improvements

Closes #1384

See merge request allianceauth/allianceauth!1645
2024-09-09 03:57:21 +00:00
Ariel Rin
0fcb517b0b Timerboard Improvements 2024-09-09 03:57:21 +00:00
Ariel Rin
dcfddf0add Merge branch 'docs2' into 'master'
Documentation

See merge request allianceauth/allianceauth!1646
2024-09-09 03:43:30 +00:00
Joel Falknau
4a4258d0e6 use docker command inside docker 2024-09-09 13:32:18 +10:00
Joel Falknau
dd15a221aa split repo from install 2024-09-09 13:32:06 +10:00
Joel Falknau
737e02293a expand mumble service install docs 2024-09-09 12:59:49 +10:00
Joel Falknau
c34efebacf define charsets for db backed apps 2024-09-03 12:27:50 +10:00
Joel Falknau
4602097399 remove DB step from mumble install, sqlite has been reccommended for a while 2024-09-03 12:27:02 +10:00
Joel Falknau
7051e06564 update features from readme 2024-09-03 12:26:43 +10:00
Joel Falknau
9767ce79d8 cleanup some local.py references 2024-09-03 12:26:31 +10:00
Joel Falknau
0c090f1486 Ubuntu 2004 should not be reccommended for new isntalls 2024-09-03 12:25:01 +10:00
Joel Falknau
618ee81f9b remove unneeded analytics docs for removed features 2024-09-03 12:24:37 +10:00
Joel Falknau
98efb9f887 split maintenance tasks into bare metal / docker 2024-09-03 12:24:17 +10:00
Ariel Rin
cbe6c821cc Merge branch 'custom-css' into 'master'
[ADD] Custom CSS Module

See merge request allianceauth/allianceauth!1643
2024-08-21 05:01:38 +00:00
Ariel Rin
de9d2b39a6 Merge branch 'theme-html-tags' into 'master'
[ADD] Theme html tags

See merge request allianceauth/allianceauth!1642
2024-08-21 04:59:18 +00:00
Peter Pfeufer
0d5f22288b Merge branch 'switch-to-django-solo' into custom-css 2024-08-20 14:41:52 +02:00
Peter Pfeufer
e0d76dc268 [CHANGE] Switch to Django Solo 2024-08-20 14:41:43 +02:00
Peter Pfeufer
ecc9e68330 [CHANGE] Consolidate migrations 2024-08-14 13:25:49 +02:00
Peter Pfeufer
710149ec21 [FIX] Check if the CustomCSS object exists 2024-08-14 13:22:23 +02:00
Peter Pfeufer
3c2c137dad [CHANGE] improve try block in template tag 2024-08-14 13:05:32 +02:00
Peter Pfeufer
a8271c4189 [CHANGE] Remove custom CSS file when it will be empty 2024-08-14 12:58:01 +02:00
Peter Pfeufer
3315ae7778 [ADD] Module to base settings file 2024-08-14 12:47:38 +02:00
Peter Pfeufer
d2f048f8fe [ADD Example template for admin overrides
For when we might want to add syntax highlight ti it, which is a completely different can of worms though.
2024-08-14 12:45:57 +02:00
Peter Pfeufer
0fe2855faa [ADD] Custom CSS to base file
Check if the CSS file exists and add it to the HTML output
2024-08-14 12:44:51 +02:00
Peter Pfeufer
79a1fa3d7c [ADD] CSS compression on save 2024-08-14 12:42:52 +02:00
Peter Pfeufer
96fe88d5c7 [REMOVE] highlight.js and leave it as an example in the widget code 2024-08-14 11:53:02 +02:00
Peter Pfeufer
59391ad3c5 [ADD] Custom CSS module (First steps) 2024-08-11 22:34:16 +02:00
Peter Pfeufer
94e9c08422 [ADD] Theme html tags 2024-08-08 10:22:14 +02:00
Joel Falknau
acff3695bc Version Bump 4.2.2 2024-08-06 12:43:06 +10:00
Ariel Rin
43ec8514aa Merge branch 'improve-redis-installation-on-ubuntu' into 'master'
[MISC] Improve Redis installation instructions for Ubuntu

See merge request allianceauth/allianceauth!1641
2024-08-05 01:26:07 +00:00
Peter Pfeufer
4c629b193f [CHANGE] Redis hint link 2024-08-05 03:21:14 +02:00
Peter Pfeufer
c651da4011 [MISC] Improve Redis installation instructions for Ubuntu 2024-08-05 03:12:24 +02:00
Ariel Rin
da382cffd1 Merge branch 'fix-mumble-url' into 'master'
[FIX] Mumble URL in service card

See merge request allianceauth/allianceauth!1637
2024-08-05 01:04:24 +00:00
Ariel Rin
4ecfc3afd8 Merge branch 'docs-docker-headlines' into 'master'
[CHANGE] Clarify that these instructions are for Docker

See merge request allianceauth/allianceauth!1638
2024-08-05 01:02:57 +00:00
Ariel Rin
4eb7dbbe62 Merge branch 'add-margin' into 'master'
[ADD] A bit margin to the notifications

See merge request allianceauth/allianceauth!1639
2024-08-05 01:02:52 +00:00
Ariel Rin
c96ba65296 Merge branch 'avoid-KeyError-in-checks' into 'master'
[FIX] Avoid `KeyError` in `celery_settings` checks

See merge request allianceauth/allianceauth!1640
2024-08-05 01:02:40 +00:00
Peter Pfeufer
ff2f60f7f3 [FIX] Avoid KeyError in celery_settings checks 2024-08-04 18:29:43 +02:00
Peter Pfeufer
3000545c98 [ADD] A bit margin to the notifications 2024-07-26 23:09:15 +02:00
Peter Pfeufer
f3ad092ef2 [CHANGNE] Clarify that these instructions are for Docker
This should also fix the menu item title, hopefully …
2024-07-19 19:13:48 +02:00
Peter Pfeufer
a012e7df2f [FIX] Mumble URL in service card 2024-07-19 17:33:32 +02:00
Ariel Rin
1fa77412c0 Merge branch 'fix/missing-celery-setting' into 'master'
fix missing setting in celery

See merge request allianceauth/allianceauth!1636
2024-07-15 13:39:28 +00:00
Matteo Ghia
e56caeb22b fix missing setting in celery 2024-07-15 14:53:45 +02:00
Joel Falknau
ceb07ebc67 Version Bump 4.2.1 2024-07-15 22:20:32 +10:00
Ariel Rin
237075d45c Merge branch 'checklib' into 'master'
More Detail on the SQL charset check

See merge request allianceauth/allianceauth!1635
2024-07-15 12:18:47 +00:00
Ariel Rin
7099b1946d More Detail on the SQL charset check 2024-07-15 12:18:47 +00:00
Joel Falknau
e416ab8ff2 Version Bump 4.2.0 2024-07-15 21:25:00 +10:00
Joel Falknau
2802ed03a5 Add Celery to classifiers 2024-07-15 21:22:58 +10:00
Ariel Rin
4af73c76fe Merge branch 'analytics' into 'master'
Analytics

See merge request allianceauth/allianceauth!1632
2024-07-15 11:00:27 +00:00
Ariel Rin
b6149979aa Analytics 2024-07-15 11:00:26 +00:00
Ariel Rin
cb20288427 Merge branch 'checklib' into 'master'
More Checks for System Packages and Configs

See merge request allianceauth/allianceauth!1633
2024-07-15 11:00:06 +00:00
Ariel Rin
db6f4c91dc More Checks for System Packages and Configs 2024-07-15 11:00:06 +00:00
Ariel Rin
57ac7a5277 Merge branch 'center-error-messages' into 'master'
[CHANGE] Center HTTPError messages

See merge request allianceauth/allianceauth!1634
2024-07-15 03:32:34 +00:00
Peter Pfeufer
136438f9c2 [CHANGE] Center HTTPError messages 2024-07-13 00:31:44 +02:00
Ariel Rin
e2be8b3440 Merge branch 'composelint' into 'master'
Optimize Dockerfile

See merge request allianceauth/allianceauth!1630
2024-06-17 08:42:39 +00:00
Ariel Rin
04f3473ef3 Optimize Dockerfile 2024-06-17 08:42:39 +00:00
Ariel Rin
255cb0da8d Merge branch 'bootstrap-class-fixes' into 'master'
[CHANGE] Remove unnecessary bootstrap classes from the dashboard

See merge request allianceauth/allianceauth!1631
2024-06-17 08:42:34 +00:00
Peter Pfeufer
069352fb0f [FIX] Switch to bottom margin instead of top/bottom padding
This is the much more commonly used approach.
2024-06-01 12:01:44 +02:00
Peter Pfeufer
66e8ddb684 [CHANGE] Remove unnecessary bootstrap classes from the dashboard 2024-05-31 21:59:24 +02:00
Ariel Rin
179c26975c Version Bump 4.1.0 2024-05-27 14:31:41 +10:00
Ariel Rin
e17f6e799b correct capitalization 2024-05-27 14:31:21 +10:00
Ariel Rin
7cd8294104 Merge branch 'widget-title-to-framework' into 'master'
[ADD] Widget title partial to AA framework

See merge request allianceauth/allianceauth!1629
2024-05-27 04:25:56 +00:00
Peter Pfeufer
ede5540335 [ADD] Widget title partial to AA framework 2024-05-26 16:52:15 +02:00
Ariel Rin
747279b773 Merge branch 'yet-another-padding-fix' into 'master'
Some more widget fixes

See merge request allianceauth/allianceauth!1628
2024-05-26 09:08:00 +00:00
Peter Pfeufer
44f8b1c477 [FIX] Don't try to underline these links
Fixing this while I'm at it …
2024-05-26 10:06:07 +02:00
Peter Pfeufer
7c6ebd9bf6 [FIX] Yet another padding in the dashboard widgets 2024-05-26 09:52:03 +02:00
Ariel Rin
430469b708 Merge branch 'widget-padding-fix' into 'master'
[FIX] Dashboard widget padding

See merge request allianceauth/allianceauth!1627
2024-05-26 06:51:20 +00:00
Peter Pfeufer
efbb3cee31 [FIX] Dashboard widget padding 2024-05-26 08:23:57 +02:00
Ariel Rin
21094ed4dd lint 2024-05-26 13:30:21 +10:00
Ariel Rin
5f326efc7e Merge branch 'v4docs' into 'master'
Expand Tuning Doccs

See merge request allianceauth/allianceauth!1624
2024-05-26 03:22:08 +00:00
Ariel Rin
b6e34ace35 Expand Tuning Doccs 2024-05-26 03:22:08 +00:00
Ariel Rin
fe4a8965e3 Merge branch 'master' into 'master'
Improve Error Troubleshooting with Log Documentation

See merge request allianceauth/allianceauth!1619
2024-05-26 02:58:23 +00:00
Ariel Rin
23371c233d Merge branch 'bmtuk-master-patch-12042' into 'master'
Timerboard - Fix Timer deletion

See merge request allianceauth/allianceauth!1625
2024-05-26 02:56:35 +00:00
Ariel Rin
7a3bbf0d7f Merge branch 'staff-menu-item' into 'master'
Allow staff access to admin button in user menu

See merge request allianceauth/allianceauth!1626
2024-05-26 02:56:05 +00:00
Aaron Kable
89a1bec9c1 Allow staff access to admin button in user menu 2024-05-26 02:56:04 +00:00
Ben Thomas
1c1e70619a Fix ability to delete timers 2024-05-21 23:42:19 +00:00
Ariel Rin
0ff4374efa Version Bump 4.0.2 2024-05-12 19:51:02 +10:00
Ariel Rin
18d0e58a48 Merge branch 'master' of gitlab.com:allianceauth/allianceauth 2024-05-12 19:50:10 +10:00
Ariel Rin
84f44338dc Merge branch 'mute-subtitle' into 'master'
[CHANGE] Mute subtitle text

See merge request allianceauth/allianceauth!1623
2024-05-12 09:48:47 +00:00
Ariel Rin
2ba0412890 Add Polish to language selections 2024-05-12 19:44:30 +10:00
Peter Pfeufer
2326522b29 [CHANGE] Docs updated with the missing subtitle attribute 2024-05-12 11:40:47 +02:00
Peter Pfeufer
a7cb6ee434 [CHANGE] Mute subtitle text 2024-05-12 11:35:42 +02:00
Ariel Rin
2aeef63565 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1609
2024-05-12 09:23:26 +00:00
Ariel Rin
3c9e7335ef Updates for project Alliance Auth 2024-05-12 09:23:26 +00:00
Ariel Rin
49067de325 apply precommit here 2024-05-12 19:21:58 +10:00
Ariel Rin
471e7e29ae Update Source EN 2024-05-12 19:15:56 +10:00
Ariel Rin
3ec5775406 remove unneeded legacy transifex config 2024-05-12 19:15:29 +10:00
Ariel Rin
e804d2b60d update (and sort) precommit 2024-05-12 19:15:14 +10:00
Ariel Rin
742438a95d Merge branch 'timerboard-bg-fix' into 'master'
Make table bg a little less oppressive in timerboard

See merge request allianceauth/allianceauth!1617
2024-04-27 05:09:37 +00:00
Ariel Rin
5c60086baa Merge branch 'add-missing-padding' into 'master'
[ADD] missing padding

See merge request allianceauth/allianceauth!1620
2024-04-27 05:05:22 +00:00
Ariel Rin
e49041bb14 Merge branch 'Haffi-master-patch-21354' into 'master'
updates package registry reference

Closes #1403

See merge request allianceauth/allianceauth!1621
2024-04-25 09:48:10 +00:00
Haffi
f3cbe91883 updates package registry reference 2024-04-25 08:42:18 +00:00
Peter Pfeufer
ea439a2176 [FIX] Indentation 2024-04-15 17:16:01 +02:00
Peter Pfeufer
56e1e76f11 [ADD] Missing theme padding on public pages 2024-04-15 17:15:35 +02:00
entropylaw
634e7357be Update troubleshooting.md. Fixed Typo. 2024-04-13 21:21:13 -05:00
entropylaw
08dc88da1a Update troubleshooting.md 2024-04-13 20:59:19 -05:00
entropylaw
3d206e445c Update troubleshooting.md 2024-04-13 20:55:10 -05:00
entropylaw
64686cdad1 Update troubleshooting.md 2024-04-13 20:49:46 -05:00
AnomicDev
d7fe09bdf1 Update troubleshooting.md 2024-04-14 01:19:51 +00:00
AnomicDev
6da50da92f Update troubleshooting.md 2024-04-14 01:10:38 +00:00
AnomicDev
51e4dd986f Update troubleshooting.md 2024-04-14 01:09:56 +00:00
AnomicDev
bee6522182 Update troubleshooting.md 2024-04-14 01:07:08 +00:00
AnomicDev
1711a9dd33 Update troubleshooting.md 2024-04-14 01:05:25 +00:00
AnomicDev
3914626379 Update troubleshooting.md 2024-04-14 01:04:59 +00:00
AnomicDev
df276cb32d Update troubleshooting.md 2024-04-14 00:59:19 +00:00
AnomicDev
daad7d8b10 Update troubleshooting.md 2024-04-14 00:58:44 +00:00
AnomicDev
3bf5bc0fe3 Update troubleshooting.md 2024-04-14 00:58:09 +00:00
AnomicDev
96abae553a Update troubleshooting.md 2024-04-14 00:57:12 +00:00
AnomicDev
f9cbfb1562 Update troubleshooting.md 2024-04-14 00:55:59 +00:00
AnomicDev
8eaa94e179 Update troubleshooting.md 2024-04-14 00:55:24 +00:00
AnomicDev
4f876b648b Update troubleshooting.md 2024-04-14 00:53:16 +00:00
AnomicDev
cd738137c0 Update troubleshooting.md 2024-04-14 00:52:07 +00:00
Aaron Kable
5605eb129d Make table bg a little less opressive in timerboard 2024-04-10 16:27:09 +08:00
Ariel Rin
87ef0f21a3 Merge branch 'add-missing-colon' into 'master'
[ADD] Missing colon

See merge request allianceauth/allianceauth!1616
2024-04-10 01:12:30 +00:00
Ariel Rin
a1c7ce827e Merge branch 'topnav-revival' into 'master'
V4 Theme - Re-add the Top Nav for unauthenticated users

See merge request allianceauth/allianceauth!1615
2024-04-10 01:09:03 +00:00
Aaron Kable
97466bcdfb V4 Theme - Re-add the Top Nav for unauthenticated users 2024-04-10 01:09:02 +00:00
Peter Pfeufer
ff3096b106 [ADD] Missing colon 2024-04-07 15:58:35 +02:00
Ariel Rin
98f0d77f3f Merge branch 'pre-commit-updates' into 'master'
[MISC] pre-commit config updates

See merge request allianceauth/allianceauth!1614
2024-03-29 02:24:49 +00:00
Peter Pfeufer
92548ba402 [ADD] pyproject.toml validation 2024-03-28 20:40:45 +01:00
Peter Pfeufer
c46741d311 [MISC] Update repo versions 2024-03-28 20:34:31 +01:00
Peter Pfeufer
7c7c1abf7c [CHANGE] Project file linter
We don't use setup.cfg anymore, so we should lint the pyproject.toml file now.
2024-03-28 20:33:16 +01:00
Ariel Rin
fc303b1b0a Merge branch 'fix-phpbb3-mysql-user' into 'master'
[FIX] DB user for phpBB

See merge request allianceauth/allianceauth!1613
2024-03-26 10:19:07 +00:00
Peter Pfeufer
4e220a9679 [FIX] DB user for phpBB 2024-03-24 17:08:34 +01:00
Ariel Rin
b17b1f7504 Version Bump 4.0.1 2024-03-21 19:34:02 +10:00
Ariel Rin
7081fc0e76 Merge branch 'docs' into 'master'
Documentation

See merge request allianceauth/allianceauth!1610
2024-03-21 09:17:43 +00:00
Ariel Rin
68e4574f19 Merge branch 'analytics' into 'master'
Pass Version to analytics user properties

See merge request allianceauth/allianceauth!1612
2024-03-21 09:12:53 +00:00
Ariel Rin
e6e0a70012 Pass Version to analytics user properties 2024-03-21 09:12:53 +00:00
Ariel Rin
13e38da942 Merge branch 'timers-row-background' into 'master'
[CHANGE] Restore the "old" color coding in table rows

See merge request allianceauth/allianceauth!1611
2024-03-21 09:12:25 +00:00
Peter Pfeufer
468c1de26b [CHANGE] restore the "old" color coding in table rows 2024-03-20 19:22:03 +01:00
Ariel Rin
22ef5ac0e5 raw file contents incase someone wgets 2024-03-16 15:44:39 +10:00
Ariel Rin
ef2dc08958 Version Bump 4.0.0 2024-03-16 14:17:29 +10:00
Ariel Rin
6b84ffa16c update pre-commit 2024-03-16 14:16:50 +10:00
Ariel Rin
d7a1096413 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1595
2024-03-16 04:08:52 +00:00
Ariel Rin
93b94a8bc2 Updates for project Alliance Auth 2024-03-16 04:08:52 +00:00
Ariel Rin
9a95716105 Merge branch 'nav-active-passthrough' into 'master'
[Enhancement] Keep menu folders open when a sub item is active

See merge request allianceauth/allianceauth!1608
2024-03-16 04:00:06 +00:00
Aaron Kable
dbfcf5d87a [Enhancement] Keep menu folders open when a sub item is active 2024-03-16 04:00:06 +00:00
Ariel Rin
105d7d53b3 Merge branch 'no-perm-folders' into 'master'
[FIX] Hide empty folders in menu

See merge request allianceauth/allianceauth!1607
2024-03-16 03:59:54 +00:00
Aaron Kable
01cefe1457 [FIX] Hide empty folders in menu 2024-03-16 03:59:54 +00:00
Ariel Rin
7fe3db8017 drop pypy testing 2024-03-13 21:44:48 +10:00
Ariel Rin
e0945fac80 Version Bump 4.0.0rc1 2024-03-13 19:12:11 +10:00
Ariel Rin
40fa190820 Merge branch 'v4docs' into 'v4.x'
Expand Docker Docs for v4

See merge request allianceauth/allianceauth!1577
2024-03-13 09:06:10 +00:00
Ariel Rin
670580f8f3 Merge branch 'sw-version-button-same-height' into 'v4.x'
[FIX] Make SW Version buttons the same height

See merge request allianceauth/allianceauth!1606
2024-03-12 13:23:32 +00:00
Peter Pfeufer
323a0bcf16 [FIX] Make SW Version buttons the same height 2024-03-12 12:42:34 +01:00
Ariel Rin
6e995edd80 Merge branch 'sha-fixes' into 'v4.x'
[FIX] Bootstrap SHA hashes

See merge request allianceauth/allianceauth!1605
2024-03-12 11:30:16 +00:00
Peter Pfeufer
8d86e45b7a [FIX] Bootstrap SHA hashes 2024-03-12 12:29:21 +01:00
Ariel Rin
2aa6df4461 Merge branch 'bootswatch' into 'v4.x'
Bump and unify on bootstrap 5.3.3

See merge request allianceauth/allianceauth!1603
2024-03-12 03:36:19 +00:00
Ariel Rin
cf6f989502 Bump and unify on bootstrap 5.3.3 2024-03-12 03:36:19 +00:00
Ariel Rin
3e1d8ae334 Merge branch 'widgets' into 'v4.x'
When providing a single time, clarify EVE Time

See merge request allianceauth/allianceauth!1604
2024-03-12 03:34:33 +00:00
Ariel Rin
bcfe9484b5 When providing a single time, clarify EVE Time 2024-03-12 03:34:33 +00:00
Ariel Rin
5e4d1b9cfd Merge branch 'timerboard-perms' into 'v4.x'
Add Dashboard Widget View Perms

See merge request allianceauth/allianceauth!1602
2024-03-10 09:36:51 +00:00
Aaron Kable
3b463e7305 Fix timer query, Corp is not nullable 2024-03-08 17:37:11 +08:00
Aaron Kable
eedf5082fa remove the locked hieght from the ops/tiemrs dashboard widgets 2024-03-08 17:15:03 +08:00
Aaron Kable
2ea5b15175 Add perms to ops dashboard view 2024-03-08 17:14:36 +08:00
Aaron Kable
7a9808aad3 Add permision check to timerboard dashboard view 2024-03-08 15:54:39 +08:00
Ariel Rin
a1d712694c Merge branch 'theme-fixes' into 'v4.x'
[V4] Add reject button back to group management.

See merge request allianceauth/allianceauth!1601
2024-03-07 10:35:39 +00:00
Ariel Rin
ca11c726a3 Merge branch 'login-screen-theming' into 'v4.x'
[ADD] Theme CSS to login base template

See merge request allianceauth/allianceauth!1600
2024-03-07 10:34:53 +00:00
Ariel Rin
6e0f7a35bd Merge branch 'login-box-fix' into 'v4.x'
[CHANGE] Give the login box a bit more space

See merge request allianceauth/allianceauth!1599
2024-03-07 10:34:16 +00:00
Aaron Kable
7375b001ca Add reject button back in 2024-03-04 17:18:19 +08:00
Peter Pfeufer
0287086633 [ADD] Theme CSS to login base template 2024-02-25 20:53:52 +01:00
Peter Pfeufer
9eb2becbb5 [CHANGE] Give the login box a bit more space 2024-02-25 20:37:32 +01:00
Ariel Rin
12f1444fe7 add update command 2024-02-24 20:41:10 +10:00
Ariel Rin
d6372bd093 add notes to building custom image 2024-02-24 16:05:50 +10:00
Ariel Rin
3935a9cdd2 Version Bump 4.0.0b2 2024-02-24 14:44:49 +10:00
Ariel Rin
49fb6c39d5 Merge branch 'navactive' into 'v4.x'
Errors thrown here cause 404 error handling to fail. 404s cant url resolve.

See merge request allianceauth/allianceauth!1598
2024-02-24 04:42:48 +00:00
Ariel Rin
8821f18b21 Errors thrown here cause 404 error handling to fail. 404s cant url resolve. 2024-02-24 04:42:48 +00:00
Ariel Rin
f4d8ead54e remove justified text 2024-02-23 23:25:20 +10:00
Ariel Rin
7427e13505 move into docker and add to toctree 2024-02-23 23:21:09 +10:00
Ariel Rin
445683c3d5 Merge branch 'v4.x' of gitlab.com:allianceauth/allianceauth into v4docs 2024-02-23 22:26:38 +10:00
Ariel Rin
677c46c48a very basic migration guide to our v4 docker stack 2024-02-23 22:23:12 +10:00
Ariel Rin
87b9e3f87a use latest python minor 2024-02-23 20:37:41 +10:00
Ariel Rin
da2a5aff2f missing ` 2024-02-23 20:37:18 +10:00
Ariel Rin
65d77743dc fix toctree after myst conversion 2024-02-23 20:37:06 +10:00
Ariel Rin
1c7f8256d0 Merge branch 'fix-filenames' into 'v4.x'
[AA4] Fix dots in file names

See merge request allianceauth/allianceauth!1597
2024-02-22 03:00:47 +00:00
Erik Kalkoken
61f0aae5d9 [AA4] Fix dots in file names 2024-02-22 03:00:47 +00:00
Ariel Rin
4d56030edf Version Bump 4.0.0b1 2024-02-17 20:56:51 +10:00
Ariel Rin
2dfe194a3b Merge branch 'v4.x-banned' into 'v4.x'
[v4.x] ESI Alerts Dashboard Widget

See merge request allianceauth/allianceauth!1591
2024-02-17 10:48:37 +00:00
Aaron Kable
ebb40deb7f [v4.x] ESI Alerts Dashboard Widget 2024-02-17 10:48:37 +00:00
Ariel Rin
a3a2d3d35b Merge branch 'darklyrollback' into 'v4.x'
rollback darkly, fixes #1396

See merge request allianceauth/allianceauth!1594
2024-02-17 10:37:18 +00:00
Ariel Rin
d4dee519b8 rollback darkly, fixes #1396 2024-02-17 20:29:20 +10:00
Ariel Rin
dfcbad3476 Update source EN 2024-02-17 20:09:53 +10:00
Ariel Rin
e03c1307a3 Merge branch 'master' of gitlab.com:allianceauth/allianceauth into v4.x 2024-02-17 20:01:50 +10:00
Ariel Rin
054ef27fa4 Version Bump 3.8.1 2024-02-17 19:39:14 +10:00
Ariel Rin
97e224b8e6 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1593
2024-02-17 09:30:43 +00:00
Ariel Rin
3b8fa415bc Updates for project Alliance Auth 2024-02-17 09:30:43 +00:00
Ariel Rin
b94fd7ed19 I18N Maintenance 2024-02-17 18:52:42 +10:00
Ariel Rin
d1dac61135 Merge branch 'translations_7f31a07ccd4e4a66b1dd7b6bc2dbddb5' into 'master'
Updates for project Alliance Auth

See merge request allianceauth/allianceauth!1563
2024-02-17 08:48:55 +00:00
Ariel Rin
d2a095217f Updates for project Alliance Auth 2024-02-17 08:48:55 +00:00
Ariel Rin
3a95b89779 Merge branch 'cherry-pick-2418023d' into 'v4.x'
remove venv from python command

See merge request allianceauth/allianceauth!1592
2024-02-17 08:39:47 +00:00
Ariel Rin
4f5b231bdf remove venv
(cherry picked from commit 2418023ddd)
2024-02-17 08:02:32 +00:00
Ariel Rin
40c0b8d862 Merge branch 'improve-menu-app' into 'v4.x'
Improve menu app

See merge request allianceauth/allianceauth!1589
2024-02-17 07:56:38 +00:00
Erik Kalkoken
62c936f1c0 Improve menu app 2024-02-17 07:56:38 +00:00
Ariel Rin
2a762df9b3 Merge branch 'bs5-datatable-filterdropdown' into 'v4.x'
Re-enable filter dropdown for Datatables

See merge request allianceauth/allianceauth!1590
2024-02-15 01:56:21 +00:00
Ariel Rin
8fb5a488f7 Merge branch 'bs-merge' into 'v4.x'
[v4.x] Merge Bootstrap/Bootstrap Dark Themes

See merge request allianceauth/allianceauth!1587
2024-02-15 01:55:15 +00:00
Ariel Rin
dc239d5396 Merge branch 'more-framework-functions' into 'v4.x'
[ADD] Evecharacter API functions

See merge request allianceauth/allianceauth!1588
2024-02-15 01:54:12 +00:00
Ariel Rin
2815ebaa07 Merge branch 'template-stuff' into 'v4.x'
Auth Menu Changes and Other Template Fixes

See merge request allianceauth/allianceauth!1586
2024-02-15 01:53:38 +00:00
Peter Pfeufer
34dd4802a8 [CHANGE] Some margins modified to be in line with the dashboard 2024-02-11 15:03:49 +01:00
Peter Pfeufer
3ebf11308c [CHANGE] Re-enable filterDropdown JS 2024-02-04 13:40:48 +01:00
Peter Pfeufer
5cd5180a91 [CHANGE] Use the now official release version 2024-02-04 13:35:05 +01:00
Peter Pfeufer
ba213db493 [CHANGE] Update filterDropDown JS for Bootstrap 5 2024-02-04 13:35:05 +01:00
Peter Pfeufer
8362d11714 [FIX] Mark selected theme in the theme dropdown in the user menu 2024-01-28 10:27:47 +01:00
Peter Pfeufer
7ba65968ed [CHANGE] Make it IDs instead of classes 2024-01-27 09:22:03 +01:00
Peter Pfeufer
7fdbac20cb [REMOVE] Unnecessary bg and text classes from user menu element 2024-01-26 15:01:44 +01:00
Peter Pfeufer
76efcb5266 [ADD] Classes to the dashboard panels to identify them
This is nice to have for theming :-)
2024-01-26 14:58:35 +01:00
Peter Pfeufer
6aacb8c2e3 [REMOVE] Unnecessary active class 2024-01-25 16:29:00 +01:00
Peter Pfeufer
465fba3a18 [FIX] It's user not User 2024-01-24 21:57:03 +01:00
Peter Pfeufer
9ae6addc71 [FIX] Stop Python 3.8 tests from failing (hopefully) 2024-01-24 21:11:04 +01:00
Peter Pfeufer
76ae9b8849 [ADD] get_all_characters_from_user function to User API 2024-01-24 21:03:09 +01:00
Peter Pfeufer
13a8b7678f [ADD] Evecharacter API functions 2024-01-24 20:41:36 +01:00
Aaron Kable
c166fc0ef9 Merge the 2 Bootstrap Themes they dont need to be separate 2024-01-24 17:41:19 +08:00
Peter Pfeufer
9da61588eb [CHANGE] Change the chevron for submenu depending on its toggle status 2024-01-24 10:24:14 +01:00
Peter Pfeufer
7425176b3f [CHANGE] Side menu improvements
- Increase width to 325px
- Add some CSS tricks to ensure long link names don't break the menu
2024-01-23 15:23:48 +01:00
Peter Pfeufer
2bb518f7e0 [CHANGE] Don't generate an empty <p> when no group description
Also, better margins on the badges.
2024-01-23 08:17:18 +01:00
Peter Pfeufer
84d5693583 [CHANGE] Use the right BS class 2024-01-17 22:29:22 +01:00
Peter Pfeufer
867e2a1ded [CHANGE] Replaced style="width: 100%;" with the appropriate BS class 2024-01-17 22:28:17 +01:00
Peter Pfeufer
fd6c6991f5 [REMOVED] Unnecessary text class 2024-01-17 22:25:54 +01:00
Peter Pfeufer
333fe8497d [FIX] Register template to Bootstrap 5 2024-01-17 22:21:16 +01:00
Peter Pfeufer
8a3fb17147 [CHANGE] Reduce the width of the side menu to 300px
This gives the apps a bit of wiggle room for all the tables we have there.
2024-01-17 20:04:07 +01:00
Peter Pfeufer
f8baeb19a7 [FIX] Static no longer needed here 2024-01-16 21:29:46 +01:00
Peter Pfeufer
10096862e5 [CHANGE] Better padding 2024-01-16 20:58:24 +01:00
Peter Pfeufer
89193d2fcf [CHANGE] Set min width, so it's properly readable 2024-01-16 20:32:45 +01:00
Peter Pfeufer
fd08b987bd [CHANGE] Ok, the overflow is needed for keep the menu in its bounds … 2024-01-16 20:24:32 +01:00
Peter Pfeufer
4e9e22cb4b [REMOVED] Unnecessary z-index and overflow
Width fixed as well
2024-01-16 20:18:46 +01:00
Peter Pfeufer
f8fbbb5ba7 [CHANGE] Auth menu for public pages 2024-01-16 20:00:53 +01:00
Peter Pfeufer
dd3ef41396 [FIX] Attribuite name and mandatory alt attribute added 2024-01-16 19:36:54 +01:00
Ariel Rin
d5fda05dc9 Merge branch 'add-missing-bootstrap-class' into 'v4.x'
[ADD] Missing Bootstrap class to select field

See merge request allianceauth/allianceauth!1585
2024-01-16 01:56:13 +00:00
Peter Pfeufer
d815fad0e6 [ADD] Missing Bootstrap class to select field 2024-01-15 07:31:52 +01:00
Ariel Rin
e109198782 Merge branch 'v4.x-theme-work' into 'v4.x'
Move User Actions into new Top Nav areas across the internal apps

See merge request allianceauth/allianceauth!1581
2024-01-15 05:35:19 +00:00
Aaron Kable
fbd4672454 Move User Actions into new Top Nav areas across the internal apps 2024-01-15 05:35:19 +00:00
Ariel Rin
a29bd567c2 Merge branch 'v4.x-user-menu' into 'v4.x'
New User Menu

See merge request allianceauth/allianceauth!1582
2024-01-15 05:34:19 +00:00
Aaron Kable
960aef95ad New User Menu 2024-01-15 05:34:19 +00:00
Ariel Rin
4aae5497bb Merge branch 'callout-box-fixes' into 'v4.x'
Different callout box sizes (through padding)

See merge request allianceauth/allianceauth!1584
2024-01-15 05:29:33 +00:00
Ariel Rin
6081cbe900 Merge branch 'grafanabootstrap' into 'v4.x'
Generate a grafana password during bootstrap script

See merge request allianceauth/allianceauth!1583
2024-01-15 05:27:13 +00:00
Ariel Rin
5e9b47cf79 Merge branch 'docs-improvements' into 'master'
Docs improvements

See merge request allianceauth/allianceauth!1574
2024-01-15 05:25:51 +00:00
Ariel Rin
853826c140 Merge branch 'add-email-timeout' into 'master'
Add email timeout

See merge request allianceauth/allianceauth!1580
2024-01-15 05:19:57 +00:00
Peter Pfeufer
ce0d8342e3 [REMOVE] Wrong modifier class in docs 2024-01-07 15:27:42 +01:00
Peter Pfeufer
006785e592 [CHANGE] Use default alert box margin as base 2024-01-07 15:05:41 +01:00
Peter Pfeufer
df05070a55 [ADD] Bootstrap class for bottom margin to callout box in SRP module 2024-01-07 14:02:59 +01:00
Peter Pfeufer
e81450baf3 [CHANGE] Docs updated 2024-01-07 13:57:47 +01:00
Peter Pfeufer
24b6c19aca [ADD] Different sizes (through padding) 2024-01-07 13:34:50 +01:00
Ariel Rin
9f4bf13cc9 Expand documentation on building a custom image, provide example 2024-01-05 15:42:39 +10:00
Ariel Rin
2a156302f0 Merge branch 'top-nav-fix' into 'v4.x'
[ADD] Missing Bootstrap class to top navigation blocks

See merge request allianceauth/allianceauth!1578
2024-01-05 05:42:09 +00:00
Ariel Rin
c4d3bde106 Generate a grafana password during bootstrap script 2024-01-05 15:34:27 +10:00
ErikKalkoken
9c7de58989 Add email timeout 2024-01-02 11:48:27 +01:00
Peter Pfeufer
0900806f68 [REMOVE] Unnecessary empty div 2023-12-29 20:10:06 +01:00
Peter Pfeufer
a0d32d8c2d [ADD] Missing Bootstrap class 2023-12-29 19:57:15 +01:00
Ariel Rin
51b86f88b9 generate some basic docker install guides for services 2023-12-26 20:41:53 +10:00
Ariel Rin
8184461b48 use docker compose instead of dash, add hint 2023-12-26 19:35:11 +10:00
Ariel Rin
ca0cdd6e15 remove old docs images 2023-12-26 19:34:25 +10:00
Ariel Rin
036a17ad3b note the container name changes after refactor 2023-12-26 19:34:09 +10:00
Ariel Rin
2418023ddd remove venv 2023-12-26 19:28:34 +10:00
Peter Pfeufer
6e3219fd1b [FIX] Grammar and spelling 2023-12-17 20:21:11 +01:00
Peter Pfeufer
8aeb061635 [ADD] Remark on how to stop Gunicorn when testing 2023-12-17 17:45:29 +01:00
Peter Pfeufer
84e2107b62 [CHANGE] Switch to adduser for Ubuntu
This will create the users' hoe directory and make it a no-login user in one command.
2023-12-17 17:42:08 +01:00
253 changed files with 29133 additions and 10363 deletions

View File

@@ -19,5 +19,6 @@ exclude_lines =
if __name__ == .__main__.:
def __repr__
raise AssertionError
if TYPE_CHECKING:
ignore_errors = True

View File

@@ -25,12 +25,12 @@ before_script:
pre-commit-check:
<<: *only-default
stage: pre-commit
image: python:3.11-bullseye
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
cache:
paths:
- ${PRE_COMMIT_HOME}
image: python:3.11-bookworm
# variables:
# PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
# cache:
# paths:
# - ${PRE_COMMIT_HOME}
script:
- pip install pre-commit
- pre-commit run --all-files
@@ -53,7 +53,7 @@ secret_detection:
test-3.8-core:
<<: *only-default
image: python:3.8-bullseye
image: python:3.8-bookworm
script:
- tox -e py38-core
artifacts:
@@ -65,7 +65,7 @@ test-3.8-core:
test-3.9-core:
<<: *only-default
image: python:3.9-bullseye
image: python:3.9-bookworm
script:
- tox -e py39-core
artifacts:
@@ -77,7 +77,7 @@ test-3.9-core:
test-3.10-core:
<<: *only-default
image: python:3.10-bullseye
image: python:3.10-bookworm
script:
- tox -e py310-core
artifacts:
@@ -89,7 +89,7 @@ test-3.10-core:
test-3.11-core:
<<: *only-default
image: python:3.11-bullseye
image: python:3.11-bookworm
script:
- tox -e py311-core
artifacts:
@@ -101,7 +101,7 @@ test-3.11-core:
test-3.12-core:
<<: *only-default
image: python:3.12-rc-bullseye
image: python:3.12-bookworm
script:
- tox -e py312-core
artifacts:
@@ -113,7 +113,7 @@ test-3.12-core:
test-3.8-all:
<<: *only-default
image: python:3.8-bullseye
image: python:3.8-bookworm
script:
- tox -e py38-all
artifacts:
@@ -125,7 +125,7 @@ test-3.8-all:
test-3.9-all:
<<: *only-default
image: python:3.9-bullseye
image: python:3.9-bookworm
script:
- tox -e py39-all
artifacts:
@@ -137,7 +137,7 @@ test-3.9-all:
test-3.10-all:
<<: *only-default
image: python:3.10-bullseye
image: python:3.10-bookworm
script:
- tox -e py310-all
artifacts:
@@ -149,7 +149,7 @@ test-3.10-all:
test-3.11-all:
<<: *only-default
image: python:3.11-bullseye
image: python:3.11-bookworm
script:
- tox -e py311-all
artifacts:
@@ -162,7 +162,7 @@ test-3.11-all:
test-3.12-all:
<<: *only-default
image: python:3.12-rc-bullseye
image: python:3.12-bookworm
script:
- tox -e py312-all
artifacts:
@@ -174,7 +174,7 @@ test-3.12-all:
build-test:
stage: test
image: python:3.11-bullseye
image: python:3.11-bookworm
before_script:
- python -m pip install --upgrade pip
@@ -193,13 +193,13 @@ build-test:
test-docs:
<<: *only-default
image: python:3.11-bullseye
image: python:3.11-bookworm
script:
- tox -e docs
deploy_production:
stage: deploy
image: python:3.11-bullseye
image: python:3.11-bookworm
before_script:
- python -m pip install --upgrade pip

View File

@@ -4,8 +4,21 @@
# pre-commit autoupdate
repos:
# Code Upgrades
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.17.0
hooks:
- id: django-upgrade
args: [--target-version=4.2]
# Formatting
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
# Identify invalid files
- id: check-ast
@@ -13,27 +26,24 @@ repos:
- id: check-json
- id: check-toml
- id: check-xml
# git checks
- id: check-merge-conflict
- id: check-added-large-files
args: [ --maxkb=1000 ]
args: [--maxkb=1000]
- id: detect-private-key
- id: check-case-conflict
# Python checks
# - id: check-docstring-first
# - id: check-docstring-first
- id: debug-statements
# - id: requirements-txt-fixer
# - id: requirements-txt-fixer
- id: fix-encoding-pragma
args: [ --remove ]
args: [--remove]
- id: fix-byte-order-marker
# General quality checks
- id: mixed-line-ending
args: [ --fix=lf ]
args: [--fix=lf]
- id: trailing-whitespace
args: [ --markdown-linebreak-ext=md ]
args: [--markdown-linebreak-ext=md]
exclude: |
(?x)(
\.min\.css|
@@ -52,9 +62,8 @@ repos:
\.mo|
swagger\.json
)
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: 2.7.2
rev: 2.7.3
hooks:
- id: editorconfig-checker
exclude: |
@@ -65,21 +74,26 @@ repos:
\.mo|
swagger\.json
)
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]
- repo: https://github.com/adamchainz/django-upgrade
rev: 1.14.0
- id: markdownlint
args:
- --disable=MD013
# Infrastructure
- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.1.3
hooks:
- id: django-upgrade
args: [--target-version=4.2]
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.3.0
- id: pyproject-fmt
name: pyproject.toml formatter
description: "Format the pyproject.toml file."
args:
- --indent=4
additional_dependencies:
- tox==4.15.0 # https://github.com/tox-dev/tox/releases/latest
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.18
hooks:
- id: setup-cfg-fmt
args: [ --include-version-classifiers ]
- id: validate-pyproject
name: Validate pyproject.toml
description: "Validate the pyproject.toml file."

View File

@@ -1,10 +0,0 @@
[main]
host = https://app.transifex.com
lang_map = zh-Hans: zh_Hans
[o:alliance-auth:p:alliance-auth:r:django-po]
file_filter = allianceauth/locale/<lang>/LC_MESSAGES/django.po
source_file = allianceauth/locale/en/LC_MESSAGES/django.po
source_lang = en
type = PO
minimum_perc = 0

View File

@@ -5,7 +5,7 @@
[![django](https://img.shields.io/pypi/djversions/allianceauth?label=django)](https://pypi.org/project/allianceauth/)
[![version](https://img.shields.io/pypi/v/allianceauth?label=release)](https://pypi.org/project/allianceauth/)
[![pipeline status](https://gitlab.com/allianceauth/allianceauth/badges/master/pipeline.svg)](https://gitlab.com/allianceauth/allianceauth/commits/master)
[![Documentation Status](https://readthedocs.org/projects/allianceauth/badge/?version=latest)](http://allianceauth.readthedocs.io/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/allianceauth/badge/?version=latest)](https://allianceauth.readthedocs.io/?badge=latest)
[![coverage report](https://gitlab.com/allianceauth/allianceauth/badges/master/coverage.svg)](https://gitlab.com/allianceauth/allianceauth/commits/master)
[![Chat on Discord](https://img.shields.io/discord/399006117012832262.svg)](https://discord.gg/fjnHAmk)
@@ -14,7 +14,7 @@ An auth system for EVE Online to help in-game organizations manage online servic
## Content
- [Overview](#overview)
- [Documentation](http://allianceauth.rtfd.io)
- [Documentation](https://allianceauth.rtfd.io)
- [Support](#support)
- [Release Notes](https://gitlab.com/allianceauth/allianceauth/-/releases)
- [Developer Team](#development-team)
@@ -38,7 +38,7 @@ Main features:
- English :flag_gb:, Chinese :flag_cn:, German :flag_de:, Spanish :flag_es:, Korean :flag_kr:, Russian :flag_ru:, Italian :flag_it:, French :flag_fr:, Japanese :flag_jp: and Ukrainian :flag_ua: Localization
For further details about AA - including an installation guide and a full list of included services and plugin apps - please see the [official documentation](http://allianceauth.rtfd.io).
For further details about AA - including an installation guide and a full list of included services and plugin apps - please see the [official documentation](https://allianceauth.rtfd.io).
## Screenshot

View File

@@ -5,7 +5,7 @@ manage online service access.
# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
__version__ = '4.0.0a5'
__version__ = '4.4.0'
__title__ = 'Alliance Auth'
__url__ = 'https://gitlab.com/allianceauth/allianceauth'
NAME = f'{__title__} v{__version__}'

View File

@@ -9,6 +9,8 @@ from .utils import (
install_stat_tokens,
install_stat_users)
from allianceauth import __version__
logger = logging.getLogger(__name__)
BASE_URL = "https://www.google-analytics.com"
@@ -99,11 +101,38 @@ def analytics_daily_stats():
event_type='Stats')
for appconfig in apps.get_app_configs():
analytics_event(namespace='allianceauth.analytics',
task='send_extension_stats',
label=appconfig.label,
value=1,
event_type='Stats')
if appconfig.label in [
"django_celery_beat",
"bootstrapform",
"messages",
"sessions",
"auth",
"staticfiles",
"users",
"addons",
"admin",
"humanize",
"contenttypes",
"sortedm2m",
"django_bootstrap5",
"tokens",
"authentication",
"services",
"framework",
"notifications"
"eveonline",
"navhelper",
"analytics",
"menu",
"theme"
]:
pass
else:
analytics_event(namespace='allianceauth.analytics',
task='send_extension_stats',
label=appconfig.label,
value=1,
event_type='Stats')
@shared_task()
@@ -139,7 +168,7 @@ def send_ga_tracking_celery_event(
'client_id': AnalyticsIdentifier.objects.get(id=1).identifier.hex,
"user_properties": {
"allianceauth_version": {
"value": "allianceauth_version"
"value": __version__
}
},
'non_personalized_ads': True,

View File

@@ -5,26 +5,5 @@ from django.core.checks import Warning, Error, register
class AllianceAuthConfig(AppConfig):
name = 'allianceauth'
@register()
def check_settings(app_configs, **kwargs):
from django.conf import settings
errors = []
if hasattr(settings, "SITE_URL"):
if settings.SITE_URL[-1] == "/":
errors.append(Warning(
"'SITE_URL' Has a trailing slash. This may lead to incorrect links being generated by Auth."))
else:
errors.append(Error(
"No 'SITE_URL' found is settings. This may lead to incorrect links being generated by Auth or Errors in 3rd party modules."))
if hasattr(settings, "CSRF_TRUSTED_ORIGINS"):
if hasattr(settings, "SITE_URL"):
if settings.SITE_URL not in settings.CSRF_TRUSTED_ORIGINS:
errors.append(Warning(
"'SITE_URL' not found in 'CSRF_TRUSTED_ORIGINS'. Auth may not load pages correctly until this is rectified."))
else:
errors.append(Error(
"No 'CSRF_TRUSTED_ORIGINS' found is settings, Auth may not load pages correctly until this is rectified"))
return errors
def ready(self) -> None:
import allianceauth.checks # noqa

View File

@@ -1,6 +1,6 @@
from allianceauth.hooks import DashboardItemHook
from allianceauth import hooks
from .views import dashboard_characters, dashboard_groups, dashboard_admin
from .views import dashboard_characters, dashboard_esi_check, dashboard_groups, dashboard_admin
class UserCharactersHook(DashboardItemHook):
@@ -26,6 +26,15 @@ class AdminHook(DashboardItemHook):
DashboardItemHook.__init__(
self,
dashboard_admin,
1
)
class ESICheckHook(DashboardItemHook):
def __init__(self):
DashboardItemHook.__init__(
self,
dashboard_esi_check,
0
)
@@ -43,3 +52,8 @@ def register_groups_hook():
@hooks.register('dashboard_hook')
def register_admin_hook():
return AdminHook()
@hooks.register('dashboard_hook')
def register_esi_hook():
return ESICheckHook()

View File

@@ -0,0 +1,12 @@
from django.utils.translation import gettext_lazy as _
# Overide ESI messages in the dashboard widget
# when the returned messages are not helpful or out of date
ESI_ERROR_MESSAGE_OVERRIDES = {
420: _("This software has exceeded the error limit for ESI. "
"If you are a user, please contact the maintainer of this software."
" If you are a developer/maintainer, please make a greater "
"effort in the future to receive valid responses. For tips on how, "
"come have a chat with us in ##3rd-party-dev-and-esi on the EVE "
"Online Discord. https://www.eveonline.com/discord")
}

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.2.13 on 2024-05-12 09:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('authentication', '0022_userprofile_theme'),
]
operations = [
migrations.AlterField(
model_name='userprofile',
name='language',
field=models.CharField(blank=True, choices=[('en', 'English'), ('de', 'German'), ('es', 'Spanish'), ('zh-hans', 'Chinese Simplified'), ('ru', 'Russian'), ('ko', 'Korean'), ('fr', 'French'), ('ja', 'Japanese'), ('it', 'Italian'), ('uk', 'Ukrainian'), ('pl', 'Polish')], default='', max_length=10, verbose_name='Language'),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.2 on 2024-09-13 09:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('authentication', '0023_alter_userprofile_language'),
]
operations = [
migrations.AlterField(
model_name='userprofile',
name='language',
field=models.CharField(blank=True, choices=[('en', 'English'), ('cs-cz', 'Czech'), ('de', 'German'), ('es', 'Spanish'), ('it-it', 'Italian'), ('ja', 'Japanese'), ('ko-kr', 'Korean'), ('fr-fr', 'French'), ('ru', 'Russian'), ('nl-nl', 'Dutch'), ('pl-pl', 'Polish'), ('uk', 'Ukrainian'), ('zh-hans', 'Simplified Chinese')], default='', max_length=10, verbose_name='Language'),
),
]

View File

@@ -67,17 +67,20 @@ class UserProfile(models.Model):
"""
Choices for UserProfile.language
"""
# Sorted by Language Code alphabetical order + English at top
ENGLISH = 'en', _('English')
CZECH = 'cs-cz', _("Czech") # Not yet at 50% translated
GERMAN = 'de', _('German')
SPANISH = 'es', _('Spanish')
CHINESE = 'zh-hans', _('Chinese Simplified')
RUSSIAN = 'ru', _('Russian')
KOREAN = 'ko', _('Korean')
FRENCH = 'fr', _('French')
ITALIAN = 'it-it', _('Italian')
JAPANESE = 'ja', _('Japanese')
ITALIAN = 'it', _('Italian')
KOREAN = 'ko-kr', _('Korean')
FRENCH = 'fr-fr', _('French')
RUSSIAN = 'ru', _('Russian')
DUTCH = 'nl-nl', _("Dutch")
POLISH = 'pl-pl', _("Polish")
UKRAINIAN = 'uk', _('Ukrainian')
CHINESE = 'zh-hans', _('Simplified Chinese')
user = models.OneToOneField(
User,

View File

@@ -7,7 +7,7 @@
{% translate "Dashboard" %}
{% endblock %}
{% block content %}
<div class="d-flex justify-content-around align-self-center flex-wrap">
<div class="row">
{% for dash in views %}
{{ dash | safe }}
{% endfor %}

View File

@@ -0,0 +1,10 @@
{% extends 'allianceauth/base.html' %}
{% block page_title %}Dashboard{% endblock page_title %}
{% block content %}
<div>
<h1>Dashboard Dummy</h1>
</div>
{% endblock %}

View File

@@ -1,13 +1,11 @@
{% load i18n %}
<div class="col-12 col-xl-8 align-self-stretch p-2 ps-0 pe-0 ps-xl-0 pe-xl-2">
<div class="card">
<div id="aa-dashboard-panel-characters" class="col-12 col-xl-8 mb-3">
<div class="card h-100">
<div class="card-body">
<div class="d-flex align-items-center">
<h4 class="ms-auto me-auto">
{% translate "Characters" %}
</h4>
</div>
<div class="card-body">
{% translate "Characters" as widget_title %}
{% include "framework/dashboard/widget-title.html" with title=widget_title %}
<div>
<div style="height: 300px; overflow-y:auto;">
<div class="d-flex">
<a href="{% url 'authentication:add_character' %}" class="btn btn-primary flex-fill m-1" title="{% translate 'Add Character' %}">

View File

@@ -1,9 +1,11 @@
{% load i18n %}
<div class="col-12 col-xl-4 align-self-stretch py-2 ps-xl-2">
<div id="aa-dashboard-panel-membership" class="col-12 col-xl-4 mb-3">
<div class="card h-100">
<div class="card-body">
<h4 class="card-title text-center">{% translate "Membership" %}</h4>
<div class="card-body">
{% translate "Membership" as widget_title %}
{% include "framework/dashboard/widget-title.html" with title=widget_title %}
<div>
<div style="height: 300px; overflow-y:auto;">
<h5 class="text-center">{% translate "State:" %} {{ request.user.profile.state }}</h5>
<table class="table">

View File

@@ -16,7 +16,7 @@
{% translate "This page is a best attempt, but backups or database logs can still contain your tokens. Always revoke tokens on https://community.eveonline.com/support/third-party-applications/ where possible."|urlize %}
</p>
<table class="table" id="table_tokens" style="width: 100%;">
<table class="table w-100" id="table_tokens">
<thead>
<tr>
<th>{% translate "Scopes" %}</th>

View File

@@ -1,3 +1,4 @@
{% load theme_tags %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
@@ -16,7 +17,7 @@
<title>{% block title %}{% block page_title %}{% endblock page_title %} - {{ SITE_NAME }}{% endblock title %}</title>
{% include 'bundles/bootstrap-css-bs5.html' %}
{% theme_css %}
{% include 'bundles/fontawesome.html' %}
{% block extra_include %}

View File

@@ -4,7 +4,7 @@
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<select onchange="this.form.submit()" class="form-control" id="lang-select" name="language">
<select class="form-select" onchange="this.form.submit()" class="form-control" id="lang-select" name="language">
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}

View File

@@ -4,7 +4,7 @@
{% block content %}
<div class="row justify-content-center">
<div class="col-md-4">
<div class="col-md-6">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.level_tag}}">{{ message }}</div>

View File

@@ -1,6 +1,6 @@
{% extends 'public/base.html' %}
{% load bootstrap %}
{% load django_bootstrap5 %}
{% load i18n %}
{% block page_title %}{% translate "Registration" %}{% endblock %}
@@ -12,16 +12,20 @@
{% endblock %}
{% block content %}
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default panel-transparent">
<div class="panel-body">
<form method="POST">
{% csrf_token %}
{{ form|bootstrap }}
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Register" %}</button>
</form>
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card card-login border-secondary p-3">
<div class="card-body">
<form method="POST">
{% csrf_token %}
{% bootstrap_form form %}
<button class="btn btn-primary btn-block" type="submit">{% translate "Register" %}</button>
</form>
{% include 'public/lang_select.html' %}
</div>
</div>
</div>
{% include 'public/lang_select.html' %}
</div>
{% endblock %}

View File

@@ -1,10 +1,12 @@
import json
import requests_mock
from unittest.mock import patch
from django.test import RequestFactory, TestCase
from allianceauth.authentication.views import task_counts
from allianceauth.authentication.views import task_counts, esi_check
from allianceauth.tests.auth_utils import AuthUtils
from allianceauth.authentication.constants import ESI_ERROR_MESSAGE_OVERRIDES
MODULE_PATH = "allianceauth.authentication.views"
@@ -21,6 +23,8 @@ class TestRunningTasksCount(TestCase):
super().setUpClass()
cls.factory = RequestFactory()
cls.user = AuthUtils.create_user("bruce_wayne")
cls.user.is_superuser = True
cls.user.save()
def test_should_return_data(
self, mock_active_tasks_count, mock_queued_tasks_count
@@ -35,5 +39,164 @@ class TestRunningTasksCount(TestCase):
# then
self.assertEqual(response.status_code, 200)
self.assertDictEqual(
jsonresponse_to_dict(response), {"tasks_running": 2, "tasks_queued": 3}
jsonresponse_to_dict(response), {
"tasks_running": 2, "tasks_queued": 3}
)
def test_su_only(
self, mock_active_tasks_count, mock_queued_tasks_count
):
self.user.is_superuser = False
self.user.save()
self.user.refresh_from_db()
# given
mock_active_tasks_count.return_value = 2
mock_queued_tasks_count.return_value = 3
request = self.factory.get("/")
request.user = self.user
# when
response = task_counts(request)
# then
self.assertEqual(response.status_code, 302)
class TestEsiCheck(TestCase):
@classmethod
def setUpClass(cls) -> None:
super().setUpClass()
cls.factory = RequestFactory()
cls.user = AuthUtils.create_user("bruce_wayne")
cls.user.is_superuser = True
cls.user.save()
@requests_mock.Mocker()
def test_401_data_returns_200(
self, m
):
error_json = {
"error": "You have been banned from using ESI. Please contact Technical Support. (support@eveonline.com)"
}
status_code = 401
m.get(
"https://esi.evetech.net/latest/status/?datasource=tranquility",
text=json.dumps(error_json),
status_code=status_code
)
# given
request = self.factory.get("/")
request.user = self.user
# when
response = esi_check(request)
# then
self.assertEqual(response.status_code, 200)
self.assertDictEqual(
jsonresponse_to_dict(response), {
"status": status_code,
"data": error_json
}
)
@requests_mock.Mocker()
def test_504_data_returns_200(
self, m
):
error_json = {
"error": "Gateway timeout message",
"timeout": 5000
}
status_code = 504
m.get(
"https://esi.evetech.net/latest/status/?datasource=tranquility",
text=json.dumps(error_json),
status_code=status_code
)
# given
request = self.factory.get("/")
request.user = self.user
# when
response = esi_check(request)
# then
self.assertEqual(response.status_code, 200)
self.assertDictEqual(
jsonresponse_to_dict(response), {
"status": status_code,
"data": error_json
}
)
@requests_mock.Mocker()
def test_420_data_override(
self, m
):
error_json = {
"error": "message from CCP",
}
status_code = 420
m.get(
"https://esi.evetech.net/latest/status/?datasource=tranquility",
text=json.dumps(error_json),
status_code=status_code
)
# given
request = self.factory.get("/")
request.user = self.user
# when
response = esi_check(request)
# then
self.assertEqual(response.status_code, 200)
self.assertNotEqual(
jsonresponse_to_dict(response)["data"],
error_json
)
self.assertDictEqual(
jsonresponse_to_dict(response), {
"status": status_code,
"data": {
"error": ESI_ERROR_MESSAGE_OVERRIDES.get(status_code)
}
}
)
@requests_mock.Mocker()
def test_200_data_returns_200(
self, m
):
good_json = {
"players": 5,
"server_version": "69420",
"start_time": "2030-01-01T23:59:59Z"
}
status_code = 200
m.get(
"https://esi.evetech.net/latest/status/?datasource=tranquility",
text=json.dumps(good_json),
status_code=status_code
)
# given
request = self.factory.get("/")
request.user = self.user
# when
response = esi_check(request)
# then
self.assertEqual(response.status_code, 200)
self.assertDictEqual(
jsonresponse_to_dict(response), {
"status": status_code,
"data": good_json
}
)
def test_su_only(
self,
):
self.user.is_superuser = False
self.user.save()
self.user.refresh_from_db()
# given
request = self.factory.get("/")
request.user = self.user
# when
response = esi_check(request)
# then
self.assertEqual(response.status_code, 302)

View File

@@ -38,5 +38,7 @@ urlpatterns = [
name='token_refresh'
),
path('dashboard/', views.dashboard, name='dashboard'),
path('dashboard_bs3/', views.dashboard_bs3, name='dashboard_bs3'),
path('task-counts/', views.task_counts, name='task_counts'),
path('esi-check/', views.esi_check, name='esi_check'),
]

View File

@@ -1,6 +1,6 @@
import logging
from allianceauth.hooks import get_hooks
import requests
from django_registration.backends.activation.views import (
REGISTRATION_SALT, ActivationView as BaseActivationView,
RegistrationView as BaseRegistrationView,
@@ -10,7 +10,7 @@ from django_registration.signals import user_registered
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.contrib.auth.decorators import login_required, user_passes_test
from django.contrib.auth.models import User
from django.core import signing
from django.http import JsonResponse
@@ -23,14 +23,16 @@ from esi.decorators import token_required
from esi.models import Token
from allianceauth.eveonline.models import EveCharacter
from allianceauth.hooks import get_hooks
from .constants import ESI_ERROR_MESSAGE_OVERRIDES
from .core.celery_workers import active_tasks_count, queued_tasks_count
from .forms import RegistrationForm
from .models import CharacterOwnership
if 'allianceauth.eveonline.autogroups' in settings.INSTALLED_APPS:
_has_auto_groups = True
from allianceauth.eveonline.autogroups.models import *
from allianceauth.eveonline.autogroups.models import * # noqa: F401, F403
else:
_has_auto_groups = False
@@ -54,7 +56,7 @@ def dashboard_groups(request):
context = {
'groups': groups,
}
return render_to_string('authentication/dashboard.groups.html', context=context, request=request)
return render_to_string('authentication/dashboard_groups.html', context=context, request=request)
def dashboard_characters(request):
@@ -66,7 +68,7 @@ def dashboard_characters(request):
context = {
'characters': characters
}
return render_to_string('authentication/dashboard.characters.html', context=context, request=request)
return render_to_string('authentication/dashboard_characters.html', context=context, request=request)
def dashboard_admin(request):
@@ -76,6 +78,13 @@ def dashboard_admin(request):
return ""
def dashboard_esi_check(request):
if request.user.is_superuser:
return render_to_string('allianceauth/admin-status/esi_check.html', request=request)
else:
return ""
@login_required
def dashboard(request):
_dash_items = list()
@@ -135,23 +144,30 @@ def token_refresh(request, token_id=None):
@login_required
@token_required(scopes=settings.LOGIN_TOKEN_SCOPES)
def main_character_change(request, token):
logger.debug(f"main_character_change called by user {request.user} for character {token.character_name}")
logger.debug(
f"main_character_change called by user {request.user} for character {token.character_name}")
try:
co = CharacterOwnership.objects.get(character__character_id=token.character_id, user=request.user)
co = CharacterOwnership.objects.get(
character__character_id=token.character_id, user=request.user)
except CharacterOwnership.DoesNotExist:
if not CharacterOwnership.objects.filter(character__character_id=token.character_id).exists():
co = CharacterOwnership.objects.create_by_token(token)
else:
messages.error(
request,
_('Cannot change main character to %(char)s: character owned by a different account.') % ({'char': token.character_name})
_('Cannot change main character to %(char)s: character owned by a different account.') % (
{'char': token.character_name})
)
co = None
if co:
request.user.profile.main_character = co.character
request.user.profile.save(update_fields=['main_character'])
messages.success(request, _('Changed main character to %(char)s') % {"char": co.character})
logger.info('Changed user %(user)s main character to %(char)s' % ({'user': request.user, 'char': co.character}))
messages.success(request, _('Changed main character to %s') % co.character)
logger.info(
'Changed user {user} main character to {char}'.format(
user=request.user, char=co.character
)
)
return redirect("authentication:dashboard")
@@ -159,9 +175,11 @@ def main_character_change(request, token):
def add_character(request, token):
if CharacterOwnership.objects.filter(character__character_id=token.character_id).filter(
owner_hash=token.character_owner_hash).filter(user=request.user).exists():
messages.success(request, _('Added %(name)s to your account.' % ({'name': token.character_name})))
messages.success(request, _(
'Added %(name)s to your account.' % ({'name': token.character_name})))
else:
messages.error(request, _('Failed to add %(name)s to your account: they already have an account.' % ({'name': token.character_name})))
messages.error(request, _('Failed to add %(name)s to your account: they already have an account.' % (
{'name': token.character_name})))
return redirect('authentication:dashboard')
@@ -204,8 +222,10 @@ def sso_login(request, token):
token.delete()
messages.error(
request,
_('Unable to authenticate as the selected character. '
'Please log in with the main character associated with this account.')
_(
'Unable to authenticate as the selected character. '
'Please log in with the main character associated with this account.'
)
)
return redirect(settings.LOGIN_URL)
@@ -278,7 +298,8 @@ class RegistrationView(BaseRegistrationView):
return super().dispatch(request, *args, **kwargs)
def register(self, form):
user = User.objects.get(pk=self.request.session.get('registration_uid'))
user = User.objects.get(
pk=self.request.session.get('registration_uid'))
user.email = form.cleaned_data['email']
user_registered.send(self.__class__, user=user, request=self.request)
if getattr(settings, 'REGISTRATION_VERIFY_EMAIL', True):
@@ -295,7 +316,8 @@ class RegistrationView(BaseRegistrationView):
def get_email_context(self, activation_key):
context = super().get_email_context(activation_key)
context['url'] = context['site'].domain + reverse('registration_activate', args=[activation_key])
context['url'] = context['site'].domain + \
reverse('registration_activate', args=[activation_key])
return context
@@ -328,20 +350,24 @@ class ActivationView(BaseActivationView):
def registration_complete(request):
messages.success(request, _('Sent confirmation email. Please follow the link to confirm your email address.'))
messages.success(request, _(
'Sent confirmation email. Please follow the link to confirm your email address.'))
return redirect('authentication:login')
def activation_complete(request):
messages.success(request, _('Confirmed your email address. Please login to continue.'))
messages.success(request, _(
'Confirmed your email address. Please login to continue.'))
return redirect('authentication:dashboard')
def registration_closed(request):
messages.error(request, _('Registration of new accounts is not allowed at this time.'))
messages.error(request, _(
'Registration of new accounts is not allowed at this time.'))
return redirect('authentication:login')
@user_passes_test(lambda u: u.is_superuser)
def task_counts(request) -> JsonResponse:
"""Return task counts as JSON for an AJAX call."""
data = {
@@ -349,3 +375,31 @@ def task_counts(request) -> JsonResponse:
"tasks_queued": queued_tasks_count()
}
return JsonResponse(data)
def check_for_override_esi_error_message(response):
if response.status_code in ESI_ERROR_MESSAGE_OVERRIDES:
return {"error": ESI_ERROR_MESSAGE_OVERRIDES.get(response.status_code)}
else:
return response.json()
@user_passes_test(lambda u: u.is_superuser)
def esi_check(request) -> JsonResponse:
"""Return if ESI ok With error messages and codes as JSON"""
_r = requests.get("https://esi.evetech.net/latest/status/?datasource=tranquility")
data = {
"status": _r.status_code,
"data": check_for_override_esi_error_message(_r)
}
return JsonResponse(data)
@login_required
def dashboard_bs3(request):
"""Render dashboard view with BS3 theme.
This is an internal view used for testing BS3 backward compatibility in AA4 only.
"""
return render(request, 'authentication/dashboard_bs3.html')

187
allianceauth/checks.py Normal file
View File

@@ -0,0 +1,187 @@
from typing import List
from django import db
from django.core.checks import CheckMessage, Error, register, Warning
from allianceauth.utils.cache import get_redis_client
from django.utils import timezone
from packaging.version import InvalidVersion, Version as Pep440Version
from celery import current_app
from django.conf import settings
from sqlite3.dbapi2 import sqlite_version_info
"""
A = System Packages
B = Configuration
"""
@register()
def django_settings(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
if hasattr(settings, "SITE_URL"):
if settings.SITE_URL[-1] == "/":
errors.append(Warning("'SITE_URL' Has a trailing slash. This may lead to incorrect links being generated by Auth.", hint="", id="allianceauth.checks.B005"))
else:
errors.append(Error("No 'SITE_URL' found is settings. This may lead to incorrect links being generated by Auth or Errors in 3rd party modules.", hint="", id="allianceauth.checks.B006"))
if hasattr(settings, "CSRF_TRUSTED_ORIGINS") and hasattr(settings, "SITE_URL"):
if settings.SITE_URL not in settings.CSRF_TRUSTED_ORIGINS:
errors.append(Warning("'SITE_URL' not found in 'CSRF_TRUSTED_ORIGINS'. Auth may not load pages correctly until this is rectified.", hint="", id="allianceauth.checks.B007"))
else:
errors.append(Error("No 'CSRF_TRUSTED_ORIGINS' found is settings, Auth may not load pages correctly until this is rectified", hint="", id="allianceauth.checks.B008"))
return errors
@register()
def system_package_redis(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
try:
redis_version = Pep440Version(get_redis_client().info()['redis_version'])
except InvalidVersion:
errors.append(Warning("Unable to confirm Redis Version"))
return errors
if redis_version.major == 7 and redis_version.minor == 2 and timezone.now() > timezone.datetime(year=2025, month=8, day=31, tzinfo=timezone.utc):
errors.append(Error(f"Redis {redis_version.public} in Security Support only, Updating Suggested", hint="https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html#redis-and-other-tools", id="allianceauth.checks.A001"))
elif redis_version.major == 7 and redis_version.minor == 0:
errors.append(Warning(f"Redis {redis_version.public} in Security Support only, Updating Suggested", hint="https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html#redis-and-other-tools", id="allianceauth.checks.A002"))
elif redis_version.major == 6 and redis_version.minor == 2:
errors.append(Warning(f"Redis {redis_version.public} in Security Support only, Updating Suggested", hint="https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html#redis-and-other-tools", id="allianceauth.checks.A018"))
elif redis_version.major in [6, 5]:
errors.append(Error(f"Redis {redis_version.public} EOL", hint="https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html#redis-and-other-tools", id="allianceauth.checks.A003"))
return errors
@register()
def system_package_mysql(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
for connection in db.connections.all():
if connection.vendor == "mysql":
try:
mysql_version = Pep440Version(".".join(str(i) for i in connection.mysql_version))
except InvalidVersion:
errors.append(Warning("Unable to confirm MySQL Version"))
return errors
# MySQL 8
if mysql_version.major == 8 and mysql_version.minor == 4 and timezone.now() > timezone.datetime(year=2032, month=4, day=30, tzinfo=timezone.utc):
errors.append(Error(f"MySQL {mysql_version.public} EOL", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A004"))
elif mysql_version.major == 8 and mysql_version.minor == 3:
errors.append(Warning(f"MySQL {mysql_version.public} Non LTS", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A005"))
elif mysql_version.major == 8 and mysql_version.minor == 2:
errors.append(Warning(f"MySQL {mysql_version.public} Non LTS", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A006"))
elif mysql_version.major == 8 and mysql_version.minor == 1:
errors.append(Error(f"MySQL {mysql_version.public} EOL", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A007"))
elif mysql_version.major == 8 and mysql_version.minor == 0 and timezone.now() > timezone.datetime(year=2026, month=4, day=30, tzinfo=timezone.utc):
errors.append(Error(f"MySQL {mysql_version.public} EOL", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A008"))
elif mysql_version.major < 8: # This will also catch Mariadb 5.x
errors.append(Error(f"MySQL or MariaDB {mysql_version.public} EOL", hint="https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/", id="allianceauth.checks.A009"))
return errors
@register()
def system_package_mariadb(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
for connection in db.connections.all():
if connection.vendor == "mysql": # Still to find a way to determine MySQL vs MariaDB
try:
mariadb_version = Pep440Version(".".join(str(i) for i in connection.mysql_version))
except InvalidVersion:
errors.append(Warning("Unable to confirm MariaDB Version"))
return errors
# MariaDB 11
if mariadb_version.major == 11 and mariadb_version.minor == 4 and timezone.now() > timezone.datetime(year=2029, month=5, day=19, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A010"))
elif mariadb_version.major == 11 and mariadb_version.minor == 2:
errors.append(Warning(f"MariaDB {mariadb_version.public} Non LTS", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A018"))
if timezone.now() > timezone.datetime(year=2024, month=11, day=21, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A011"))
elif mariadb_version.major == 11 and mariadb_version.minor == 1:
errors.append(Warning(f"MariaDB {mariadb_version.public} Non LTS", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A019"))
if timezone.now() > timezone.datetime(year=2024, month=8, day=21, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A012"))
elif mariadb_version.major == 11 and mariadb_version.minor in [0, 3]: # Demote versions down here once EOL
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config.", id="allianceauth.checks.A013"))
# MariaDB 10
elif mariadb_version.major == 10 and mariadb_version.minor == 11 and timezone.now() > timezone.datetime(year=2028, month=2, day=10, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config.", id="allianceauth.checks.A014"))
elif mariadb_version.major == 10 and mariadb_version.minor == 6 and timezone.now() > timezone.datetime(year=2026, month=7, day=6, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A0015"))
elif mariadb_version.major == 10 and mariadb_version.minor == 5 and timezone.now() > timezone.datetime(year=2025, month=6, day=24, tzinfo=timezone.utc):
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A016"))
elif mariadb_version.major == 10 and mariadb_version.minor in [0, 1, 2, 3, 4, 7, 9, 10]: # Demote versions down here once EOL
errors.append(Error(f"MariaDB {mariadb_version.public} EOL", hint="https://mariadb.org/download/?t=repo-config", id="allianceauth.checks.A017"))
return errors
@register()
def system_package_sqlite(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
for connection in db.connections.all():
if connection.vendor == "sqlite":
try:
sqlite_version = Pep440Version(".".join(str(i) for i in sqlite_version_info))
except InvalidVersion:
errors.append(Warning("Unable to confirm SQLite Version"))
return errors
if sqlite_version.major == 3 and sqlite_version.minor < 27:
errors.append(Error(f"SQLite {sqlite_version.public} Unsupported by Django", hint="https://pkgs.org/download/sqlite3", id="allianceauth.checks.A020"))
return errors
@register()
def sql_settings(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
for connection in db.connections.all():
if connection.vendor == "mysql":
try:
if connection.settings_dict["OPTIONS"]["charset"] != "utf8mb4":
errors.append(Error(f"SQL Charset is not set to utf8mb4 DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001"))
except KeyError:
errors.append(Error(f"SQL Charset is not set to utf8mb4 DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001"))
# This hasn't actually been set on AA yet
# try:
# if connection.settings_dict["OPTIONS"]["collation"] != "utf8mb4_unicode_ci":
# errors.append(Error(f"SQL Collation is not set to utf8mb4_unicode_ci DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001"))
# except KeyError:
# errors.append(Error(f"SQL Collation is not set to utf8mb4_unicode_ci DB:{connection.alias}", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/89be2456fb2d741b86417e889da9b6129525bec8", id="allianceauth.checks.B001"))
# if connection.vendor == "sqlite":
return errors
@register()
def celery_settings(app_configs, **kwargs) -> List[CheckMessage]:
errors: List[CheckMessage] = []
try:
if current_app.conf.broker_transport_options != {'priority_steps': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 'queue_order_strategy': 'priority'}:
errors.append(Error("Celery Priorities are not set correctly", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/8861ec0a61790eca0261f1adc1cc04ca5f243cbc", id="allianceauth.checks.B003"))
except KeyError:
errors.append(Error("Celery Priorities are not set", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/8861ec0a61790eca0261f1adc1cc04ca5f243cbc", id="allianceauth.checks.B003"))
try:
if current_app.conf.broker_connection_retry_on_startup != True:
errors.append(Error("Celery broker_connection_retry_on_startup not set correctly", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/380c41400b535447839e5552df2410af35a75280", id="allianceauth.checks.B004"))
except KeyError:
errors.append(Error("Celery broker_connection_retry_on_startup not set", hint="https://gitlab.com/allianceauth/allianceauth/-/commit/380c41400b535447839e5552df2410af35a75280", id="allianceauth.checks.B004"))
return errors
# IDEAS
# Any other celery things weve manually changed over the years
# I'd be happy to add Community App checks, old versions the owners dont want to support etc.
# Check Default Collation on DB
# Check Charset Collation on all tables

View File

@@ -31,7 +31,7 @@
<div class="card card-default mt-4">
<div class="card-header clearfix" role="tablist">
<ul class="nav nav-pills text-right float-start">
<ul class="nav nav-pills float-start">
<li class="nav-item" role="presentation">
<a
class="nav-link active"

View File

@@ -0,0 +1,3 @@
"""
Initializes the custom_css module.
"""

View File

@@ -0,0 +1,25 @@
"""
Admin classes for custom_css app
"""
# Django
from django.contrib import admin
# Django Solos
from solo.admin import SingletonModelAdmin
# Alliance Auth Custom CSS
from allianceauth.custom_css.models import CustomCSS
from allianceauth.custom_css.forms import CustomCSSAdminForm
@admin.register(CustomCSS)
class CustomCSSAdmin(SingletonModelAdmin):
"""
Custom CSS Admin
"""
form = CustomCSSAdminForm
# Leave this here for when we decide to add syntax highlighting to the CSS editor
# change_form_template = 'custom_css/admin/change_form.html'

View File

@@ -0,0 +1,13 @@
"""
Django app configuration for custom_css
"""
# Django
from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class CustomCSSConfig(AppConfig):
name = "allianceauth.custom_css"
label = "custom_css"
verbose_name = _("Custom CSS")

View File

@@ -0,0 +1,29 @@
"""
Forms for custom_css app
"""
# Alliance Auth Custom CSS
from allianceauth.custom_css.models import CustomCSS
from allianceauth.custom_css.widgets import CssEditorWidget
# Django
from django import forms
class CustomCSSAdminForm(forms.ModelForm):
"""
Form for editing custom CSS
"""
class Meta:
model = CustomCSS
fields = ("css",)
widgets = {
"css": CssEditorWidget(
attrs={
"style": "width: 90%; height: 100%;",
"data-editor": "code-highlight",
"data-language": "css",
}
)
}

View File

@@ -0,0 +1,42 @@
# Generated by Django 4.2.15 on 2024-08-14 11:25
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="CustomCSS",
fields=[
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"css",
models.TextField(
blank=True,
help_text="This CSS will be added to the site after the default CSS.",
null=True,
verbose_name="Your custom CSS",
),
),
("timestamp", models.DateTimeField(auto_now=True)),
],
options={
"verbose_name": "Custom CSS",
"verbose_name_plural": "Custom CSS",
"default_permissions": (),
},
),
]

View File

@@ -0,0 +1,143 @@
"""
Models for the custom_css app
"""
import os
import re
# Django Solo
from solo.models import SingletonModel
# Django
from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
class CustomCSS(SingletonModel):
"""
Model for storing custom CSS for the site
"""
css = models.TextField(
blank=True,
null=True,
verbose_name=_("Your custom CSS"),
help_text=_("This CSS will be added to the site after the default CSS."),
)
timestamp = models.DateTimeField(auto_now=True)
class Meta:
"""
Meta for CustomCSS
"""
default_permissions = ()
verbose_name = _("Custom CSS")
verbose_name_plural = _("Custom CSS")
def __str__(self) -> str:
"""
String representation of CustomCSS
:return:
:rtype:
"""
return str(_("Custom CSS"))
def save(self, *args, **kwargs):
"""
Save method for CustomCSS
:param args:
:type args:
:param kwargs:
:type kwargs:
:return:
:rtype:
"""
self.pk = 1
if self.css and len(self.css.replace(" ", "")) > 0:
# Write the custom CSS to a file
custom_css_file = open(
f"{settings.STATIC_ROOT}allianceauth/custom-styles.css", "w+"
)
custom_css_file.write(self.compress_css())
custom_css_file.close()
else:
# Remove the custom CSS file
try:
os.remove(f"{settings.STATIC_ROOT}allianceauth/custom-styles.css")
except FileNotFoundError:
pass
super().save(*args, **kwargs)
def compress_css(self) -> str:
"""
Compress CSS
:return:
:rtype:
"""
css = self.css
new_css = ""
# Remove comments
css = re.sub(pattern=r"\s*/\*\s*\*/", repl="$$HACK1$$", string=css)
css = re.sub(pattern=r"/\*[\s\S]*?\*/", repl="", string=css)
css = css.replace("$$HACK1$$", "/**/")
# url() doesn't need quotes
css = re.sub(pattern=r'url\((["\'])([^)]*)\1\)', repl=r"url(\2)", string=css)
# Spaces may be safely collapsed as generated content will collapse them anyway.
css = re.sub(pattern=r"\s+", repl=" ", string=css)
# Shorten collapsable colors: #aabbcc to #abc
css = re.sub(
pattern=r"#([0-9a-f])\1([0-9a-f])\2([0-9a-f])\3(\s|;)",
repl=r"#\1\2\3\4",
string=css,
)
# Fragment values can loose zeros
css = re.sub(
pattern=r":\s*0(\.\d+([cm]m|e[mx]|in|p[ctx]))\s*;", repl=r":\1;", string=css
)
for rule in re.findall(pattern=r"([^{]+){([^}]*)}", string=css):
# We don't need spaces around operators
selectors = [
re.sub(
pattern=r"(?<=[\[\(>+=])\s+|\s+(?=[=~^$*|>+\]\)])",
repl=r"",
string=selector.strip(),
)
for selector in rule[0].split(",")
]
# Order is important, but we still want to discard repetitions
properties = {}
porder = []
for prop in re.findall(pattern="(.*?):(.*?)(;|$)", string=rule[1]):
key = prop[0].strip().lower()
if key not in porder:
porder.append(key)
properties[key] = prop[1].strip()
# output rule if it contains any declarations
if properties:
new_css += "{}{{{}}}".format(
",".join(selectors),
"".join([f"{key}:{properties[key]};" for key in porder])[:-1],
)
return new_css

View File

@@ -0,0 +1,48 @@
{% extends "admin/change_form.html" %}
{% block field_sets %}
{% for fieldset in adminform %}
<fieldset class="module aligned {{ fieldset.classes }}">
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% if fieldset.description %}
<div class="description">{{ fieldset.description|safe }}</div>
{% endif %}
{% for line in fieldset %}
<div class="form-row{% if line.fields|length == 1 and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
{% if line.fields|length == 1 %}{{ line.errors }}{% else %}<div class="flex-container form-multiline">{% endif %}
{% for field in line %}
<div>
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
<div class="flex-container{% if not line.fields|length == 1 %} fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}{% elif field.is_checkbox %} checkbox-row{% endif %}">
{% if field.is_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% else %}
{{ field.label_tag }}
{% if field.is_readonly %}
<div class="readonly">{{ field.contents }}</div>
{% else %}
{{ field.field }}
{% endif %}
{% endif %}
</div>
{% if field.field.help_text %}
<div class="help"{% if field.field.id_for_label %} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
<div>{{ field.field.help_text|safe }}</div>
</div>
{% endif %}
</div>
{% endfor %}
{% if not line.fields|length == 1 %}</div>{% endif %}
</div>
{% endfor %}
</fieldset>
{% endfor %}
{% endblock %}
{% block after_field_sets %}{% endblock %}

View File

@@ -0,0 +1,3 @@
{% load custom_css %}
{% custom_css_static 'allianceauth/custom-styles.css' %}

View File

@@ -0,0 +1,3 @@
"""
Init file for custom_css templatetags
"""

View File

@@ -0,0 +1,48 @@
"""
Custom template tags for custom_css app
"""
# Alliance Auth Custom CSS
from allianceauth.custom_css.models import CustomCSS
# Django
from django.conf import settings
from django.template.defaulttags import register
from django.templatetags.static import static
from django.utils.safestring import mark_safe
from pathlib import Path
@register.simple_tag
def custom_css_static(path: str) -> str:
"""
Versioned static URL
This is to make sure to break the browser cache on CSS updates.
Example: /static/allianceauth/custom-styles.css?v=1234567890
:param path:
:type path:
:return:
:rtype:
"""
try:
Path(f"{settings.STATIC_ROOT}{path}").resolve(strict=True)
except FileNotFoundError:
return ""
else:
try:
custom_css = CustomCSS.objects.get(pk=1)
except CustomCSS.DoesNotExist:
return ""
else:
custom_css_changed = custom_css.timestamp.timestamp()
custom_css_version = (
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
) # remove spaces, colons, and dashes
static_url = static(path)
versioned_url = static_url + "?v=" + custom_css_version
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')

View File

@@ -0,0 +1,38 @@
"""
Form widgets for custom_css app
"""
# Django
from django import forms
# Alliance Auth
from allianceauth.custom_css.models import CustomCSS
class CssEditorWidget(forms.Textarea):
"""
Widget for editing CSS
"""
def __init__(self, attrs=None):
default_attrs = {"class": "custom-css-editor"}
if attrs:
default_attrs.update(attrs)
super().__init__(default_attrs)
# For when we want to add some sort of syntax highlight to it, which is not that
# easy to do on a textarea field though.
# `highlight.js` is just used as an example here, and doesn't work on a textarea field.
# class Media:
# css = {
# "all": (
# "/static/custom_css/libs/highlight.js/11.10.0/styles/github.min.css",
# )
# }
# js = (
# "/static/custom_css/libs/highlight.js/11.10.0/highlight.min.js",
# "/static/custom_css/libs/highlight.js/11.10.0/languages/css.min.js",
# "/static/custom_css/javascript/custom-css.min.js",
# )

View File

@@ -10,7 +10,7 @@ from . import (
)
_BASE_URL = 'http://evemaps.dotlan.net'
_BASE_URL = 'https://evemaps.dotlan.net'
def _build_url(category: str, name: str) -> str:

View File

@@ -31,29 +31,29 @@ class TestDotlan(TestCase):
def test_alliance_url(self):
self.assertEqual(
dotlan.alliance_url('Wayne Enterprices'),
'http://evemaps.dotlan.net/alliance/Wayne_Enterprices'
'https://evemaps.dotlan.net/alliance/Wayne_Enterprices'
)
def test_corporation_url(self):
self.assertEqual(
dotlan.corporation_url('Wayne Technology'),
'http://evemaps.dotlan.net/corp/Wayne_Technology'
'https://evemaps.dotlan.net/corp/Wayne_Technology'
)
self.assertEqual(
dotlan.corporation_url('Crédit Agricole'),
'http://evemaps.dotlan.net/corp/Cr%C3%A9dit_Agricole'
'https://evemaps.dotlan.net/corp/Cr%C3%A9dit_Agricole'
)
def test_region_url(self):
self.assertEqual(
dotlan.region_url('Black Rise'),
'http://evemaps.dotlan.net/map/Black_Rise'
'https://evemaps.dotlan.net/map/Black_Rise'
)
def test_solar_system_url(self):
self.assertEqual(
dotlan.solar_system_url('Jita'),
'http://evemaps.dotlan.net/system/Jita'
'https://evemaps.dotlan.net/system/Jita'
)

View File

@@ -0,0 +1,57 @@
"""
Alliance Auth Evecharacter API
"""
from typing import Optional
from django.contrib.auth.models import User
from allianceauth.authentication.models import CharacterOwnership
from allianceauth.eveonline.models import EveCharacter
from allianceauth.framework.api.user import get_sentinel_user
def get_main_character_from_evecharacter(
character: EveCharacter,
) -> Optional[EveCharacter]:
"""
Get the main character for a given EveCharacter or None when no main character is set
:param character:
:type character:
:return:
:rtype:
"""
try:
userprofile = character.character_ownership.user.profile
except (
AttributeError,
EveCharacter.character_ownership.RelatedObjectDoesNotExist,
CharacterOwnership.user.RelatedObjectDoesNotExist,
):
return None
return userprofile.main_character
def get_user_from_evecharacter(character: EveCharacter) -> User:
"""
Get the user for an EveCharacter or the sentinel user when no user is found
:param character:
:type character:
:return:
:rtype:
"""
try:
userprofile = character.character_ownership.user.profile
except (
AttributeError,
EveCharacter.character_ownership.RelatedObjectDoesNotExist,
CharacterOwnership.user.RelatedObjectDoesNotExist,
):
return get_sentinel_user()
return userprofile.user

View File

@@ -6,17 +6,33 @@ from typing import Optional
from django.contrib.auth.models import User
from allianceauth.authentication.models import CharacterOwnership
from allianceauth.eveonline.models import EveCharacter
def get_sentinel_user() -> User:
def get_all_characters_from_user(user: User) -> list:
"""
Get the sentinel user or create one
Get all characters from a user or an empty list
when no characters are found for the user or the user is None
:param user:
:type user:
:return:
:rtype:
"""
return User.objects.get_or_create(username="deleted")[0]
if user is None:
return []
try:
characters = [
char.character for char in CharacterOwnership.objects.filter(user=user)
]
except AttributeError:
return []
return characters
def get_main_character_from_user(user: User) -> Optional[EveCharacter]:
"""
@@ -62,3 +78,13 @@ def get_main_character_name_from_user(user: User) -> str:
return str(user)
return username
def get_sentinel_user() -> User:
"""
Get the sentinel user or create one
:return:
"""
return User.objects.get_or_create(username="deleted")[0]

View File

@@ -13,6 +13,45 @@
}
}
/* Side Navigation
------------------------------------------------------------------------------------- */
@media all {
#sidebar > div {
width: 325px;
}
/* Menu items in general */
#sidebar-menu li > a,
#sidebar-menu li > ul > li > a {
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
max-width: 210px;
}
/* Parent items with chevron and possible badge */
#sidebar-menu li:has(span.badge) > a[data-bs-toggle="collapse"] {
max-width: 180px;
}
/* Child items with possible badge */
#sidebar-menu li > ul > li > a {
max-width: 189px;
}
/* Chevron icons */
#sidebar-menu [data-bs-toggle="collapse"] > i.fa-chevron-down,
#sidebar-menu [data-bs-toggle="collapse"].collapsed > i.fa-chevron-right {
display: block;
width: 16px;
}
#sidebar-menu [data-bs-toggle="collapse"] > i.fa-chevron-right,
#sidebar-menu [data-bs-toggle="collapse"].collapsed > i.fa-chevron-down {
display: none;
}
}
/* Cursor classes
------------------------------------------------------------------------------------- */
@media all {
@@ -72,9 +111,16 @@
border: 1px solid var(--bs-border-color);
border-left-width: 0.25rem;
border-radius: 0.25rem;
margin-bottom: 1.25rem;
margin-top: 1.25rem;
padding: 1.25rem;
margin-bottom: 1rem;
padding: 1rem;
}
.aa-callout.aa-callout-sm {
padding: 0.5rem;
}
.aa-callout.aa-callout-lg {
padding: 1.5rem;
}
/* Last item bottom margin should be 0 */

View File

@@ -0,0 +1,8 @@
{#Usage:#}
{# {% include "framework/dashboard/widget-title.html" with title="Foobar" %}#}
<div class="text-center">
<h4 class="ms-auto me-auto mb-3">
{{ title }}
</h4>
</div>

View File

@@ -7,7 +7,7 @@
{% if subtitle %}
<br>
<small>{{ subtitle }}</small>
<small class="text-muted">{{ subtitle }}</small>
{% endif %}
</h1>
{% endif %}

View File

@@ -49,7 +49,7 @@ class GroupsMenuItem(MenuItemHook):
MenuItemHook.__init__(
self,
text=_("Groups"),
classes="fa-solid fa-user",
classes="fa-solid fa-users",
url_name="groupmanagement:groups",
order=25,
navactive=[

View File

@@ -71,7 +71,7 @@
{% block extra_javascript %}
{% include 'bundles/datatables-js-bs5.html' %}
{% include 'bundles/moment-js.html' with locale=True %}
{# {% include 'bundles/filterdropdown-js.html' %}#}
{% include 'bundles/filterdropdown-js.html' %}
<script>
$.fn.dataTable.moment = (format, locale) => {
@@ -117,7 +117,8 @@
idx: 6
}
],
bootstrap: true
bootstrap: true,
bootstrap_version: 5
},
"stateSave": true,
"stateDuration": 0

View File

@@ -30,7 +30,11 @@
<tr>
<th>{% translate "Name" %}</th>
<th>{% translate "Description" %}</th>
<th>{% translate "Leaders" %}<span class="m-1 fw-lighter badge bg-primary">{% translate "User" %}</span><span class="m-1 fw-lighter badge bg-secondary ">{% translate "Group" %}</span></th>
<th>
{% translate "Leaders" %}<br>
<span class="my-1 me-1 fw-lighter badge bg-primary">{% translate "User" %}</span>
<span class="my-1 me-1 fw-lighter badge bg-secondary">{% translate "Group" %}</span>
</th>
<th></th>
</tr>
</thead>
@@ -39,13 +43,23 @@
{% for g in groups %}
<tr>
<td>{{ g.group.name }}</td>
<td>{{ g.group.authgroup.description|linebreaks|urlize }}</td>
<td>
{% if g.group.authgroup.description %}
{{ g.group.authgroup.description|linebreaks|urlize }}
{% endif %}
</td>
<td style="max-width: 30%;">
{% if g.group.authgroup.group_leaders.all.count %}
{% for leader in g.group.authgroup.group_leaders.all %}{% if leader.profile.main_character %}<span class="m-1 badge bg-primary">{{leader.profile.main_character}}</span>{% endif %}{% endfor %}
{% for leader in g.group.authgroup.group_leaders.all %}
{% if leader.profile.main_character %}
<span class="my-1 me-1 badge bg-primary">{{leader.profile.main_character}}</span>
{% endif %}
{% endfor %}
{% endif %}
{% if g.group.authgroup.group_leaders.all.count %}
{% for group in g.group.authgroup.group_leader_groups.all %}<span class="badge bg-secondary">{{group.name}}</span>{% endfor %}
{% for group in g.group.authgroup.group_leader_groups.all %}
<span class="my-1 me-1 badge bg-secondary">{{group.name}}</span>
{% endfor %}
{% endif %}
</td>
<td class="text-end">

View File

@@ -92,6 +92,9 @@
<a href="{% url 'groupmanagement:accept_request' acceptrequest.id %}" class="btn btn-success">
{% translate "Accept" %}
</a>
<a href="{% url 'groupmanagement:reject_request' acceptrequest.id %}" class="btn btn-danger">
{% translate "Reject" %}
</a>
</td>
</tr>
{% endfor %}

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,111 @@
"""Admin site for menu app."""
from typing import Optional
from django.contrib import admin
from django.http import HttpRequest, HttpResponse
from django.shortcuts import get_object_or_404
from django.utils.translation import gettext_noop as _
from . import models
from .constants import MenuItemType
from .core.smart_sync import sync_menu
from .filters import MenuItemTypeListFilter
from .forms import (
AppMenuItemAdminForm,
FolderMenuItemAdminForm,
LinkMenuItemAdminForm,
)
from .models import MenuItem
@admin.register(models.MenuItem)
@admin.register(MenuItem)
class MenuItemAdmin(admin.ModelAdmin):
list_display = ['text', 'hide', 'parent', 'url', 'icon_classes', 'rank']
ordering = ('rank',)
list_display = (
"_text",
"parent",
"order",
"_user_defined",
"_visible",
"_children",
)
list_filter = [
MenuItemTypeListFilter,
"is_hidden",
("parent", admin.RelatedOnlyFieldListFilter),
]
ordering = ["parent", "order", "text"]
def get_form(self, request: HttpRequest, obj: Optional[MenuItem] = None, **kwargs):
kwargs["form"] = self._choose_form(request, obj)
return super().get_form(request, obj, **kwargs)
@classmethod
def _choose_form(cls, request: HttpRequest, obj: Optional[MenuItem]):
"""Return the form for the current menu item type."""
if obj: # change
if obj.hook_hash:
return AppMenuItemAdminForm
if obj.is_folder:
return FolderMenuItemAdminForm
return LinkMenuItemAdminForm
# add
if cls._type_from_request(request) is MenuItemType.FOLDER:
return FolderMenuItemAdminForm
return LinkMenuItemAdminForm
def add_view(self, request, form_url="", extra_context=None) -> HttpResponse:
context = extra_context or {}
item_type = self._type_from_request(request, default=MenuItemType.LINK)
context["title"] = _("Add %s menu item") % item_type.label
return super().add_view(request, form_url, context)
def change_view(
self, request, object_id, form_url="", extra_context=None
) -> HttpResponse:
extra_context = extra_context or {}
obj = get_object_or_404(MenuItem, id=object_id)
extra_context["title"] = _("Change %s menu item") % obj.item_type.label
return super().change_view(request, object_id, form_url, extra_context)
def changelist_view(self, request: HttpRequest, extra_context=None):
# needed to ensure items are updated after an app change
# and when the admin page is opened directly
sync_menu()
extra_context = extra_context or {}
extra_context["folder_type"] = MenuItemType.FOLDER.value
return super().changelist_view(request, extra_context)
@admin.display(description=_("children"))
def _children(self, obj: MenuItem):
if not obj.is_folder:
return []
names = [obj.text for obj in obj.children.order_by("order", "text")]
return names if names else "?"
@admin.display(description=_("text"), ordering="text")
def _text(self, obj: MenuItem) -> str:
if obj.is_folder:
return f"[{obj.text}]"
return obj.text
@admin.display(description=_("user defined"), boolean=True)
def _user_defined(self, obj: MenuItem) -> bool:
return obj.is_user_defined
@admin.display(description=_("visible"), ordering="is_hidden", boolean=True)
def _visible(self, obj: MenuItem) -> bool:
return not bool(obj.is_hidden)
@staticmethod
def _type_from_request(
request: HttpRequest, default=None
) -> Optional[MenuItemType]:
try:
return MenuItemType(request.GET.get("type"))
except ValueError:
return default

View File

@@ -1,19 +1,19 @@
import logging
from django.apps import AppConfig
from django.db.utils import ProgrammingError, OperationalError
logger = logging.getLogger(__name__)
# TODO discuss permissions for user defined links
# TODO define aa way for hooks to predefine a "parent" to create a sub menu from modules
# TODO Add user documentation
class MenuConfig(AppConfig):
name = "allianceauth.menu"
label = "menu"
def ready(self):
try:
from allianceauth.menu.providers import menu_provider
menu_provider.clear_synced_flag()
except (ProgrammingError, OperationalError):
logger.warning("Migrations not completed for MenuItems")
from allianceauth.menu.core import smart_sync
smart_sync.reset_menu_items_sync()

View File

@@ -0,0 +1,18 @@
"""Global constants for the menu app."""
from django.db import models
from django.utils.translation import gettext_lazy as _
DEFAULT_FOLDER_ICON_CLASSES = "fa-solid fa-folder" # TODO: Make this a setting?
"""Default icon class for folders."""
DEFAULT_MENU_ITEM_ORDER = 9999
"""Default order for any menu item."""
class MenuItemType(models.TextChoices):
"""The type of a menu item."""
APP = "app", _("app")
FOLDER = "folder", _("folder")
LINK = "link", _("link")

View File

View File

@@ -0,0 +1,48 @@
"""Logic for handling MenuItemHook objects."""
import hashlib
from typing import List, NamedTuple, Optional
from allianceauth.menu.hooks import MenuItemHook
class MenuItemHookCustom(MenuItemHook):
"""A user defined menu item that can be rendered with the standard template."""
def __init__(
self,
text: str,
classes: str,
url_name: str,
order: Optional[int] = None,
navactive: Optional[List[str]] = None,
):
super().__init__(text, classes, url_name, order, navactive)
self.url = ""
self.is_folder = None
self.html_id = ""
self.children = []
class MenuItemHookParams(NamedTuple):
"""Immutable container for params about a menu item hook."""
text: str
order: int
hash: str
def generate_hash(obj: MenuItemHook) -> str:
"""Return the hash for a menu item hook."""
my_class = obj.__class__
name = f"{my_class.__module__}.{my_class.__name__}"
hash_value = hashlib.sha256(name.encode("utf-8")).hexdigest()
return hash_value
def gather_params(obj: MenuItemHook) -> MenuItemHookParams:
"""Return params from a menu item hook."""
text = getattr(obj, "text", obj.__class__.__name__)
order = getattr(obj, "order", None)
hash = generate_hash(obj)
return MenuItemHookParams(text=text, hash=hash, order=order)

View File

@@ -0,0 +1,30 @@
"""Provide capability to sync menu items when needed only."""
from django.core.cache import cache
_MENU_SYNC_CACHE_KEY = "ALLIANCEAUTH-MENU-SYNCED"
def sync_menu() -> None:
"""Sync menu items if needed only."""
from allianceauth.menu.models import MenuItem
is_sync_needed = not _is_menu_synced() or not MenuItem.objects.exists()
# need to also check for existence of MenuItems in database
# to ensure the menu is synced during tests
if is_sync_needed:
MenuItem.objects.sync_all()
_record_menu_was_synced()
def _is_menu_synced() -> bool:
return cache.get(_MENU_SYNC_CACHE_KEY, False)
def _record_menu_was_synced() -> None:
cache.set(_MENU_SYNC_CACHE_KEY, True, timeout=None) # no timeout
def reset_menu_items_sync() -> None:
"""Ensure menu items are synced, e.g. after a Django restart."""
cache.delete(_MENU_SYNC_CACHE_KEY)

View File

@@ -0,0 +1,24 @@
"""Filters for the menu app."""
from django.contrib import admin
from django.utils.translation import gettext_noop as _
from allianceauth.menu.constants import MenuItemType
class MenuItemTypeListFilter(admin.SimpleListFilter):
"""Allow filtering admin changelist by menu item type."""
title = _("type")
parameter_name = "type"
def lookups(self, request, model_admin):
return [(obj.value, obj.label.title()) for obj in MenuItemType]
def queryset(self, request, queryset):
if value := self.value():
return queryset.annotate_item_type_2().filter(
item_type_2=MenuItemType(value).value
)
return None

View File

@@ -0,0 +1,49 @@
from django import forms
from .constants import DEFAULT_FOLDER_ICON_CLASSES
from .models import MenuItem
class FolderMenuItemAdminForm(forms.ModelForm):
"""A form for changing folder items."""
class Meta:
model = MenuItem
fields = ["text", "classes", "order", "is_hidden"]
def clean(self):
data = super().clean()
if not data["classes"]:
data["classes"] = DEFAULT_FOLDER_ICON_CLASSES
return data
class _BasedMenuItemAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["parent"].queryset = MenuItem.objects.filter_folders().order_by(
"text"
)
self.fields["parent"].required = False
self.fields["parent"].widget = forms.Select(
choices=self.fields["parent"].widget.choices
) # disable modify buttons
class AppMenuItemAdminForm(_BasedMenuItemAdminForm):
"""A form for changing app items."""
class Meta:
model = MenuItem
fields = ["order", "parent", "is_hidden"]
class LinkMenuItemAdminForm(_BasedMenuItemAdminForm):
"""A form for changing link items."""
class Meta:
model = MenuItem
fields = ["text", "url", "classes", "order", "parent", "is_hidden"]
widgets = {
"url": forms.TextInput(attrs={"size": "100"}),
}

View File

@@ -1,42 +1,58 @@
from django.template.loader import render_to_string
"""Menu item hooks."""
from typing import List, Optional
from django.template.loader import render_to_string
from allianceauth.menu.constants import DEFAULT_MENU_ITEM_ORDER
class MenuItemHook:
"""
Auth Hook for generating Side Menu Items
"""
def __init__(self, text: str, classes: str, url_name: str, order: Optional[int] = None, navactive: List = []):
"""
:param text: The text shown as menu item, e.g. usually the name of the app.
:type text: str
:param classes: The classes that should be applied to the menu item icon
:type classes: List[str]
:param url_name: The name of the Django URL to use
:type url_name: str
:param order: An integer which specifies the order of the menu item, lowest to highest. Community apps are free to use any order above `1000`. Numbers below are served for Auth.
:type order: Optional[int], optional
:param navactive: A list of views or namespaces the link should be highlighted on. See [django-navhelper](https://github.com/geelweb/django-navhelper#navactive) for usage. Defaults to the supplied `url_name`.
:type navactive: List, optional
"""
"""Auth Hook for generating side menu items.
Args:
- text: The text shown as menu item, e.g. usually the name of the app.
- classes: The classes that should be applied to the menu item icon
- url_name: The name of the Django URL to use
- order: An integer which specifies the order of the menu item,
lowest to highest. Community apps are free to use any order above `1000`.
Numbers below are served for Auth.
- A list of views or namespaces the link should be highlighted on.
See 3rd party package django-navhelper for usage.
Defaults to the supplied `url_name`.
Optional:
- count is an integer shown next to the menu item as badge when is is not `None`.
Apps need to set the count in their child class, e.g. in `render()` method
"""
def __init__(
self,
text: str,
classes: str,
url_name: str,
order: Optional[int] = None,
navactive: Optional[List[str]] = None,
):
self.text = text
self.classes = classes
self.url_name = url_name
self.template = 'public/menuitem.html'
self.order = order if order is not None else 9999
# count is an integer shown next to the menu item as badge when count != None
# apps need to set the count in their child class, e.g. in render() method
self.template = "public/menuitem.html"
self.order = order if order is not None else DEFAULT_MENU_ITEM_ORDER
self.count = None
navactive = navactive or []
navactive.append(url_name)
self.navactive = navactive
def render(self, request):
return render_to_string(self.template,
{'item': self},
request=request)
def __str__(self) -> str:
return self.text
def __repr__(self) -> str:
return f'{self.__class__.__name__}(text="{self.text}")'
def render(self, request) -> str:
"""Render this menu item and return resulting HTML."""
return render_to_string(self.template, {"item": self}, request=request)

View File

@@ -0,0 +1,67 @@
from __future__ import annotations
import logging
from typing import TYPE_CHECKING
from django.db import models
from django.db.models import Case, Q, Value, When
from allianceauth.hooks import get_hooks
from .constants import MenuItemType
from .core.menu_item_hooks import MenuItemHookParams, gather_params
if TYPE_CHECKING:
from .models import MenuItem
logger = logging.getLogger(__name__)
class MenuItemQuerySet(models.QuerySet):
def filter_folders(self):
"""Add filter to include folders only."""
return self.filter(hook_hash__isnull=True, url="")
def annotate_item_type_2(self):
"""Add calculated field with item type."""
return self.annotate(
item_type_2=Case(
When(~Q(hook_hash__isnull=True), then=Value(MenuItemType.APP.value)),
When(url="", then=Value(MenuItemType.FOLDER.value)),
default=Value(MenuItemType.LINK.value),
)
)
class MenuItemManagerBase(models.Manager):
def sync_all(self):
"""Sync all menu items from hooks."""
hook_params = self._gather_menu_item_hook_params()
self._delete_obsolete_app_items(hook_params)
self._update_or_create_app_items(hook_params)
def _gather_menu_item_hook_params(self) -> list[MenuItemHookParams]:
params = [gather_params(hook()) for hook in get_hooks("menu_item_hook")]
return params
def _delete_obsolete_app_items(self, params: list[MenuItemHookParams]):
hashes = [obj.hash for obj in params]
self.exclude(hook_hash__isnull=True).exclude(hook_hash__in=hashes).delete()
def _update_or_create_app_items(self, params: list[MenuItemHookParams]):
for param in params:
try:
obj: MenuItem = self.get(hook_hash=param.hash)
except self.model.DoesNotExist:
self.create(hook_hash=param.hash, order=param.order, text=param.text)
else:
# if it exists update the text only
if obj.text != param.text:
obj.text = param.text
obj.save()
logger.debug("Updated menu items from %d menu item hooks", len(params))
MenuItemManager = MenuItemManagerBase.from_queryset(MenuItemQuerySet)

View File

@@ -1,15 +0,0 @@
from django.utils.deprecation import MiddlewareMixin
import logging
from allianceauth.menu.providers import menu_provider
logger = logging.getLogger(__name__)
class MenuSyncMiddleware(MiddlewareMixin):
def __call__(self, request):
"""Alliance Auth Menu Sync Middleware"""
menu_provider.check_and_sync_menu()
return super().__call__(request)

View File

@@ -1,4 +1,4 @@
# Generated by Django 4.0.2 on 2022-08-28 14:00
# Generated by Django 4.2.9 on 2024-02-15 00:01
from django.db import migrations, models
import django.db.models.deletion
@@ -8,21 +8,88 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
]
dependencies = []
operations = [
migrations.CreateModel(
name='MenuItem',
name="MenuItem",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('hook_function', models.CharField(max_length=500)),
('icon_classes', models.CharField(max_length=150)),
('text', models.CharField(max_length=150)),
('url', models.CharField(blank=True, default=None, max_length=2048, null=True)),
('rank', models.IntegerField(default=1000)),
('hide', models.BooleanField(default=False)),
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='menu.menuitem')),
(
"id",
models.AutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"text",
models.CharField(
db_index=True,
help_text="Text to show on menu",
max_length=150,
verbose_name="text",
),
),
(
"order",
models.IntegerField(
db_index=True,
default=9999,
help_text="Order of the menu. Lowest First",
verbose_name="order",
),
),
(
"is_hidden",
models.BooleanField(
default=False,
help_text="Hide this menu item.If this item is a folder all items under it will be hidden too",
verbose_name="is hidden",
),
),
(
"hook_hash",
models.CharField(
default=None,
editable=False,
max_length=64,
null=True,
unique=True,
),
),
(
"classes",
models.CharField(
blank=True,
default="",
help_text="Font Awesome classes to show as icon on menu, e.g. <code>fa-solid fa-house</code>",
max_length=150,
verbose_name="icon classes",
),
),
(
"url",
models.TextField(
default="",
help_text="External URL this menu items will link to",
verbose_name="url",
),
),
(
"parent",
models.ForeignKey(
blank=True,
default=None,
help_text="Folder this item is in (optional)",
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="children",
to="menu.menuitem",
verbose_name="folder",
),
),
],
),
]

View File

@@ -1,28 +0,0 @@
# Generated by Django 4.0.2 on 2022-08-28 14:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('menu', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='menuitem',
name='hook_function',
field=models.CharField(blank=True, default=None, max_length=500, null=True),
),
migrations.AlterField(
model_name='menuitem',
name='icon_classes',
field=models.CharField(blank=True, default=None, max_length=150, null=True),
),
migrations.AlterField(
model_name='menuitem',
name='text',
field=models.CharField(blank=True, default=None, max_length=150, null=True),
),
]

View File

@@ -1,17 +0,0 @@
# Generated by Django 4.0.8 on 2023-02-05 07:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('menu', '0002_alter_menuitem_hook_function_and_more'),
]
operations = [
migrations.AddIndex(
model_name='menuitem',
index=models.Index(fields=['rank'], name='menu_menuit_rank_e880ab_idx'),
),
]

View File

@@ -1,39 +0,0 @@
# Generated by Django 4.0.10 on 2023-07-16 11:41
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('menu', '0003_menuitem_menu_menuit_rank_e880ab_idx'),
]
operations = [
migrations.AlterField(
model_name='menuitem',
name='hide',
field=models.BooleanField(default=False, help_text='Hide this menu item. If this item is a header all items under it will be hidden too.'),
),
migrations.AlterField(
model_name='menuitem',
name='icon_classes',
field=models.CharField(blank=True, default=None, help_text='Font Awesome classes to show as icon on menu', max_length=150, null=True),
),
migrations.AlterField(
model_name='menuitem',
name='parent',
field=models.ForeignKey(blank=True, help_text='Parent Header. (Optional)', null=True, on_delete=django.db.models.deletion.SET_NULL, to='menu.menuitem'),
),
migrations.AlterField(
model_name='menuitem',
name='rank',
field=models.IntegerField(default=1000, help_text='Order of the menu. Lowest First.'),
),
migrations.AlterField(
model_name='menuitem',
name='text',
field=models.CharField(blank=True, default=None, help_text='Text to show on menu', max_length=150, null=True),
),
]

View File

@@ -1,174 +1,132 @@
import logging
from allianceauth.hooks import get_hooks
from django.db import models
from django.utils.translation import gettext_lazy as _
from django.template.loader import render_to_string
logger = logging.getLogger(__name__)
from allianceauth.menu.constants import DEFAULT_FOLDER_ICON_CLASSES
from .constants import DEFAULT_MENU_ITEM_ORDER, MenuItemType
from .core.menu_item_hooks import MenuItemHookCustom
from .managers import MenuItemManager
class MenuItem(models.Model):
# Auto Generated model from an auth_hook
hook_function = models.CharField(
max_length=500, default=None, null=True, blank=True)
"""An item in the sidebar menu.
Some of these objects are generated from `MenuItemHook` objects.
To avoid confusion we are using the same same field names.user defined
"""
# User Made Model
icon_classes = models.CharField(
max_length=150, default=None, null=True, blank=True, help_text="Font Awesome classes to show as icon on menu")
text = models.CharField(
max_length=150, default=None, null=True, blank=True, help_text="Text to show on menu")
url = models.CharField(max_length=2048, default=None,
null=True, blank=True)
# Put it under a header?
max_length=150,
db_index=True,
verbose_name=_("text"),
help_text=_("Text to show on menu"),
)
order = models.IntegerField(
default=DEFAULT_MENU_ITEM_ORDER,
db_index=True,
verbose_name=_("order"),
help_text=_("Order of the menu. Lowest First"),
)
parent = models.ForeignKey(
'self', on_delete=models.SET_NULL, null=True, blank=True, help_text="Parent Header. (Optional)")
"self",
on_delete=models.SET_NULL,
default=None,
null=True,
blank=True,
related_name="children",
verbose_name=_("folder"),
help_text=_("Folder this item is in (optional)"),
)
is_hidden = models.BooleanField(
default=False,
verbose_name=_("is hidden"),
help_text=_(
"Hide this menu item."
"If this item is a folder all items under it will be hidden too"
),
)
# Put it where? lowest first
rank = models.IntegerField(default=1000, help_text="Order of the menu. Lowest First.")
# app related properties
hook_hash = models.CharField(
max_length=64, default=None, null=True, unique=True, editable=False
) # hash of a menu item hook. Must be nullable for unique comparison.
# Hide it fully? Hiding a parent will hide all it's children
hide = models.BooleanField(default=False, help_text="Hide this menu item. If this item is a header all items under it will be hidden too.")
# user defined properties
classes = models.CharField(
max_length=150,
default="",
blank=True,
verbose_name=_("icon classes"),
help_text=_(
"Font Awesome classes to show as icon on menu, "
"e.g. <code>fa-solid fa-house</code>"
),
)
url = models.TextField(
default="",
verbose_name=_("url"),
help_text=_("External URL this menu items will link to"),
)
class Meta:
indexes = [
models.Index(fields=['rank', ]),
]
objects = MenuItemManager()
def __str__(self) -> str:
return self.text
def save(self, *args, **kwargs):
if not self.hook_hash:
self.hook_hash = None # empty strings can create problems
return super().save(*args, **kwargs)
@property
def classes(self): # Helper function to make this model closer to the hook functions
return self.icon_classes
def item_type(self) -> MenuItemType:
"""Return the type of this menu item."""
if self.hook_hash:
return MenuItemType.APP
@staticmethod
def hook_to_name(mh):
return f"{mh.__class__.__module__}.{mh.__class__.__name__}"
if not self.url:
return MenuItemType.FOLDER
@staticmethod
def sync_hook_models():
# TODO define aa way for hooks to predefine a "parent" to create a sub menu from modules
menu_hooks = get_hooks('menu_item_hook')
hook_functions = []
for hook in menu_hooks:
mh = hook()
cls = MenuItem.hook_to_name(mh)
try:
# if it exists update the text only
# Users can adjust ranks so lets not change it if they have.
mi = MenuItem.objects.get(hook_function=cls)
mi.text = getattr(mh, "text", mh.__class__.__name__)
mi.save()
except MenuItem.DoesNotExist:
# This is a new hook, Make the database model.
MenuItem.objects.create(
hook_function=cls,
rank=getattr(mh, "order", 500),
text=getattr(mh, "text", mh.__class__.__name__)
)
hook_functions.append(cls)
return MenuItemType.LINK
# Get rid of any legacy hooks from modules removed
MenuItem.objects.filter(hook_function__isnull=False).exclude(
hook_function__in=hook_functions).delete()
@property
def is_app_item(self) -> bool:
"""Return True if this is an app item, else False."""
return self.item_type is MenuItemType.APP
@classmethod
def filter_items(cls, menu_item: dict):
"""
filter any items with no valid children from a menu
"""
count_items = len(menu_item['items'])
if count_items: # if we have children confirm we can see them
for i in menu_item['items']:
if len(i['render']) == 0:
count_items -= 1
if count_items == 0: # no children left dont render header
return False
return True
else:
return True
@property
def is_child(self) -> bool:
"""Return True if this item is a child, else False."""
return bool(self.parent_id)
@classmethod
def render_menu(cls, request):
"""
Return the sorted side menu items with any items the user can't see removed.
"""
# Override all the items to the bs5 theme
template = "menu/menu-item-bs5.html"
# TODO discuss permissions for user defined links
@property
def is_folder(self) -> bool:
"""Return True if this item is a folder, else False."""
return self.item_type is MenuItemType.FOLDER
# Turn all the hooks into functions
menu_hooks = get_hooks('menu_item_hook')
items = {}
for fn in menu_hooks:
f = fn()
items[cls.hook_to_name(f)] = f
@property
def is_link_item(self) -> bool:
"""Return True if this item is a link item, else False."""
return self.item_type is MenuItemType.LINK
menu_items = MenuItem.objects.all().order_by("rank")
@property
def is_user_defined(self) -> bool:
"""Return True if this item is user defined."""
return self.item_type is not MenuItemType.APP
menu = {}
for mi in menu_items:
if mi.hide:
# hidden item, skip it completely
continue
try:
_cnt = 0
_render = None
if mi.hook_function:
# This is a module hook, so we need to render it as the developer intended
# TODO add a new attribute for apps that want to override it in the new theme
items[mi.hook_function].template = template
_render = items[mi.hook_function].render(request)
_cnt = items[mi.hook_function].count
else:
# This is a user defined menu item so we render it with defaults.
_render = render_to_string(template,
{'item': mi},
request=request)
def to_hook_obj(self) -> MenuItemHookCustom:
"""Convert to hook object for rendering."""
if self.is_app_item:
raise ValueError("The related hook objects should be used for app items.")
parent = mi.id
if mi.parent_id: # Set it if present
parent = mi.parent_id
hook_obj = MenuItemHookCustom(
text=self.text, classes=self.classes, url_name="", order=self.order
)
hook_obj.navactive = []
if self.is_folder and not self.classes:
hook_obj.classes = DEFAULT_FOLDER_ICON_CLASSES
if parent not in menu: # this will cause the menu headers to be out of order
menu[parent] = {"items": [],
"count": 0,
"render": None,
"text": "None",
"rank": 9999,
}
_mi = {
"count": _cnt,
"render": _render,
"text": mi.text,
"rank": mi.rank,
"classes": (mi.icon_classes if mi.icon_classes != "" else "fa-solid fa-folder"),
"hide": mi.hide
}
if parent != mi.id:
# this is a sub item
menu[parent]["items"].append(_mi)
if _cnt:
#add its count to the header count
menu[parent]["count"] += _cnt
else:
if len(menu[parent]["items"]):
# this is a top folder dont update the count.
del(_mi["count"])
menu[parent].update(_mi)
except Exception as e:
logger.exception(e)
# reset to list
menu = list(menu.values())
# sort the menu list as the parents may be out of order.
menu.sort(key=lambda i: i['rank'])
# ensure no empty groups
menu = filter(cls.filter_items, menu)
return menu
hook_obj.url = self.url
hook_obj.is_folder = self.is_folder
hook_obj.html_id = f"id-folder-{self.id}" if self.is_folder else ""
return hook_obj

View File

@@ -1,49 +0,0 @@
import logging
from django.core.cache import cache
from allianceauth.menu.models import MenuItem
from allianceauth.utils.django import StartupCommand
logger = logging.getLogger(__name__)
MENU_SYNC_CACHE_KEY = "ALLIANCEAUTH-MENU-SYNCED"
MENU_CACHE_KEY = "ALLIANCEAUTH-MENU-CACHE"
class MenuProvider():
def clear_synced_flag(self) -> bool:
return cache.delete(MENU_SYNC_CACHE_KEY)
def set_synced_flag(self) -> bool:
return cache.set(MENU_SYNC_CACHE_KEY, True)
def get_synced_flag(self) -> bool:
return cache.get(MENU_SYNC_CACHE_KEY, False)
def sync_menu_models(self):
MenuItem.sync_hook_models()
self.set_synced_flag()
def check_and_sync_menu(self) -> None:
if self.get_synced_flag():
# performance hit to each page view to ensure tests work.
# tests clear DB but not cache.
# TODO rethink all of this?
if MenuItem.objects.all().count() > 0:
logger.debug("Menu Hooks Synced")
else:
self.sync_menu_models()
else:
logger.debug("Syncing Menu Hooks")
self.sync_menu_models()
def get_and_cache_menu(self):
pass
def clear_menu_cache(self):
pass
menu_provider = MenuProvider()

View File

@@ -0,0 +1,13 @@
{% extends "admin/change_list.html" %}
{% load i18n %}
{% block object-tools-items %}
{{ block.super }}
<li>
<a href="{% url 'admin:menu_menuitem_add' %}?type={{ folder_type }}" class="addlink">
{% translate "Add folder" %}
</a>
</li>
{% endblock %}

View File

@@ -1,7 +1,3 @@
{% for data in menu_items %}
{% if data.items|length > 0 %}
{% include "menu/menu-item-bs5.html" with item=data %}
{% else %}
{{ data.render }}
{% endif %}
{% for item in menu_items %}
{{ item.html }}
{% endfor %}

View File

@@ -1,37 +1,57 @@
{% load i18n %}
{% load navactive %}
{% if not item.hide %}
<li class="d-flex flex-wrap m-2 p-2 pt-0 pb-0 mt-0 mb-0 me-0 pe-0">
<i class="nav-link {{ item.classes }} fa-fw align-self-center me-3 {% if item.navactive %}{% navactive request item.navactive|join:' ' %}{% endif %}" {% if item.items|length %} type="button" data-bs-toggle="collapse" data-bs-target="#id-{{ item.text|slugify }}" aria-expanded="false" aria-controls="" {% endif %}></i>
<a class="nav-link flex-fill align-self-center" {% if item.items|length %} type="button" data-bs-toggle="collapse" data-bs-target="#id-{{ item.text|slugify }}" aria-expanded="false" aria-controls="" {% endif %}
href="{% if item.url_name %}{% url item.url_name %}{% else %}{{ item.url }}{% endif %}">
{% translate item.text %}
</a>
{% if item.count >= 1 %}
<span class="badge bg-primary m-2 align-self-center {% if item.items|length == 0 %}me-4{% endif %}">
{{ item.count }}
</span>
{% elif item.url %}
<span class="pill m-2 me-4 align-self-center fas fa-external-link-alt"></span>
<li class="d-flex flex-wrap m-2 p-2 pt-0 pb-0 mt-0 mb-0 me-0 pe-0">
<i
class="nav-link {{ item.classes }} fa-fw align-self-center me-3 {% if item.navactive %}{% navactive request item.navactive|join:' ' %}{% endif %}"
{% if item.is_folder %}
type="button"
data-bs-toggle="collapse"
data-bs-target="#{{ item.html_id }}"
aria-expanded="false"
aria-controls=""
{% endif %}>
</i>
<a
class="nav-link flex-fill align-self-center me-auto {% if item.navactive %}{% navactive request item.navactive|join:' ' %}{% endif %}"
{% if item.is_folder %}
type="button"
data-bs-toggle="collapse"
data-bs-target="#{{ item.html_id }}"
aria-expanded="false"
aria-controls=""
{% endif %}
href="{% if item.url_name %}{% url item.url_name %}{% else %}{{ item.url }}{% endif %}">
{% translate item.text %}
</a>
{% if item.items|length > 0 %}
<span
class="pill m-2 me-4 align-self-center fas fa-solid fa-chevron-down"
type="button"
data-bs-toggle="collapse"
data-bs-target="#id-{{ item.text|slugify }}"
aria-expanded="false"
aria-controls="">
</span>
<!--<hr class="m-0 w-100">-->
<ul class="collapse ps-1 w-100 border-start rounded-start border-light border-3" id="id-{{ item.text|slugify }}">
{% for sub_item in item.items %}
{{ sub_item.render }}
{% endfor %}
</ul>
{% endif %}
</li>
{% endif %}
{% if item.count >= 1 %}
<span class="badge bg-primary m-2 align-self-center{% if not item.is_folder %} me-2{% endif %}">
{{ item.count }}
</span>
{% elif item.url %}
<span class="pill m-2 me-4 align-self-center fas fa-external-link-alt"></span>
{% endif %}
{% if item.is_folder %}
<span
class="pill m-2 align-self-center collapsed"
type="button"
data-bs-toggle="collapse"
data-bs-target="#{{ item.html_id }}"
aria-expanded="false"
aria-controls=""
>
<i class="fas fa-chevron-right"></i>
<i class="fas fa-chevron-down"></i>
</span>
<ul
class="collapse ps-1 w-100 border-start rounded-start border-light border-3"
id="{{ item.html_id }}">
{% for sub_item in item.children %}
{{ sub_item }}
{% endfor %}
</ul>
{% endif %}
</li>

View File

@@ -0,0 +1,3 @@
<div class="align-items-center text-center">
{% include "bundles/image-auth-logo.html" %}
</div>

View File

@@ -2,57 +2,91 @@
{% load evelinks %}
{% load theme_tags %}
<div style="z-index:5;" class="w100 d-flex flex-column justify-content-center align-items-center text-center pb-2">
{% if user.is_authenticated %}
{% if request.user.profile.main_character %}
{% with request.user.profile.main_character as main %}
<div class="p-2 position-relative m-2">
<div id="aa-user-info" class="w-100 d-flex flex-column justify-content-center align-items-center text-center py-1 border-top border-secondary {% if not user.is_authenticated %}position-absolute bottom-0{% endif %}">
<div class="d-flex mb-0 w-100">
<div class="p-2 position-relative m-2">
{% if user.is_authenticated %}
{% with request.user.profile.main_character as main %}
<img class="rounded-circle" src="{{ main.character_id|character_portrait_url:64 }}" alt="{{ main.character_name }}">
<img class="rounded-circle position-absolute bottom-0 start-0" src="{{ main.corporation_logo_url_32 }}" alt="{{ main.corporation_name }}">
{% if main.alliance_id %}
<img class="rounded-circle position-absolute bottom-0 end-0" src="{{ main.alliance_logo_url_32 }}" alt="{{ main.alliance_name }}">
{% elif main.faction_id %}
<img class="rounded-circle position-absolute bottom-0 end-0" src="{{ main.faction_logo_url_32 }}" alt="{{ main.faction_name }}">
{% endif %}
</div>
<h5>{{ main.character_name }}</h5>
{% endwith %}
{% else %}
<img class="rounded-circle m-2" src="{{ 1|character_portrait_url:32 }}" alt="{% translate 'No Main Character!' %}">
<h5>{% translate "No Main Character!" %}</h5>
{% endif %}
{% endwith %}
{% else %}
{% include "bundles/image-auth-logo.html" with logo_width="64px" %}
{% endif %}
</div>
<div class="align-self-center text-start">
{% if user.is_authenticated %}
{% with request.user.profile.main_character as main %}
<h5 class="m-0">{{ main.character_name }}</h5>
<p class="m-0 small">{{ main.corporation_name }}</p>
{% if main.alliance_id %}
<p class="m-0 small">{{ main.alliance_name }}</p>
{% elif main.faction_id %}
<p class="m-0 small">{{ main.faction_name }}</p>
{% endif %}
{% endwith %}
{% else %}
<h5 class="m-0">{{ SITE_NAME }}</h5>
{% endif %}
</div>
<div class="ms-auto dropup">
<button type="button" class="h-100 btn" data-bs-toggle="dropdown" aria-expanded="false">
<i class="fa-solid fa-gear fa-fw text-light"></i>
</button>
<ul class="dropdown-menu" style="min-width: 200px;">
<li><h6 class="dropdown-header">{% translate "Language" %}</h6></li>
<li>
<a class="dropdown-item">{% include "public/lang_select.html" %}</a>
</li>
<li><h6 class="dropdown-header">{% translate "Theme" %}</h6></li>
{% theme_select %}
{% endif %}
<li>
<a class="dropdown-item">
{% theme_select %}
</a>
</li>
<div class="btn-group m-2">
<button type="button" class="btn btn-secondary p-1">
{% include "public/lang_select.html" %}
</button>
{% if user.is_superuser %}
<a role="button" class="btn btn btn-secondary d-flex" href="{% url 'admin:index' %}">
<span class="align-self-center">{% translate "Admin" %}</span>
</a>
{% endif %}
</div>
<div class="btn-group m-2">
{% if user.is_authenticated %}
<a role="button" class="btn btn-info" href="{% url 'authentication:token_management' %}" title="Token Management"><i class="fa-solid fa-user-lock fa-fw"></i></a>
{% endif %}
{% if user.is_superuser %}
<a role="button" class="btn btn-info" href="https://allianceauth.readthedocs.io/" title="Alliance Auth Documentation"><i class="fa-solid fa-book fa-fw"></i></a>
<a role="button" class="btn btn-info" href="https://discord.gg/fjnHAmk" title="Alliance Auth Discord"><i class="fa-brands fa-discord fa-fw"></i></a>
<a role="button" class="btn btn-info" href="https://gitlab.com/allianceauth/allianceauth" title="Alliance Auth Git"><i class="fa-brands fa-gitlab fa-fw"></i></a>
{% endif %}
{% if user.is_authenticated %}
<a role="button" class="btn btn-danger" href="{% url 'logout' %}" title="{% translate 'Sign Out' %}"><i class="fa-solid fa-right-from-bracket fa-fw"></i></a>
{% else %}
<a role="button" class="btn btn-success" href="{% url 'authentication:login' %}" title="{% translate 'Sign In' %}"> <i class="fa-solid fa-right-to-bracket fa-fw"></i></a>
{% endif %}
{% if user.is_superuser %}
<li><hr class="dropdown-divider"></li>
<li><h6 class="dropdown-header">{% translate "Super User" %}</h6></li>
<li>
<a class="dropdown-item" href="https://allianceauth.readthedocs.io/" title="Alliance Auth Documentation"><i class="fa-solid fa-book fa-fw"></i> Alliance Auth Documentation</a>
</li>
<li>
<a class="dropdown-item" href="https://discord.gg/fjnHAmk" title="Alliance Auth Discord"><i class="fa-brands fa-discord fa-fw"></i> Alliance Auth Discord</a>
</li>
<li>
<a class="dropdown-item" href="https://gitlab.com/allianceauth/allianceauth" title="Alliance Auth Git"><i class="fa-brands fa-gitlab fa-fw"></i> Alliance Auth Git</a>
</li>
{% endif %}
{% if user.is_staff %}
<li>
<a class="dropdown-item" href="{% url 'admin:index' %}">
<i class="fa-solid fa-gear fa-fw"></i> {% translate "Admin" %}
</a>
</li>
{% endif %}
<li><hr class="dropdown-divider"></li>
{% if user.is_authenticated %}
<li>
<a class="dropdown-item" href="{% url 'authentication:token_management' %}">
<i class="fa-solid fa-user-lock fa-fw"></i> Token Management
</a>
</li>
<li>
<a class="dropdown-item text-danger" href="{% url 'logout' %}" title="{% translate 'Sign Out' %}"><i class="fa-solid fa-right-from-bracket fa-fw "></i> {% translate 'Sign Out' %}</a>
</li>
{% else %}
<li>
<a class="dropdown-item text-success" href="{% url 'authentication:login' %}" title="{% translate 'Sign In' %}"> <i class="fa-solid fa-right-to-bracket fa-fw "></i> {% translate 'Sign In' %}</a>
</li>
{% endif %}
</ul>
</div>
</div>
</div>

View File

@@ -4,19 +4,21 @@
<div class="col-auto px-0">
<div class="collapse collapse-horizontal" tabindex="-1" id="sidebar">
<div style="width: 350px;">
<div class="nav-padding navbar-dark bg-dark text-light px-0 d-flex flex-column overflow-hidden vh-100 auth-logo">
<div>
<div class="nav-padding navbar-dark bg-dark text-light px-0 d-flex flex-column overflow-hidden vh-100 {% if not user.is_authenticated %}position-relative{% endif %}">
{% if user.is_authenticated %}
<ul style="z-index:5;" id="sidebar-menu" class="navbar-nav flex-column mb-auto overflow-auto pt-2">
<ul id="sidebar-menu" class="navbar-nav flex-column mb-auto overflow-auto pt-2">
<li class="d-flex flex-wrap m-2 p-2 pt-0 pb-0 mt-0 mb-0 me-0 pe-0">
<i class="nav-link fas fa-tachometer-alt fa-fw align-self-center me-3 {% navactive request 'authentication:dashboard' %}"></i>
<a class="nav-link flex-fill align-self-center" href="{% url 'authentication:dashboard' %}">
<a class="nav-link flex-fill align-self-center {% navactive request 'authentication:dashboard' %}" href="{% url 'authentication:dashboard' %}">
{% translate "Dashboard" %}
</a>
</li>
{% sorted_menu_items %}
{% menu_items %}
</ul>
{% include 'menu/menu-logo.html' %}
{% endif %}
{% include 'menu/menu-user.html' %}

View File

@@ -0,0 +1,32 @@
"""Template tags for rendering the classic side menu."""
from django import template
from django.http import HttpRequest
from allianceauth.hooks import get_hooks
register = template.Library()
# TODO: Show user created menu items
# TODO: Apply is_hidden feature for BS3 type items
@register.inclusion_tag("public/menublock.html", takes_context=True)
def menu_items(context: dict) -> dict:
"""Render menu items for classic dashboard."""
items = render_menu(context["request"])
return {"menu_items": items}
def render_menu(request: HttpRequest):
"""Return the rendered side menu for including in a template.
This function is creating a BS3 style menu.
"""
hooks = get_hooks("menu_item_hook")
raw_items = [fn() for fn in hooks]
raw_items.sort(key=lambda i: i.order)
menu_items = [item.render(request) for item in raw_items]
return menu_items

View File

@@ -1,34 +1,178 @@
"""Template tags for rendering the new side menu.
Documentation of the render logic
---------------------------------
The are 3 types of menu items:
- App entries: Generated by hooks from Django apps
- Link entries: Linking to external pages. User created.
- Folder: Grouping together several app or link entries. User created.
The MenuItem model holds the current list of all menu items.
App entries are linked to a `MenuItemHook` object in the respective Django app.
Those hook objects contain dynamic logic in a `render()` method,
which must be executed when rendering for the current request.
Since the same template must be used to render all items, link entries and folders
are converted to `MenuItemHookCustom` objects, a sub class of `MenuItemHook`.
This ensures the template only rendered objects of one specific type or sub-type.
The rendered menu items are finally collected in a list of RenderedMenuItem objects,
which is used to render the complete menu.
"""
from dataclasses import dataclass, field
from typing import Dict, List, Optional
from django import template
from django.db.models import QuerySet
from django.http import HttpRequest
from allianceauth.hooks import get_hooks
from allianceauth.menu.core import menu_item_hooks, smart_sync
from allianceauth.menu.models import MenuItem
from allianceauth.services.auth_hooks import MenuItemHook
register = template.Library()
def process_menu_items(hooks, request):
_menu_items = list()
items = [fn() for fn in hooks]
items.sort(key=lambda i: i.order)
for item in items:
_menu_items.append(item.render(request))
return _menu_items
@register.inclusion_tag("menu/menu-block.html", takes_context=True)
def menu_items(context: dict) -> dict:
"""Render menu items for new dashboards."""
smart_sync.sync_menu()
items = render_menu(context["request"])
return {"menu_items": items}
@register.inclusion_tag('public/menublock.html', takes_context=True)
def menu_items(context):
request = context['request']
@dataclass
class RenderedMenuItem:
"""A rendered menu item.
return {
'menu_items': process_menu_items(get_hooks('menu_item_hook'), request),
}
These objects can be rendered with the menu-block template.
"""
menu_item: MenuItem
children: List["RenderedMenuItem"] = field(default_factory=list)
count: Optional[int] = None
html: str = ""
html_id: str = ""
@property
def is_folder(self) -> bool:
"""Return True if this item is a folder."""
return self.menu_item.is_folder
def update_html(self, request: HttpRequest, template: str):
"""Render this menu item with defaults and set HTML ID."""
hook_obj = self.menu_item.to_hook_obj()
hook_obj.template = template
hook_obj.count = self.count
if self.is_folder:
hook_obj.children = [child.html for child in self.children]
self.html = hook_obj.render(request)
self.html_id = hook_obj.html_id
@register.inclusion_tag('menu/menu-block.html', takes_context=True)
def sorted_menu_items(context):
request = context['request']
menu_items = MenuItem.render_menu(request)
return {
'menu_items':menu_items
}
def render_menu(request: HttpRequest) -> List[RenderedMenuItem]:
"""Return the rendered side menu for including in a template.
This function is creating BS5 style menus.
"""
hook_items = _gather_menu_items_from_hooks()
# Menu items needs to be rendered with the new BS5 template
bs5_template = "menu/menu-item-bs5.html"
rendered_items: Dict[int, RenderedMenuItem] = {}
menu_items: QuerySet[MenuItem] = MenuItem.objects.order_by(
"parent", "order", "text"
)
for item in menu_items:
if item.is_hidden:
continue # do not render hidden items
if item.is_app_item:
rendered_item = _render_app_item(request, hook_items, item, bs5_template)
if rendered_item.html == "":
# If there is no content dont render it.
# This item has probably been hidden by permissions
continue
elif item.is_link_item:
rendered_item = _render_link_item(request, item, bs5_template)
elif item.is_folder:
rendered_item = RenderedMenuItem(item) # we render these items later
else:
raise NotImplementedError("Unknown menu item type")
if item.is_child:
try:
parent = rendered_items[item.parent_id]
except KeyError:
continue # do not render children of hidden folders
parent.children.append(rendered_item)
if rendered_item.count is not None:
if parent.count is None:
parent.count = 0
parent.count += rendered_item.count
else:
rendered_items[item.id] = rendered_item
_remove_empty_folders(rendered_items)
_render_folder_items(request, rendered_items, bs5_template)
return list(rendered_items.values())
def _gather_menu_items_from_hooks() -> Dict[str, MenuItemHook]:
hook_items = {}
for hook in get_hooks("menu_item_hook"):
f = hook()
hook_items[menu_item_hooks.generate_hash(f)] = f
return hook_items
def _render_app_item(
request: HttpRequest, hook_items: dict, item: MenuItem, new_template: str
) -> RenderedMenuItem:
# This is a module hook, so we need to render it as the developer intended
# TODO add a new attribute for apps that want to override it in the new theme
hook_item = hook_items[item.hook_hash]
hook_item.template = new_template
html = hook_item.render(request)
count = hook_item.count
rendered_item = RenderedMenuItem(menu_item=item, count=count, html=html)
return rendered_item
def _render_link_item(
request: HttpRequest, item: MenuItem, new_template: str
) -> RenderedMenuItem:
rendered_item = RenderedMenuItem(menu_item=item)
rendered_item.update_html(request, template=new_template)
return rendered_item
def _render_folder_items(
request: HttpRequest, rendered_items: Dict[int, RenderedMenuItem], new_template: str
):
for item in rendered_items.values():
if item.menu_item.is_folder:
item.update_html(request=request, template=new_template)
def _remove_empty_folders(rendered_items: Dict[int, RenderedMenuItem]):
ids_to_remove = []
for item_id, item in rendered_items.items():
if item.is_folder and not item.children:
ids_to_remove.append(item_id)
for item_id in ids_to_remove:
del rendered_items[item_id]

Some files were not shown because too many files have changed in this diff Show More