Skip to main content

greenlight Plugin for Alliance Auth (GitHub Version)

Project description

Example Plugin App for Alliance Auth (GitHub Version)

This is an example plugin app for Alliance Auth (AA) that can be used as a starting point to develop custom plugins.

License python django pre-commit

(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)



Features

  • The 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 text

How to Use It

To 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 Repo

For 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, enable pre-commit to enable automatic code style checking.

git clone https://github.com/YourName/aa-example-plugin.git aa-your-app-name
cd aa-your-app-name
rm -rf .git
git init
pre-commit install

Renaming the App

Before 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 & replace example with 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.

Location Description
./example/ Folder name
./example/static/example/ Folder name
./example/templates/example/ Folder name
./pyproject.cfg Update module name for version import, update package name, update title, author, etc.
./example/apps.py App name
./example/__init__.py App name
./example/auth_hooks.py Menu hook config incl. icon and label of your app's menu item appearing in the sidebar
./example/models.py App name
./example/urls.py App name
./example/views.py Permission name and template path
./example/templates/example/base.html Title of your app to be shown in all views and as title in the browser tab
./example/templates/example/index.html Template path
./testauth/local.py App name in PACKAGE constant
./.coveragerc App name
./MANIFEST.in App name
./README.md Clear content
./LICENSE Replace with your own license
./tox.ini App name
./.isort.cfg App name for import_heading_firstparty
./Makefile App name and package name

Clearing Migrations

Instead 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 your migrations folder.

rm your-app-name/migrations/0001_initial.py
rm -rf your-app-name/migrations/_pycache

Writing Unit Tests

Write your unit tests in your-app-name/tests/ and make sure that you use a "test_" prefix for files with your unit tests.

Installing Into Your Dev AA

Once 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:

pip install -e aa-your-app-name

First add your app to the Django project by adding the name of your app to INSTALLED_APPS in settings/local.py.

Next, we will create new migrations for your app:

python manage.py makemigrations

Then run a check to see if everything is set up correctly.

python manage.py check

In case they're errors make sure to fix them before proceeding.

Next, perform migrations to add your model to the database:

python manage.py migrate

Finally, restart your AA server and that's it.

Installing Into Production AA

To install your plugin into a production AA, run this command within the virtual Python environment of your AA installation:

pip install git+https://github.com/YourName/aa-your-app-name

Alternatively, you can create a package file and manually upload it to your production AA:

pip install build
python -m build

You'll find the package under ./dist/aa-your-app-name.tar.gz after this.

Install your package directly from the package file:

pip install aa-your-app-name.tar.gz

Then add your app to INSTALLED_APPS in settings/local.py, run migrations and restart your allianceserver.

Contribute

If 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 creations here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aa_greenlight-1.1.2.tar.gz (38.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aa_greenlight-1.1.2-py3-none-any.whl (47.2 kB view details)

Uploaded Python 3

File details

Details for the file aa_greenlight-1.1.2.tar.gz.

File metadata

  • Download URL: aa_greenlight-1.1.2.tar.gz
  • Upload date:
  • Size: 38.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for aa_greenlight-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3132033b339d8025634a7e96b7a8843d9d5f60ca1b7662dc645ada570bd0a642
MD5 cf7593b3da3002f2358fef06850b6ae7
BLAKE2b-256 6dca84c3f26986d74523ecac2120a0aa590aeb19cd33f68c69019ad0b6aa5eaf

See more details on using hashes here.

File details

Details for the file aa_greenlight-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: aa_greenlight-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 47.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for aa_greenlight-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1c549e5a1ec9a85ba2bef444099f1aa266d77939521e6974285e638c1534717
MD5 daa4b3c3bc44d38c0aebd21e1b381068
BLAKE2b-256 41f16e9137e550cc943e09c8725d88de920febb7abf8e40d107a53b69ca85ebe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page