# Member Audit Secure Groups

An Alliance Auth app that enables secure group management with Member Audit.

[![release](https://img.shields.io/pypi/v/aa-memberaudit-securegroups?label=release)](https://pypi.org/project/aa-memberaudit-securegroups/)
[![python](https://img.shields.io/pypi/pyversions/aa-memberaudit-securegroups)](https://pypi.org/project/aa-memberaudit-securegroups/)
[![django](https://img.shields.io/pypi/djversions/aa-memberaudit-securegroups?label=django)](https://pypi.org/project/aa-memberaudit-securegroups/)
[![pipeline status](https://gitlab.com/eclipse-expeditions/aa-memberaudit-securegroups/badges/master/pipeline.svg)](https://gitlab.com/eclipse-expeditions/aa-memberaudit-securegroups/-/commits/master)
[![codecov](https://codecov.io/gl/eclipse-expeditions/aa-memberaudit-securegroups/graph/badge.svg?token=PYKJH1J5TE)](https://codecov.io/gl/eclipse-expeditions/aa-memberaudit-securegroups)
[![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/eclipse-expeditions/aa-memberaudit-securegroups/-/blob/master/LICENSE)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![chat](https://img.shields.io/discord/790364535294132234)](https://discord.gg/zmh52wnfvM)

## Contents

- [Features](#features)
- [Installation](#installation)
- [Updating from aa-ma-securegroups](#updating-from-aa-ma-securegroups)
- [Documentation](#documentation)
- [Changelog](#changelog)

> **Important**<br>
> This project is the official successor of the abandoned project [aa-ma-securegroups](https://github.com/ppfeufer/aa-ma-securegroups).
> For instructions on how to update from an existing aa-ma-securegroups installation please see [Updating from aa-ma-securegroups](#updating-from-aa-ma-securegroups)

## Features

Member Audit Secure Groups provides Secure Groups filters based on character information from Member Audit.
The following filters are provided:

- Activity Filter
- Asset Filter
- Character Age Filter
- Compliance Filter
- Corporation Role Filter
- Corporation Title Filter
- Skill Set Filter
- Skill Point Filter
- Time in Corporation Filter

## Installation

This chapter explains how to install Member Audit Secure Groups (MASG).

### Step 1 - Check prerequisites

1. MASG is a plugin for Alliance Auth. If you don't have Alliance Auth running already, please install it first before proceeding. (see the official [AA installation guide](https://allianceauth.readthedocs.io/en/latest/installation/auth/allianceauth/) for details)

2. MASG needs the app [Member Audit](https://gitlab.com/ErikKalkoken/aa-memberaudit) to function. Please make sure it is installed, before continuing.

3. MASG needs the app [Secure Groups](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups) to function. Please make sure it is installed, before continuing.

### Step 2: Install the app

Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:

```sh
pip install aa-memberaudit-securegroups
```

### Step 3: Configure Auth settings

Add `memberaudit_securegroups` to your `INSTALLED_APPS`.

### Step 4: Finalize App Installation

Run migrations & copy static files

```bash
python manage.py migrate
python manage.py collectstatic --noinput
```

Restart your supervisor services for Auth.

Member Audit Secure Groups is now fully installed and you can setup your first secure groups.

### Step 5: Setup secure groups (Optional)

You can configure your secure groups on the admin site.

First create an Alliance Auth group that you want to become your smart group.

Next create a Member Audit filter. You can find all available filters under "Secure Groups (Member Audit Integration)".

Finally create a smart group for that filter. You can find smart groups under "Secure Groups / Smart Groups".

For more details on how to setup and configure secure groups please also see [Secure Groups](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups).

## Updating from aa-ma-securegroups

MASG is designed to seamlessly replace the abandoned aa-ma-securegroups project.
To update from an existing aa-ma-securegroups installation follow these steps:

### Step 1: Uninstall the old Python package

Make sure you are in the virtual environment (venv) of your Alliance Auth installation.
Then uninstall the old Python package:

```sh
pip uninstall aa-ma-securegroups
```

### Step 2: Install the new Python package

And install the new Python package:

```sh
pip uninstall aa-memberaudit-securegroups
```

### Step 3: Finalize App Update

Run migrations & copy static files:

```bash
python manage.py migrate
python manage.py collectstatic --noinput
```

Restart your supervisor services for Auth.

## Documentation

The provided filters are defined as follows:

| Filter Name | Matches if... |
| -- | -- |
| Activity | User has *at least one* character active within the last X days |
| Age | User has *at least one* character over X days old |
| Asset | User has *at least one* character with *any of* the assets defined |
| Compliance | User has *all* characters registered on Member Audit |
| Skill Point | User has *at least one* character with at least X skill points |
| Skill Set | User has *at least one* character with *any of* the selected skill sets |
| Role | User has a character (main or alt) in a certain corporation with a certain role |
| Title | User has a character (main or alt) in a certain corporation with a certain title |
| Time in Corporation | User has a character (main or alt) in a certain corporation with a certain title |

## Changelog

See [CHANGELOG.md](https://gitlab.com/eclipse-expeditions/aa-memberaudit-securegroups/-/blob/master/CHANGELOG.md)
