diff --git a/.gitignore b/.gitignore
index 91906ed8..6be7264d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@
__pycache__
fleetpings/static/fleetpings/js/fleetpings.dev.js
+fleetpings/static/fleetpings/js/fleetpings.dev.min.js
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 016083d1..a9e1017b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
-## [2.3.0] - xxxx-xx-xx
+## [2.3.0] - 2020-10-14
### Important!
@@ -17,17 +17,20 @@ so have your Auth updated before installing this version.
### Fixed
- mySQL text fields can't have default values
+- Parameters differ from overridden method warning
### Added
- Filter to the admin backend
- More checks for Discord. Now checking if the Discord Service s actually activated and setup properly
+- Compatibility to AA Timezones (v1.2.1) new link style
+- Backwards compatibility to versions of AA Timezones before 1.2.1, so the old link style is still generated when using an older version
### Changed
- Use clipboard.js bundled with Alliance Auth
- Minimum required Alliance Auth version set to 2.8.0 due to us using clipboard.js bundled with Alliance Auth
-- Unused lib removed from templates
+- Unused lib removed
## [2.2.2] - 2020-09-23
diff --git a/fleetpings/__init__.py b/fleetpings/__init__.py
index 9f4369b8..86bc019b 100644
--- a/fleetpings/__init__.py
+++ b/fleetpings/__init__.py
@@ -6,5 +6,5 @@
default_app_config: str = "fleetpings.apps.AaFleetpingsConfig"
-__version__ = "2.3.0a1"
+__version__ = "2.3.0"
__title__ = "Fleet Pings"
diff --git a/fleetpings/app_settings.py b/fleetpings/app_settings.py
index 54e0bcd0..a6b8dd27 100644
--- a/fleetpings/app_settings.py
+++ b/fleetpings/app_settings.py
@@ -8,7 +8,9 @@
from django.conf import settings
-from .utils import clean_setting
+from fleetpings.utils import clean_setting
+
+from packaging import version
# set default panels if none are set in local.py
AA_FLEETPINGS_USE_SLACK = clean_setting("AA_FLEETPINGS_USE_SLACK", False)
@@ -25,6 +27,7 @@ def get_site_url(): # regex sso url
get the site url
:return: string
"""
+
regex = r"^(.+)\/s.+"
matches = re.finditer(regex, settings.ESI_SSO_CALLBACK_URL, re.MULTILINE)
url = "http://"
@@ -40,14 +43,47 @@ def timezones_installed() -> bool:
check if aa-timezones is installed
:return: bool
"""
+
return "timezones" in settings.INSTALLED_APPS
+def get_timzones_version():
+ """
+ get the version of aa-timezones, when installed
+ :return: string or None
+ """
+
+ if timezones_installed():
+ from timezones import __version__ as timezones_version
+
+ return timezones_version
+
+ return None
+
+
+def use_new_timezone_links() -> bool:
+ """
+ determins whether to use then new link format from aa-timezones or not
+ the new link format has been introduced with aa-timezones v1.2.1
+ :return: bool
+ """
+
+ return_value = True
+
+ if get_timzones_version() and version.parse(get_timzones_version()) < version.parse(
+ "1.2.1"
+ ):
+ return_value = False
+
+ return return_value
+
+
def fittings_installed() -> bool:
"""
check if fittings is installed
:return: bool
"""
+
return "fittings" in settings.INSTALLED_APPS
@@ -56,12 +92,14 @@ def avoid_cdn() -> bool:
check if we should aviod CDN usage
:return: bool
"""
+
return AVOID_CDN
def discord_service_installed() -> bool:
"""
check if the Discord service is installed
- :return:
+ :return: bool
"""
+
return "allianceauth.services.modules.discord" in settings.INSTALLED_APPS
diff --git a/fleetpings/apps.py b/fleetpings/apps.py
index 8ea0b456..502494fe 100644
--- a/fleetpings/apps.py
+++ b/fleetpings/apps.py
@@ -6,7 +6,7 @@
from django.apps import AppConfig
-from . import __version__
+from fleetpings import __version__
class AaFleetpingsConfig(AppConfig):
diff --git a/fleetpings/auth_hooks.py b/fleetpings/auth_hooks.py
index f816df32..1bac18b5 100644
--- a/fleetpings/auth_hooks.py
+++ b/fleetpings/auth_hooks.py
@@ -6,11 +6,11 @@
from django.utils.translation import ugettext_lazy as _
+from fleetpings import urls, __title__
+
from allianceauth.services.hooks import MenuItemHook, UrlHook
from allianceauth import hooks
-from . import urls, __title__
-
class AaFleetpingsMenuItem(MenuItemHook): # pylint: disable=too-few-public-methods
""" This class ensures only authorized users will see the menu entry """
diff --git a/fleetpings/form.py b/fleetpings/form.py
index 065e5c84..b4b6fbba 100644
--- a/fleetpings/form.py
+++ b/fleetpings/form.py
@@ -5,6 +5,7 @@
"""
from django.forms import ModelForm, TextInput
+
from fleetpings.models import FleetType
diff --git a/fleetpings/models.py b/fleetpings/models.py
index 7e153b5e..2a87a245 100644
--- a/fleetpings/models.py
+++ b/fleetpings/models.py
@@ -110,11 +110,9 @@ class FleetDoctrine(models.Model):
help_text=_("Whether this doctrine is enabled or not"),
)
- def clean(self, *args, **kwargs):
+ def clean(self):
"""
check if the doctrine link is an actual link to a website
- :param args:
- :param kwargs:
"""
doctrine_link = self.link
@@ -129,7 +127,7 @@ def clean(self, *args, **kwargs):
_("Your doctrine URL is not valid.")
) from exception
- super().clean(*args, **kwargs)
+ super().clean()
def __str__(self) -> str:
return str(self.name)
@@ -239,12 +237,10 @@ class DiscordPingTargets(models.Model):
help_text=_("Whether this formup location is enabled or not"),
)
- def clean(self, *args, **kwargs):
+ def clean(self):
"""
check if the group has already been synched to Discord,
if not, raise an error
- :param args:
- :param kwargs:
"""
# check if the Discord service is active
@@ -266,18 +262,16 @@ def clean(self, *args, **kwargs):
_("This group has not been synched to Discord yet.")
)
- super().clean(*args, **kwargs)
+ super().clean()
- def save(self, *args, **kwargs):
+ def save(self):
"""
Add the Discord group ID and save the whole thing
- :param args:
- :param kwargs:
"""
discord_group_info = DiscordUser.objects.group_to_role(self.name)
self.discord_id = discord_group_info["id"]
- super().save(*args, **kwargs) # Call the "real" save() method.
+ super().save() # Call the "real" save() method.
def __str__(self) -> str:
return str(self.name)
diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js
index 463cbd51..941fa0e8 100644
--- a/fleetpings/static/fleetpings/js/fleetpings.js
+++ b/fleetpings/static/fleetpings/js/fleetpings.js
@@ -1,4 +1,4 @@
-/* global fleetpingsSettings, fleetpingsTranslations */
+/* global fleetpingsSettings, fleetpingsTranslations, ClipboardJS */
jQuery(document).ready(function($) {
/* Functions
@@ -153,10 +153,15 @@ jQuery(document).ready(function($) {
* @param {string} formupTime
*/
var getTimezonesUrl = function(formupTime) {
- var formupDateTime = new Date(formupTime)
+ var formupDateTime = new Date(formupTime);
var formupTimestamp = (formupDateTime.getTime() - formupDateTime.getTimezoneOffset() *60 * 1000) / 1000;
+ var timezonesUrl = '';
- var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp;
+ if(fleetpingsSettings.useNewTimezoneLinks === true) {
+ timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/' + formupTimestamp + '/';
+ } else {
+ timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp;
+ }
return timezonesUrl;
};
@@ -186,7 +191,7 @@ jQuery(document).ready(function($) {
// let's see if we can find a doctrine link
var fleetDoctrineLink = null;
if(fleetDoctrine !== '') {
- selectedLink = $('#fleetDoctrineList [value="' + fleetDoctrine + '"]').data('doctrine-url');
+ var selectedLink = $('#fleetDoctrineList [value="' + fleetDoctrine + '"]').data('doctrine-url');
if(undefined !== selectedLink && selectedLink !== '') {
// Houston, we have a link!
@@ -209,6 +214,7 @@ jQuery(document).ready(function($) {
var pingText = '';
// determine pingTargetText
+ var discordPingTarget = '';
if(pingTargetText.indexOf('@') > -1) {
discordPingTarget = pingTargetText;
} else {
@@ -216,6 +222,7 @@ jQuery(document).ready(function($) {
}
// determine pingTarget
+ var webhookPingTarget = '';
if(pingTarget.indexOf('@') > -1) {
webhookPingTarget = pingTarget;
} else {
@@ -250,34 +257,34 @@ jQuery(document).ready(function($) {
webhookPingTextHeader += 'Fleet is up';
}
- pingText += '**' + "\n";
+ pingText += '**' + '\n';
// check if FC name is available
if(fcName !== '') {
- pingText += "\n" + '**FC:** ' + fcName;
- webhookPingTextContent += "\n" + '**FC:** ' + fcName;
+ pingText += '\n' + '**FC:** ' + fcName;
+ webhookPingTextContent += '\n' + '**FC:** ' + fcName;
}
// check if fleet name is available
if(fleetName !== '') {
- pingText += "\n" + '**Fleet Name:** ' + fleetName;
- webhookPingTextContent += "\n" + '**Fleet Name:** ' + fleetName;
+ pingText += '\n' + '**Fleet Name:** ' + fleetName;
+ webhookPingTextContent += '\n' + '**Fleet Name:** ' + fleetName;
}
// check if form-up location is available
if(formupLocation !== '') {
- pingText += "\n" + '**Formup Location:** ' + formupLocation;
- webhookPingTextContent += "\n" + '**Formup Location:** ' + formupLocation;
+ pingText += '\n' + '**Formup Location:** ' + formupLocation;
+ webhookPingTextContent += '\n' + '**Formup Location:** ' + formupLocation;
}
// check if form-up time is available
if($('input#formupTimeNow').is(':checked')) {
- pingText += "\n" + '**Formup Time:** NOW';
- webhookPingTextContent += "\n" + '**Formup Time:** NOW';
+ pingText += '\n' + '**Formup Time:** NOW';
+ webhookPingTextContent += '\n' + '**Formup Time:** NOW';
} else {
if(formupTime !== '') {
- pingText += "\n" + '**Formup Time:** ' + formupTime;
- webhookPingTextContent += "\n" + '**Formup Time:** ' + formupTime;
+ pingText += '\n' + '**Formup Time:** ' + formupTime;
+ webhookPingTextContent += '\n' + '**Formup Time:** ' + formupTime;
// get the timestamp and build the link to the timezones module if it's installed
if(fleetpingsSettings.timezonesInstalled === true) {
@@ -298,14 +305,14 @@ jQuery(document).ready(function($) {
// check if fleet comms is available
if(fleetComms !== '') {
- pingText += "\n" + '**Comms:** ' + fleetComms;
- webhookPingTextContent += "\n" + '**Comms:** ' + fleetComms;
+ pingText += '\n' + '**Comms:** ' + fleetComms;
+ webhookPingTextContent += '\n' + '**Comms:** ' + fleetComms;
}
// check if doctrine is available
if(fleetDoctrine !== '') {
- pingText += "\n" + '**Ships / Doctrine:** ' + fleetDoctrine;
- webhookPingTextContent += "\n" + '**Ships / Doctrine:** ' + fleetDoctrine;
+ pingText += '\n' + '**Ships / Doctrine:** ' + fleetDoctrine;
+ webhookPingTextContent += '\n' + '**Ships / Doctrine:** ' + fleetDoctrine;
// grab the doctrine link if there is one
if(fleetDoctrineLink !== null) {
@@ -323,14 +330,14 @@ jQuery(document).ready(function($) {
// check if srp is available
if(fleetSrp !== '') {
- pingText += "\n" + '**SRP:** ' + fleetSrp;
- webhookPingTextContent += "\n" + '**SRP:** ' + fleetSrp;
+ pingText += '\n' + '**SRP:** ' + fleetSrp;
+ webhookPingTextContent += '\n' + '**SRP:** ' + fleetSrp;
}
// check if additional information is available
if(additionalInformation !== '') {
- pingText += "\n\n" + '**Additional Information**:' + "\n" + additionalInformation;
- webhookPingTextContent += "\n\n" + '**Additional Information**:' + "\n" + additionalInformation;
+ pingText += '\n\n' + '**Additional Information**:' + '\n' + additionalInformation;
+ webhookPingTextContent += '\n\n' + '**Additional Information**:' + '\n' + additionalInformation;
}
if(fleetpingsSettings.platformUsed === 'Discord') {
@@ -345,7 +352,7 @@ jQuery(document).ready(function($) {
if(webhookUrl !== false && webhookUrl !== '') {
// add ping creator at the end
if(fleetpingsSettings.pingCreator !== '') {
- pingText += "\n\n" + '*(Ping sent by: ' + fleetpingsSettings.pingCreator + ')*';
+ pingText += '\n\n' + '*(Ping sent by: ' + fleetpingsSettings.pingCreator + ')*';
webhookPingTextFooter = '(Ping sent by: ' + fleetpingsSettings.pingCreator + ')';
}
@@ -368,7 +375,7 @@ jQuery(document).ready(function($) {
if(undefined !== webhookEmbedPing && webhookEmbedPing === 'True') {
sendEmbeddedDiscordPing(
webhookUrl,
- webhookPingTarget + ' :: **' + webhookPingTextHeader + '**' + "\n" + '** **',
+ webhookPingTarget + ' :: **' + webhookPingTextHeader + '**' + '\n' + '** **',
// embedded content » https://discohook.org/ - https://leovoel.github.io/embed-visualizer/
{
'title': '**.: Fleet Details :.**',
@@ -399,7 +406,7 @@ jQuery(document).ready(function($) {
'fallback': pingText,
'color': embedColor,
'pretext': '<' + slackEmbedPingTarget + '>' + ' :: *' + webhookPingTextHeader + '*',
- 'text': '*.: Fleet Details :.*' + "\n" + webhookPingTextContent.split('**').join('*'),
+ 'text': '*.: Fleet Details :.*' + '\n' + webhookPingTextContent.split('**').join('*'),
'footer': webhookPingTextFooter,
// 'footer_icon': 'https://platform.slack-edge.com/img/default_application_icon.png'
}
@@ -420,7 +427,7 @@ jQuery(document).ready(function($) {
/**
* copy the fleet ping to clipboard
*/
- var CopyFleetPing = function() {
+ var copyFleetPing = function() {
/**
* copy text to clipboard
*
@@ -498,6 +505,6 @@ jQuery(document).ready(function($) {
* copy ping text
*/
$('button#copyFleetPing').on('click', function() {
- CopyFleetPing();
+ copyFleetPing();
});
});
diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js
index 3ecf2f00..25d5a3c1 100644
--- a/fleetpings/static/fleetpings/js/fleetpings.min.js
+++ b/fleetpings/static/fleetpings/js/fleetpings.min.js
@@ -1 +1 @@
-jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
"+nl2br(discordPingTarget+pingText)+"
")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html(""+nl2br(discordPingTarget+pingText.split("**").join("*"))+"
")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?""+nl2br(discordPingTarget+pingText)+"
")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html(""+nl2br(discordPingTarget+pingText.split("**").join("*"))+"
")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var copyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){copyFleetPing()})}); \ No newline at end of file diff --git a/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js b/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js deleted file mode 100644 index b9ed143b..00000000 --- a/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * clipboard.js v2.0.6 - * https://clipboardjs.com/ - * - * Licensed MIT © Zeno Rocha - */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return o={},r.m=n=[function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),r=document.createRange();r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r),e=o.toString()}return e}},function(t,e){function n(){}n.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function r(){o.off(t,r),e.apply(n,arguments)}return r._=e,this.on(t,r,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;o