Skip to content

Commit

Permalink
Merge pull request #105 from ppfeufer/development
Browse files Browse the repository at this point in the history
[RELEASE] v2.22.0
  • Loading branch information
ppfeufer authored May 20, 2023
2 parents 28bb35b + 90ca1fb commit c33ccb7
Show file tree
Hide file tree
Showing 49 changed files with 3,221 additions and 1,136 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ repos:
- id: text-unicode-replacement-char

- repo: https://github.com/adamchainz/django-upgrade
rev: 1.12.0
rev: 1.13.0
hooks:
- id: django-upgrade
args: [ --target-version=4.0 ]

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
rev: v3.4.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]
Expand All @@ -84,7 +84,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
args: [ --target-version=py38 ]
Expand All @@ -93,5 +93,5 @@ repos:
rev: 1.13.0
hooks:
- id: blacken-docs
additional_dependencies: [ black==22.12.0 ]
additional_dependencies: [ black==23.3.0 ]
args: [ --target-version=py38 ]
27 changes: 21 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [In Development] - Unreleased


## [2.22.0] - 2023-05-20

### Changed

- Migrated settings from `local.py` to the database
- German translation updated
- Russian translation updated
- Ukrainian translation updated (not complete yet, currently at 90% translated)

### Update Notes:

After this update and successful migration, you can remove this app's settings from
your `local.py`. All settings are now handled through the Django Admin Backend under
`/admin/fleetpings/setting/`


## [2.21.0] - 2023-04-25

### Added
Expand Down Expand Up @@ -92,7 +108,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Templates cleaned up and re-organised
- Templates cleaned up and re-organized
- Minimum Requirement:
- Alliance Auth >= 2.14.0

Expand Down Expand Up @@ -500,7 +516,7 @@ settings in the admin backend, since we just nuked them from the old app.
- Configuration for pre-defined fleet comms, formup locations, and doctrines. These
can be configured in your `local.py` via `AA_DISCORDFORMATTER_FLEET_COMMS`,
`AA_DISCORDFORMATTER_FLEET_DOCTRINES` and
`AA_DISCORDFORMATTER_FLEET_FORMUP_LOCATIONS`. See [README](https://github.com/ppfeufer/aa-discord-ping-formatter#fleet-comms-formup-location-and-doctrine) for syntax.
`AA_DISCORDFORMATTER_FLEET_FORMUP_LOCATIONS`.


## [1.0.0] - 2020-07-16
Expand All @@ -518,7 +534,7 @@ settings in the admin backend, since we just nuked them from the old app.
### Fixed

- Our Australian time travelers and everyone else who lives in the future (UTC+x) are
now able to pre-ping fleets that are coming up in 2 hours Eve time, which might
now able to pre-ping fleets that are coming up in 2-hours Eve time, which might
still be in their past local time, depending on how far in the future they live. (#19)


Expand All @@ -529,7 +545,7 @@ settings in the admin backend, since we just nuked them from the old app.
- Option to embed automatic pings via webhook (#13)
- Embedded pings via webhook are now color coded. Pre-defined fleet types are by
default (Roam = green, Home Defense = yellow, StratOP = orange, CTA = red), and custom
fleet types can be defined via settings (see [README](https://github.com/ppfeufer/aa-discord-ping-formatter#embed-webhook-pings))
fleet types can be defined via settings.

### Changed

Expand All @@ -551,8 +567,7 @@ settings in the admin backend, since we just nuked them from the old app.

### Added

- Webhook group restrictions. Webhooks can now be restricted to certain groups (see
[README](https://github.com/ppfeufer/aa-discord-ping-formatter#adding-ping-channels)),
- Webhook group restrictions. Webhooks can now be restricted to certain groups,
so not everyone who has access to this module can ping through all webhooks.
Webhooks without restrictions are accessible for all with access to the module.
(Thanks to Exiom for bringing this up)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ graph_models:

coverage:
rm -rfv htmlcov && \
coverage run ../myauth/manage.py test $(package) --keepdb --failfast && coverage html && coverage report -m
coverage run ../myauth/manage.py test $(package) --keepdb --failfast -v 3 && coverage html && coverage report -m

build_test:
rm -rfv dist && \
Expand Down
66 changes: 42 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ Discord.
* [View in Alliance Auth](#view-in-alliance-auth)
* [Discord Ping Example](#discord-ping-example)
* [Configuration](#configuration)
* [Use Default Fleet Types](#use-default-fleet-types)
* [Use Default Ping Targets](#use-default-ping-targets)
* [Use Doctrines From Fittings Module](#use-doctrines-from-fittings-module)
* [Allow Non Discord Webhooks](#allow-non-discord-webhooks)
* [Webhook Verification](#webhook-verification)
* [Default Embed Color](#default-embed-color)
* [Changelog](#changelog)
* [Contributing](#contributing)
<!-- TOC -->
Expand Down Expand Up @@ -117,19 +120,32 @@ Finally, restart your AA supervisor services.

![View in Alliance Auth](https://raw.githubusercontent.com/ppfeufer/aa-fleetpings/master/fleetpings/docs/images/aa-view.jpg "View in Alliance Auth")


### Discord Ping Example

![Discord Ping Example](https://raw.githubusercontent.com/ppfeufer/aa-fleetpings/master/fleetpings/docs/images/discord-ping.jpg "Discord Ping Example")


## Configuration

The following settings can be made in your `local.py`:
The following settings are available in the Django Admin Backend under
`/admin/fleetpings/setting/`:


### Use Default Fleet Types

Enable or disable the default fleet types (Roaming, Home Defense, StratOP, and CTA)
that are shown in the fleet type dropdown in addition to your own.

**Default:** True


### Use Default Ping Targets

| Setting | Description | Default |
|:---------------------------------------------------|:----------------------------------------------------------------------------------------|:--------|
| `AA_FLEETPINGS_USE_DOCTRINES_FROM_FITTINGS_MODULE` | Enables integration with the [Fittings and Doctrines] module for doctrine suggestion. | `False` |
| `AA_FLEETPINGS_WEBHOOK_VERIFICATION` | Enables or disables verification of webhook URLs to see if it's a valid Discord webhook | `True` |
Enable or disable the default ping targets (@everyone and @here) that are shown in
the ping target dropdown in addition to your own.

**Default:** True


### Use Doctrines From Fittings Module
Expand All @@ -139,30 +155,26 @@ configured there, you don't have to re-build your doctrine list for this module.
can simply use the doctrines you already have configured in the Fittings and
Doctrines module.

To do so, add the following to your `local.py`:

```python
## AA Fleet Pings
AA_FLEETPINGS_USE_DOCTRINES_FROM_FITTINGS_MODULE = True
```
**Default:** True

### Allow Non Discord Webhooks

If you require your pings to be sent to a webhook that is not a standard discord
webhook, add the following to your `local.py`:
### Webhook Verification

```python
## AA Fleet Pings
AA_FLEETPINGS_WEBHOOK_VERIFICATION = False
```
If you require your pings to be sent to a webhook, that is not a standard discord
webhook.

When disabling webhook verification and using non Discord webhooks, it is up to you
When disabling webhook verification and using non-Discord webhooks, it is up to you
to make sure your webhook understands a payload that is formatted for Discord webhooks.

<!-- URLs -->
[Fittings and Doctrines]: https://gitlab.com/colcrunch/fittings "Fittings and Doctrines"
[Discord service]: https://allianceauth.readthedocs.io/en/latest/features/services/discord.html "Discord service"
[AA installation guide]: https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html "AA installation guide"
**Default:** True


### Default Embed Color

The default highlight for the embed, that is used when no other highlight color is
defined.

**Default:** #FAA61A


## Changelog
Expand All @@ -176,3 +188,9 @@ You want to contribute to this project? That's cool!

Please make sure to read the [Contribution Guidelines](https://github.com/ppfeufer/aa-fleetpings/blob/master/CONTRIBUTING.md)
(I promise, it's not much, just some basics)


<!-- URLs -->
[Fittings and Doctrines]: https://gitlab.com/colcrunch/fittings "Fittings and Doctrines"
[Discord service]: https://allianceauth.readthedocs.io/en/latest/features/services/discord.html "Discord service"
[AA installation guide]: https://allianceauth.readthedocs.io/en/latest/installation/allianceauth.html "AA installation guide"
Binary file modified aa-fleetpings-models.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 77 additions & 13 deletions fleetpings/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
# Django
from django.contrib import admin
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _

# AA Fleet Pings
from fleetpings.form import FleetTypeAdminForm
from fleetpings.form import FleetTypeAdminForm, SettingAdminForm
from fleetpings.models import (
DiscordPingTargets,
FleetComm,
FleetDoctrine,
FleetType,
FormupLocation,
Setting,
Webhook,
)

Expand All @@ -39,6 +41,51 @@ def __new__(cls, *args, **kwargs):
return Wrapper


class SingletonModelAdmin(admin.ModelAdmin):
"""
Prevents Django admin users deleting the singleton or adding extra rows.
"""

actions = None # Removes the default delete action.

def has_add_permission(self, request):
"""
Has "add" permissions
:param request:
:type request:
:return:
:rtype:
"""

return self.model.objects.all().count() == 0

def has_change_permission(self, request, obj=None):
"""
Has "change" permissions
:param request:
:type request:
:param obj:
:type obj:
:return:
:rtype:
"""

return True

def has_delete_permission(self, request, obj=None):
"""
Has "delete" permissions
:param request:
:type request:
:param obj:
:type obj:
:return:
:rtype:
"""

return False


@admin.register(FleetComm)
class FleetCommAdmin(admin.ModelAdmin):
"""
Expand All @@ -50,7 +97,7 @@ class FleetCommAdmin(admin.ModelAdmin):
list_filter = ("is_enabled",)

@classmethod
@admin.display(description="Fleet Comms", ordering="name")
@admin.display(description=_("Fleet Comm"), ordering="name")
def _name(cls, obj):
return obj.name

Expand All @@ -71,17 +118,19 @@ class FleetDoctrineAdmin(admin.ModelAdmin):
)

@classmethod
@admin.display(description="Doctrine", ordering="name")
@admin.display(description=_("Doctrine"), ordering="name")
def _name(cls, obj):
return obj.name

@classmethod
@admin.display(description="Doctrine Link", ordering="link")
@admin.display(description=_("Doctrine link"), ordering="link")
def _link(cls, obj):
return obj.name

@classmethod
@admin.display(description="Restricted to", ordering="restricted_to_group__name")
@admin.display(
description=_("Group restrictions"), ordering="restricted_to_group__name"
)
def _restricted_to_group(cls, obj):
names = [x.name for x in obj.restricted_to_group.all().order_by("name")]

Expand Down Expand Up @@ -127,12 +176,14 @@ class DiscordPingTargetsAdmin(admin.ModelAdmin):
)

@classmethod
@admin.display(description="Ping Target", ordering="name")
@admin.display(description=_("Ping Target"), ordering="name")
def _name(cls, obj):
return obj.name

@classmethod
@admin.display(description="Restricted to", ordering="restricted_to_group__name")
@admin.display(
description=_("Group restrictions"), ordering="restricted_to_group__name"
)
def _restricted_to_group(cls, obj):
names = [x.name for x in obj.restricted_to_group.all().order_by("name")]

Expand Down Expand Up @@ -167,12 +218,12 @@ class FleetTypeAdmin(admin.ModelAdmin):
)

@classmethod
@admin.display(description="Fleet Type", ordering="name")
@admin.display(description=_("Fleet Type"), ordering="name")
def _name(cls, obj):
return obj.name

@classmethod
@admin.display(description="Embed Color", ordering="embed_color")
@admin.display(description=_("Embed color"), ordering="embed_color")
def _embed_color(cls, obj):
return_value = (
"<span "
Expand All @@ -184,7 +235,9 @@ def _embed_color(cls, obj):
return mark_safe(return_value)

@classmethod
@admin.display(description="Restricted to", ordering="restricted_to_group__name")
@admin.display(
description=_("Group restrictions"), ordering="restricted_to_group__name"
)
def _restricted_to_group(cls, obj):
names = [x.name for x in obj.restricted_to_group.all().order_by("name")]

Expand Down Expand Up @@ -217,21 +270,32 @@ class WebhookAdmin(admin.ModelAdmin):
)

@classmethod
@admin.display(description="Channel Name", ordering="name")
@admin.display(description=_("Discord channel"), ordering="name")
def _name(cls, obj):
return obj.name

@classmethod
@admin.display(description="Webhook URL", ordering="url")
@admin.display(description=_("Webhook URL"), ordering="url")
def _url(cls, obj):
return obj.url

@classmethod
@admin.display(description="Restricted to", ordering="restricted_to_group__name")
@admin.display(
description=_("Group restrictions"), ordering="restricted_to_group__name"
)
def _restricted_to_group(cls, obj):
names = [x.name for x in obj.restricted_to_group.all().order_by("name")]

if names:
return ", ".join(names)

return None


@admin.register(Setting)
class SettingAdmin(SingletonModelAdmin):
"""
Setting Admin
"""

form = SettingAdminForm
Loading

0 comments on commit c33ccb7

Please sign in to comment.