Package: aa-example-plugin
Example Plugin App for Alliance Auth (GitHub Version)This is an example plugin app forAlliance Auth(AA) that can be used as a starting point to develop custom plugins.(These badges are examples, you can and should replace them with your own)For the GitLab version of this example app, please have a look over here, Erik
Kalkoken was so friendly to provide it »Alliance Auth Example App (GitLab Version)Example Plugin App for Alliance Auth (GitHub Version)FeaturesHow to Use ItCloning From RepoRenaming the AppClearing MigrationsWriting Unit TestsInstalling Into Your Dev AAInstalling Into Production AAContributeFeaturesThe plugin can be installed, upgraded (and removed) into an existing AA
installation using PyInstaller.It has its own menu item in the sidebar.It has one view that shows a panel and some textHow to Use ItTo use this example as a basis for your own development, just fork this repo and then
clone it on your dev machine.You then should rename the app, and then you can install it into your AA dev
installation.Cloning From RepoFor this app, we're assuming that you have all your AA projects, your virtual
environment, and your AA installation under one top folder (e.g. aa-dev).This should look something like this:aa-dev
|- venv/
|- myauth/
|- aa-example-plugin
|- (other AA projects ...)Then just cd into the top folder (e.g. aa-dev) and clone the repo from your fork.
You can give the repo a new name right away (e.g.aa-your-app-name). You also want
to create a new git repo for it.
Finally, enablepre-committo enable automatic code style
checking.gitclonehttps://github.com/YourName/aa-example-plugin.gitaa-your-app-namecdaa-your-app-name
rm-rf.git
gitinit
pre-commitinstallRenaming the AppBefore installing this app into your dev AA you need to rename it to something
suitable for your development project. Otherwise, you risk not being able to install
additional apps that might also be called example.Here is an overview of the places that you need to edit to adopt the name.Easiest is to just find & replaceexamplewith your new app name in all files
listed below.One small warning about picking names: Python is a bit particular about what special
characters are allowed for names of modules and packages. To avoid any pitfalls, I
would therefore recommend using only normal characters (a-z) in your app's name
unless you know exactly what you're doing.LocationDescription./example/Folder name./example/static/example/Folder name./example/templates/example/Folder name./pyproject.cfgUpdate module name for version import, update package name, update title, author, etc../example/apps.pyApp name./example/__init__.pyApp name./example/auth_hooks.pyMenu hook config incl. icon and label of your app's menu item appearing in the sidebar./example/models.pyApp name./example/urls.pyApp name./example/views.pyPermission name and template path./example/templates/example/base.htmlTitle of your app to be shown in all views and as title in the browser tab./example/templates/example/index.htmlTemplate path./testauth/local.pyApp name inPACKAGEconstant./.coveragercApp name./MANIFEST.inApp name./README.mdClear content./LICENSEReplace with your own license./tox.iniApp name./.isort.cfgApp name forimport_heading_firstparty./MakefileApp name and package nameClearing MigrationsInstead of renaming your app in the migrations, it's easier to just recreate them
later in the process. For this to work, you need to delete the old migration files in
yourmigrationsfolder.rmyour-app-name/migrations/0001_initial.py
rm-rfyour-app-name/migrations/_pycacheWriting Unit TestsWrite your unit tests inyour-app-name/tests/and make sure that you use a "test_"
prefix for files with your unit tests.Installing Into Your Dev AAOnce you've cloned or copied all files into place and finished renaming the app,
you're ready to install it to your dev AA instance.Make sure you're in your venv. Then install it with pip in editable mode:pipinstall-eaa-your-app-nameFirst add your app to the Django project by adding the name of your app to
INSTALLED_APPS insettings/local.py.Next, we will create new migrations for your app:pythonmanage.pymakemigrationsThen run a check to see if everything is set up correctly.pythonmanage.pycheckIn case they're errors make sure to fix them before proceeding.Next, perform migrations to add your model to the database:pythonmanage.pymigrateFinally, restart your AA server and that's it.Installing Into Production AATo install your plugin into a production AA, run this command within the virtual
Python environment of your AA installation:pipinstallgit+https://github.com/YourName/aa-your-app-nameAlternatively, you can create a package file and manually upload it to your
production AA:pipinstallbuild
python-mbuildYou'll find the package under./dist/aa-your-app-name.tar.gzafter this.Install your package directly from the package file:pipinstallaa-your-app-name.tar.gzThen add your app toINSTALLED_APPSinsettings/local.py, run migrations and
restart your allianceserver.ContributeIf you've made a new app for AA, please consider sharing it with the rest of the
community. For any questions on how to share your app, please contact the AA devs on
their Discord. You find the current community creationshere.