Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate admin panel to django #502

Draft
wants to merge 37 commits into
base: master
Choose a base branch
from
Draft

Conversation

laggron42
Copy link
Member

@laggron42 laggron42 commented Jan 6, 2025

The first brick of work that may be the full migration to Django and the ditch of Tortoise, Aerich and fastapi-admin.

fastapi-admin is ditched, replaced by the much better django admin panel. It will enable much better forms, validation, permissions, logs, 2FA, Discord OAuth2, easy template customization and a wide range of extensions.

As django is mostly compatible with its own ORM, a duplication of models.py has been generated and is marked as unmanaged, meaning Django will only look for existing tables and not attempt to make migrations on it (except for admin stuff). We will have to maintain two copies of the model files.

Migrating to the django DB migration engine is highly considered in the future to ditch aerich, but a full migration to the Django ORM and the ditch of Tortoise is unlikely to arrive soon.

TODO

  • Admin views
    • BallInstance
      • Display trade history
      • Filter by special
    • Regime
    • Economy
    • Ball
      • Display preview on the side
      • Test what happens when deleting a ball with a lot of instances
      • Transform catch_names to stripped lowercase
    • Special
      • Display preview on the side
    • Player
      • Display blacklist history
      • Display a 📵 emote next to blacklisted players
      • Action for blacklisting selected players (need intermediate form to provide reason)
      • Display recent catch times
      • Show friends and blocks
      • Show trade history
    • Trade
      • Search and filter by Discord ID
      • Filter using two Discord IDs (or have a custom form/view that displays full trade history with contents between two players)
    • GuildConfig
      • Action for blacklisting selected guilds (need intermediate form to provide reason)
      • Display recent countryballs caught
  • Connect Django to the existing database and duplicate models
    • Check again if the model generation worked correctly (presence of indexes), will be annoying in the future if mismatched
  • Migrations for moving the files and renaming paths in database
  • Look into ditching aerich and moving to the Django migration engine
  • Discord OAuth2
    • Create and assign groups based on admin-role-ids and root-role-ids
    • Notify admins with a Discord webhook
    • Have multiple pipelines for role assignment to customize them (currently it's all grouped in a single one)
  • Clean up the settings (needs testing)
    • Have a configuration ready out of the box for local serve (look into blocking external traffic)
    • Provide a production settings file with DEBUG = False for secure traffic over the internet
  • Docker
    • Change and test admin-panel service in docker compose
  • Write a custom home page ?
  • Add some custom CSS, make it easy to change colors maybe
  • Write documentation in progress here
  • Improve general performance
    • Write good querysets to reduce the number of queries as much as possible. Marking as done for now but this needs to be checked constantly
    • Find out why page loading is so long (it's not the database, something else is slowing down things) --> I used the wrong hostname in production, its resolution was too long lmao

@laggron42 laggron42 force-pushed the lagg/django/admin-panel branch from 4c672c6 to d498af7 Compare January 13, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant