From a8115931abc0d2051e6353b760d0806352b43aee Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Wed, 23 Sep 2020 21:11:52 +0200 Subject: [PATCH 01/13] little bit of JS optimization --- fleetpings/static/fleetpings/js/fleetpings.js | 74 +++++++++++-------- .../static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 45 insertions(+), 31 deletions(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index 3613a375..463cbd51 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -10,11 +10,11 @@ jQuery(document).ready(function($) { * @param {string} string * @param {bool} isXhtml */ - var nl2br = (function(string, isXhtml) { - var breakTag = (isXhtml || typeof isXhtml === 'undefined') ? '
' : '
'; + 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'); - }); + }; /** * closing the message @@ -22,7 +22,7 @@ jQuery(document).ready(function($) { * @param {string} element * @returns {void} */ - var closeCopyMessageElement = (function(element) { + var closeCopyMessageElement = function(element) { /** * close after 10 seconds */ @@ -31,7 +31,7 @@ jQuery(document).ready(function($) { $(this).remove(); }); }); - }); + }; /** * show message when copy action was successful @@ -40,13 +40,13 @@ jQuery(document).ready(function($) { * @param {string} element * @returns {undefined} */ - var showSuccess = (function(message, element) { + var showSuccess = function(message, element) { $(element).html('
' + message + '
'); closeCopyMessageElement('.alert-copy-success'); return; - }); + }; /** * show message when copy action was not successful @@ -55,13 +55,13 @@ jQuery(document).ready(function($) { * @param {string} element * @returns {undefined} */ - var showError = (function(message, element) { + var showError = function(message, element) { $(element).html('
' + message + '
'); closeCopyMessageElement('.alert-copy-error'); return; - }); + }; /** * sanitize input string @@ -69,22 +69,22 @@ jQuery(document).ready(function($) { * @param {string} element * @returns {undefined} */ - var sanitizeInput = (function(input) { + var sanitizeInput = function(input) { if(input) { return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g, ''); } else { return input; } - }); + }; /** * send an embedded message to a Discord webhook * * @param {string} webhookUrl * @param {string} content - * @param {array} embeds + * @param {object} embeds */ - var sendEmbeddedDiscordPing = (function(webhookUrl, content, embeds) { + var sendEmbeddedDiscordPing = function(webhookUrl, content, embeds) { var request = new XMLHttpRequest(); request.open('POST', webhookUrl); @@ -98,7 +98,7 @@ jQuery(document).ready(function($) { }; request.send(JSON.stringify(params)); - }); + }; /** * send a message to a Discord webhook @@ -106,7 +106,7 @@ jQuery(document).ready(function($) { * @param {string} webhookUrl * @param {string} pingText */ - var sendDiscordPing = (function(webhookUrl, pingText) { + var sendDiscordPing = function(webhookUrl, pingText) { var request = new XMLHttpRequest(); request.open('POST', webhookUrl); @@ -119,9 +119,15 @@ jQuery(document).ready(function($) { }; request.send(JSON.stringify(params)); - }); + }; - var sendSlackPing = (function(webhookUrl, payload) { + /** + * send a message to a Slack webhook + * + * @param {string} webhookUrl + * @param {object} payload + */ + var sendSlackPing = function(webhookUrl, payload) { $.ajax({ data: 'payload=' + JSON.stringify(payload), dataType: 'json', @@ -129,16 +135,16 @@ jQuery(document).ready(function($) { type: 'POST', url: webhookUrl }); - }); + }; /** * convert hex color code in something Discord can handle * * @param {string} hexValue */ - var hexToDecimal = (function(hexValue) { + var hexToDecimal = function(hexValue) { return parseInt(hexValue.replace('#',''), 16); - }); + }; /** * convert the datepicker info into an URL that the @@ -146,25 +152,28 @@ jQuery(document).ready(function($) { * * @param {string} formupTime */ - var getTimezonesUrl = (function(formupTime) { + var getTimezonesUrl = function(formupTime) { var formupDateTime = new Date(formupTime) var formupTimestamp = (formupDateTime.getTime() - formupDateTime.getTimezoneOffset() *60 * 1000) / 1000; var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp; return timezonesUrl; - }); + }; /** * create the ping text */ - var generateFleetPing = (function() { + var generateFleetPing = function() { var pingTarget = sanitizeInput($('select#pingTarget option:selected').val()); var pingTargetText = sanitizeInput($('select#pingTarget option:selected').text()); - var fleetType = sanitizeInput($('select#fleetType option:selected').val()); + var webhookType = sanitizeInput($('select#pingChannel option:selected').data('webhook-type')); - var webhookEmbedColor = sanitizeInput($('select#fleetType option:selected').data('embed-color')); var webhookEmbedPing = sanitizeInput($('select#pingChannel option:selected').data('webhook-embed')); + + var fleetType = sanitizeInput($('select#fleetType option:selected').val()); + var webhookEmbedColor = sanitizeInput($('select#fleetType option:selected').data('embed-color')); + var fcName = sanitizeInput($('input#fcName').val()); var fleetName = sanitizeInput($('input#fleetName').val()); var formupLocation = sanitizeInput($('input#formupLocation').val()); @@ -341,7 +350,7 @@ jQuery(document).ready(function($) { } // default embed color - var embedColor = '#FAA61A'; + var embedColor = '#faa61a'; if(fleetType !== '' && embedColor !== '') { embedColor = webhookEmbedColor; @@ -357,7 +366,6 @@ jQuery(document).ready(function($) { // send the ping to Discord if(webhookType === 'Discord') { if(undefined !== webhookEmbedPing && webhookEmbedPing === 'True') { - sendEmbeddedDiscordPing( webhookUrl, webhookPingTarget + ' :: **' + webhookPingTextHeader + '**' + "\n" + '** **', @@ -379,6 +387,12 @@ jQuery(document).ready(function($) { // send the ping to Discord if(webhookType === 'Slack') { var slackEmbedPingTarget = webhookPingTarget.replace('@', '!'); + + /** + * payload to send to Slack + * + * @type {{attachments: [{color: string, footer: string, pretext: string, text: string, fallback: string}]}} + */ var payload = { 'attachments': [ { @@ -401,12 +415,12 @@ jQuery(document).ready(function($) { '.aa-fleetpings-ping-copyresult' ); } - }); + }; /** * copy the fleet ping to clipboard */ - var CopyFleetPing = (function() { + var CopyFleetPing = function() { /** * copy text to clipboard * @@ -440,7 +454,7 @@ jQuery(document).ready(function($) { clipboardFleetPingData.destroy(); }); - }); + }; /* Events ----------------------------------------------------------------------------------------------------------------- */ diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 69bb6172..3ecf2f00 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(10000,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove();});});});var showSuccess=(function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return;});var showError=(function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return;});var sanitizeInput=(function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"");}else{return input;}});var sendEmbeddedDiscordPing=(function(webhookUrl,content,embeds){var request=new XMLHttpRequest();request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params));});var sendDiscordPing=(function(webhookUrl,pingText){var request=new XMLHttpRequest();request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params));});var sendSlackPing=(function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl});});var hexToDecimal=(function(hexValue){return parseInt(hexValue.replace("#",""),16);});var getTimezonesUrl=(function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1000)/1000;var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp;return timezonesUrl;});var generateFleetPing=(function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink;}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val());}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText;}else{discordPingTarget="@"+pingTargetText;}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget;}else{webhookPingTarget="<@&"+pingTarget+">";}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet";}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet";}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" ";}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up";}pingText+="**\n";if(fcName!==""){pingText+="\n**FC:** "+fcName;webhookPingTextContent+="\n**FC:** "+fcName;}if(fleetName!==""){pingText+="\n**Fleet Name:** "+fleetName;webhookPingTextContent+="\n**Fleet Name:** "+fleetName;}if(formupLocation!==""){pingText+="\n**Formup Location:** "+formupLocation;webhookPingTextContent+="\n**Formup Location:** "+formupLocation;}if($("input#formupTimeNow").is(":checked")){pingText+="\n**Formup Time:** NOW";webhookPingTextContent+="\n**Formup Time:** NOW";}else{if(formupTime!==""){pingText+="\n**Formup Time:** "+formupTime;webhookPingTextContent+="\n**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))";}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)";}}}}if(fleetComms!==""){pingText+="\n**Comms:** "+fleetComms;webhookPingTextContent+="\n**Comms:** "+fleetComms;}if(fleetDoctrine!==""){pingText+="\n**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))";}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)";}}}if(fleetSrp!==""){pingText+="\n**SRP:** "+fleetSrp;webhookPingTextContent+="\n**SRP:** "+fleetSrp;}if(additionalInformation!==""){pingText+="\n\n**Additional Information**:\n"+additionalInformation;webhookPingTextContent+="\n\n**Additional Information**:\n"+additionalInformation;}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").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"?"
":"
";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('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp;return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").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 From a5c0dfbcb980ba6950e229951d882e10cec79761 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Wed, 23 Sep 2020 21:57:46 +0200 Subject: [PATCH 02/13] unused lib removed --- fleetpings/templates/fleetpings/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/fleetpings/templates/fleetpings/index.html b/fleetpings/templates/fleetpings/index.html index 5a3d1bad..b54a96e9 100644 --- a/fleetpings/templates/fleetpings/index.html +++ b/fleetpings/templates/fleetpings/index.html @@ -1,7 +1,6 @@ {% extends 'fleetpings/base.html' %} {% load i18n %} -{% load humanize %} {% load static %} {% block details %} From 14ea4706c6c924379db1f289b7fb987b9a2c6c07 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 26 Sep 2020 18:00:14 +0200 Subject: [PATCH 03/13] added some filter to the admin backend --- fleetpings/admin.py | 170 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 155 insertions(+), 15 deletions(-) diff --git a/fleetpings/admin.py b/fleetpings/admin.py index da25d0b6..48566883 100644 --- a/fleetpings/admin.py +++ b/fleetpings/admin.py @@ -3,6 +3,7 @@ """ settings for the admin backend """ + from fleetpings.form import FleetTypeAdminForm from fleetpings.models import ( FleetComm, @@ -16,15 +17,32 @@ from django.contrib import admin +def custom_filter_title(title): + class Wrapper(admin.FieldListFilter): + def __new__(cls, *args, **kwargs): + instance = admin.FieldListFilter.create(*args, **kwargs) + instance.title = title + + return instance + + return Wrapper + + @admin.register(FleetComm) class FleetCommAdmin(admin.ModelAdmin): """ FleetCommAdmin """ - list_display = ("name", "notes", "is_enabled") - list_filter = ("is_enabled",) + list_display = ("_name", "notes", "is_enabled") ordering = ("name",) + list_filter = ("is_enabled",) + + def _name(self, obj): + return obj.name + + _name.short_description = "Fleet Comms" + _name.admin_order_field = "name" @admin.register(FleetDoctrine) @@ -33,11 +51,38 @@ class FleetDoctrineAdmin(admin.ModelAdmin): FleetDoctrineAdmin """ - list_display = ("name", "link", "notes", "is_enabled") - list_filter = ("is_enabled",) + list_display = ("_name", "_link", "_restricted_to_group", "notes", "is_enabled") filter_horizontal = ("restricted_to_group",) ordering = ("name",) + list_filter = ( + ("is_enabled", custom_filter_title("active")), + ("restricted_to_group", custom_filter_title("restriction")), + ) + + def _name(self, obj): + return obj.name + + _name.short_description = "Doctrine" + _name.admin_order_field = "name" + + def _link(self, obj): + return obj.name + + _link.short_description = "Doctrine Link" + _link.admin_order_field = "link" + + def _restricted_to_group(self, obj): + names = [x.name for x in obj.restricted_to_group.all().order_by("name")] + + if names: + return ", ".join(names) + else: + return None + + _restricted_to_group.short_description = "Restricted to" + _restricted_to_group.admin_order_field = "restricted_to_group__name" + @admin.register(FormupLocation) class FormupLocationAdmin(admin.ModelAdmin): @@ -46,8 +91,8 @@ class FormupLocationAdmin(admin.ModelAdmin): """ list_display = ("name", "notes", "is_enabled") - list_filter = ("is_enabled",) ordering = ("name",) + list_filter = ("is_enabled",) @admin.register(DiscordPingTargets) @@ -56,11 +101,40 @@ class DiscordPingTargetsAdmin(admin.ModelAdmin): DiscordPingTargetsAdmin """ - list_display = ("name", "discord_id", "notes", "is_enabled") - list_filter = ("is_enabled",) - ordering = ("name",) + list_display = ( + "_name", + "discord_id", + "_restricted_to_group", + "notes", + "is_enabled", + ) + filter_horizontal = ("restricted_to_group",) readonly_fields = ("discord_id",) + ordering = ("name",) + + list_filter = ( + ("is_enabled", custom_filter_title("active")), + ("name", custom_filter_title("target")), + ("restricted_to_group", custom_filter_title("restriction")), + ) + + def _name(self, obj): + return obj.name + + _name.short_description = "Ping Target" + _name.admin_order_field = "name" + + def _restricted_to_group(self, obj): + names = [x.name for x in obj.restricted_to_group.all().order_by("name")] + + if names: + return ", ".join(names) + else: + return None + + _restricted_to_group.short_description = "Restricted to" + _restricted_to_group.admin_order_field = "restricted_to_group__name" @admin.register(FleetType) @@ -70,11 +144,40 @@ class FleetTypeAdmin(admin.ModelAdmin): """ form = FleetTypeAdminForm - list_display = ("name", "embed_color", "notes", "is_enabled") - list_filter = ("is_enabled",) + + list_display = ( + "_name", + "embed_color", + "_restricted_to_group", + "notes", + "is_enabled", + ) + filter_horizontal = ("restricted_to_group",) ordering = ("name",) + list_filter = ( + ("is_enabled", custom_filter_title("active")), + ("restricted_to_group", custom_filter_title("restriction")), + ) + + def _name(self, obj): + return obj.name + + _name.short_description = "Fleet Type" + _name.admin_order_field = "name" + + def _restricted_to_group(self, obj): + names = [x.name for x in obj.restricted_to_group.all().order_by("name")] + + if names: + return ", ".join(names) + else: + return None + + _restricted_to_group.short_description = "Restricted to" + _restricted_to_group.admin_order_field = "restricted_to_group__name" + @admin.register(Webhook) class WebhookAdmin(admin.ModelAdmin): @@ -84,13 +187,50 @@ class WebhookAdmin(admin.ModelAdmin): list_display = ( # "id", - "name", - "type", - "url", + "_name", + "_type", + "_url", + "_restricted_to_group", "notes", "is_embedded", "is_enabled", ) - list_filter = ("is_enabled",) - ordering = ("name",) + filter_horizontal = ("restricted_to_group",) + ordering = ("name",) + + list_filter = ( + ("is_enabled", custom_filter_title("active")), + ("is_embedded", custom_filter_title("embedded")), + ("type", custom_filter_title("webhook type")), + ("restricted_to_group", custom_filter_title("restriction")), + ) + + def _name(self, obj): + return obj.name + + _name.short_description = "Channel Name" + _name.admin_order_field = "name" + + def _type(self, obj): + return obj.type + + _type.short_description = "Webhook Type" + _type.admin_order_field = "type" + + def _url(self, obj): + return obj.url + + _url.short_description = "Webhook URL" + _url.admin_order_field = "url" + + def _restricted_to_group(self, obj): + names = [x.name for x in obj.restricted_to_group.all().order_by("name")] + + if names: + return ", ".join(names) + else: + return None + + _restricted_to_group.short_description = "Restricted to" + _restricted_to_group.admin_order_field = "restricted_to_group__name" From b3ea2d197cfc752d2b3a0c26e2dc007a15af3b33 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 26 Sep 2020 18:01:13 +0200 Subject: [PATCH 04/13] changelog updated --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 681ad80c..693b7849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [2.2.3] - xxxx-xx-xx + +### Added + +- Filter to the admin backend + + ## [2.2.2] - 2020-09-23 ### Added From fa3e8f36ccf988b1436e7228b0280e74cf3af340 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 26 Sep 2020 18:41:35 +0200 Subject: [PATCH 05/13] Added a couple of checks to the Discord ping target model --- fleetpings/app_settings.py | 10 ++++- fleetpings/models.py | 86 ++++++++++++++++++++++++++++++-------- 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/fleetpings/app_settings.py b/fleetpings/app_settings.py index e9ab407e..54e0bcd0 100644 --- a/fleetpings/app_settings.py +++ b/fleetpings/app_settings.py @@ -53,7 +53,15 @@ def fittings_installed() -> bool: def avoid_cdn() -> bool: """ - check if we should avpiod CDN usage + 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 "allianceauth.services.modules.discord" in settings.INSTALLED_APPS diff --git a/fleetpings/models.py b/fleetpings/models.py index 47f2c05b..edfe2d23 100644 --- a/fleetpings/models.py +++ b/fleetpings/models.py @@ -10,15 +10,22 @@ from django.db import models from django.utils.translation import gettext_lazy as _ - from allianceauth.services.modules.discord.models import DiscordUser +from requests.exceptions import HTTPError + +from fleetpings.app_settings import discord_service_installed + class AaFleetpings(models.Model): - """Meta model for app permissions""" + """ + Meta model for app permissions + """ class Meta: - """AaFleetpings :: Meta""" + """ + AaFleetpings :: Meta + """ managed = False default_permissions = () @@ -27,7 +34,9 @@ class Meta: # FleetComm Model class FleetComm(models.Model): - """Fleet Comms""" + """ + Fleet Comms + """ name = models.CharField( max_length=255, unique=True, help_text=_("Short name to identify this comms") @@ -53,7 +62,9 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" class Meta: - """FleetComm :: Meta""" + """ + FleetComm :: Meta + """ verbose_name = _("Fleet Comm") verbose_name_plural = _("Fleet Comms") @@ -62,7 +73,9 @@ class Meta: # FleetDoctrine Model class FleetDoctrine(models.Model): - """Fleet Doctrine""" + """ + Fleet Doctrine + """ # doctrine name name = models.CharField( @@ -105,9 +118,12 @@ def clean(self, *args, **kwargs): :param args: :param kwargs: """ + doctrine_link = self.link + if doctrine_link != "": validate = URLValidator() + try: validate(doctrine_link) except ValidationError as exception: @@ -124,7 +140,9 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" class Meta: - """FleetDoctrine :: Meta""" + """ + FleetDoctrine :: Meta + """ verbose_name = _("Fleet Doctrine") verbose_name_plural = _("Fleet Doctrines") @@ -133,7 +151,9 @@ class Meta: # FormupLocation Model class FormupLocation(models.Model): - """Formup Location""" + """ + Formup Location + """ # formup location name name = models.CharField( @@ -164,7 +184,9 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" class Meta: - """FormupLocation :: Meta""" + """ + FormupLocation :: Meta + """ verbose_name = _("Formup Location") verbose_name_plural = _("Formup Locations") @@ -173,7 +195,9 @@ class Meta: # DiscordPingTargets Model class DiscordPingTargets(models.Model): - """Discord Ping Targets""" + """ + Discord Ping Targets + """ # discord group to ping name = models.OneToOneField( @@ -226,10 +250,25 @@ def clean(self, *args, **kwargs): :param args: :param kwargs: """ - discord_group_info = DiscordUser.objects.group_to_role(self.name) - if not discord_group_info: - raise ValidationError(_("This group has not been synched to Discord yet.")) + # check if the Discord service is active + if not discord_service_installed(): + raise ValidationError( + _("You might want to install the Discord service first ...") + ) + + # get the group id from Discord + try: + discord_group_info = DiscordUser.objects.group_to_role(self.name) + except HTTPError: + raise ValidationError( + _("Are you sure you have your Discord linked to your Alliance Auth?") + ) + else: + if not discord_group_info: + raise ValidationError( + _("This group has not been synched to Discord yet.") + ) super().clean(*args, **kwargs) @@ -239,6 +278,7 @@ def save(self, *args, **kwargs): :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. @@ -257,7 +297,9 @@ def __repr__(self) -> str: ) class Meta: - """DiscordPingTargets :: Meta""" + """ + DiscordPingTargets :: Meta + """ verbose_name = _("Discord Ping Target") verbose_name_plural = _("Discord Ping Targets") @@ -266,7 +308,9 @@ class Meta: # FleetType Model class FleetType(models.Model): - """Fleet Types""" + """ + Fleet Types + """ # name of the fleet type name = models.CharField( @@ -312,7 +356,9 @@ def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" class Meta: - """FleetType :: Meta""" + """ + FleetType :: Meta + """ verbose_name = _("Fleet Type") verbose_name_plural = _("Fleet Types") @@ -321,7 +367,9 @@ class Meta: # Webhook Model class Webhook(models.Model): - """A Discord or Slack webhook""" + """ + A Discord or Slack webhook + """ # webhook type choices WEBHOOK_TYPE_DISCORD = "Discord" @@ -410,7 +458,9 @@ def __repr__(self) -> str: ) class Meta: - """Webhook :: Meta""" + """ + Webhook :: Meta + """ verbose_name = _("Webhook") verbose_name_plural = _("Webhooks") From f18d174e22e54728b4c43ff66fa9cea3a5f6b0f0 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Tue, 29 Sep 2020 12:08:17 +0200 Subject: [PATCH 06/13] use bundled clipboard.js --- fleetpings/templates/fleetpings/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fleetpings/templates/fleetpings/index.html b/fleetpings/templates/fleetpings/index.html index b54a96e9..ece70302 100644 --- a/fleetpings/templates/fleetpings/index.html +++ b/fleetpings/templates/fleetpings/index.html @@ -29,7 +29,7 @@ {% block extra_javascript %} {% include 'bundles/jquery-datetimepicker-js.html' %} - {% include 'fleetpings/bundles/clipboard-js.html' %} + {% include 'bundles/clipboard-js.html' %} {% endblock %} From 2b599e704609756e60b9d1bb4a74a416e7ee2425 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Tue, 29 Sep 2020 12:10:55 +0200 Subject: [PATCH 07/13] set new minimum AA version due to use of bundled clipboard.js --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 8a6c9bde..1a16695b 100644 --- a/setup.py +++ b/setup.py @@ -48,5 +48,5 @@ "Topic :: Internet :: WWW/HTTP :: Dynamic Content", ], python_requires="~=3.6", - install_requires=["allianceauth>=2.7.4"], + install_requires=["allianceauth>=2.8.0"], ) From ce201e37dd25aed9d325ed97f5b14c84bfc4d3d2 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 3 Oct 2020 15:13:45 +0200 Subject: [PATCH 08/13] [FIX] mySQL text fields can't have default values --- fleetpings/migrations/0001_initial.py | 6 -- ...ysql8_default_value_fixes_20201003_1232.py | 67 +++++++++++++++++++ fleetpings/models.py | 6 -- 3 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 fleetpings/migrations/0007_mysql8_default_value_fixes_20201003_1232.py diff --git a/fleetpings/migrations/0001_initial.py b/fleetpings/migrations/0001_initial.py index cc9cf063..62f11266 100644 --- a/fleetpings/migrations/0001_initial.py +++ b/fleetpings/migrations/0001_initial.py @@ -56,7 +56,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this configuration here if you want", null=True, ), @@ -100,7 +99,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this configuration here if you want", null=True, ), @@ -152,7 +150,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this configuration here if you want", null=True, ), @@ -196,7 +193,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this configuration here if you want", null=True, ), @@ -265,7 +261,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this webhook here if you want", null=True, ), @@ -318,7 +313,6 @@ class Migration(migrations.Migration): "notes", models.TextField( blank=True, - default=None, help_text="You can add notes about this configuration here if you want", null=True, ), diff --git a/fleetpings/migrations/0007_mysql8_default_value_fixes_20201003_1232.py b/fleetpings/migrations/0007_mysql8_default_value_fixes_20201003_1232.py new file mode 100644 index 00000000..d389f70d --- /dev/null +++ b/fleetpings/migrations/0007_mysql8_default_value_fixes_20201003_1232.py @@ -0,0 +1,67 @@ +# Generated by Django 3.1.1 on 2020-10-03 12:32 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("fleetpings", "0006_fleetdoctrine_restricted_to_group"), + ] + + operations = [ + migrations.AlterField( + model_name="discordpingtargets", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this configuration here if you want", + null=True, + ), + ), + migrations.AlterField( + model_name="fleetcomm", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this configuration here if you want", + null=True, + ), + ), + migrations.AlterField( + model_name="fleetdoctrine", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this configuration here if you want", + null=True, + ), + ), + migrations.AlterField( + model_name="fleettype", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this configuration here if you want", + null=True, + ), + ), + migrations.AlterField( + model_name="formuplocation", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this configuration here if you want", + null=True, + ), + ), + migrations.AlterField( + model_name="webhook", + name="notes", + field=models.TextField( + blank=True, + help_text="You can add notes about this webhook here if you want", + null=True, + ), + ), + ] diff --git a/fleetpings/models.py b/fleetpings/models.py index edfe2d23..1e49174c 100644 --- a/fleetpings/models.py +++ b/fleetpings/models.py @@ -44,7 +44,6 @@ class FleetComm(models.Model): notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this configuration here if you want"), ) @@ -100,7 +99,6 @@ class FleetDoctrine(models.Model): # doctrine notes notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this configuration here if you want"), ) @@ -165,7 +163,6 @@ class FormupLocation(models.Model): # formup location notes notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this configuration here if you want"), ) @@ -231,7 +228,6 @@ class DiscordPingTargets(models.Model): # notes notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this configuration here if you want"), ) @@ -337,7 +333,6 @@ class FleetType(models.Model): # fleet type notes notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this configuration here if you want"), ) @@ -430,7 +425,6 @@ class Webhook(models.Model): # webhook notes notes = models.TextField( null=True, - default=None, blank=True, help_text=_("You can add notes about this webhook here if you want"), ) From fb8ea7998666d7218195498e756b54343caec160 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 3 Oct 2020 16:11:43 +0200 Subject: [PATCH 09/13] some code optimizations and improvements --- fleetpings/__init__.py | 2 +- fleetpings/admin.py | 70 ++++++++++++++++++++++++++-------------- fleetpings/auth_hooks.py | 2 +- fleetpings/form.py | 2 +- fleetpings/models.py | 18 +++++------ fleetpings/urls.py | 2 +- fleetpings/utils.py | 6 ++-- 7 files changed, 62 insertions(+), 40 deletions(-) diff --git a/fleetpings/__init__.py b/fleetpings/__init__.py index 0be5191e..f948df5a 100644 --- a/fleetpings/__init__.py +++ b/fleetpings/__init__.py @@ -4,7 +4,7 @@ a couple of variable to use throughout the app """ -default_app_config = "fleetpings.apps.AaFleetpingsConfig" +default_app_config: str = "fleetpings.apps.AaFleetpingsConfig" __version__ = "2.2.2" __title__ = "Fleet Pings" diff --git a/fleetpings/admin.py b/fleetpings/admin.py index 48566883..f4bb42b4 100644 --- a/fleetpings/admin.py +++ b/fleetpings/admin.py @@ -17,8 +17,18 @@ from django.contrib import admin -def custom_filter_title(title): +def custom_filter(title): + """ + custom filter for model properties + :param title: + :return: + """ + class Wrapper(admin.FieldListFilter): + """ + custom_filter :: wrapper + """ + def __new__(cls, *args, **kwargs): instance = admin.FieldListFilter.create(*args, **kwargs) instance.title = title @@ -38,7 +48,8 @@ class FleetCommAdmin(admin.ModelAdmin): ordering = ("name",) list_filter = ("is_enabled",) - def _name(self, obj): + @classmethod + def _name(cls, obj): return obj.name _name.short_description = "Fleet Comms" @@ -56,23 +67,26 @@ class FleetDoctrineAdmin(admin.ModelAdmin): ordering = ("name",) list_filter = ( - ("is_enabled", custom_filter_title("active")), - ("restricted_to_group", custom_filter_title("restriction")), + ("is_enabled", custom_filter(title="active")), + ("restricted_to_group", custom_filter(title="restriction")), ) - def _name(self, obj): + @classmethod + def _name(cls, obj): return obj.name _name.short_description = "Doctrine" _name.admin_order_field = "name" - def _link(self, obj): + @classmethod + def _link(cls, obj): return obj.name _link.short_description = "Doctrine Link" _link.admin_order_field = "link" - def _restricted_to_group(self, obj): + @classmethod + def _restricted_to_group(cls, obj): names = [x.name for x in obj.restricted_to_group.all().order_by("name")] if names: @@ -114,18 +128,20 @@ class DiscordPingTargetsAdmin(admin.ModelAdmin): ordering = ("name",) list_filter = ( - ("is_enabled", custom_filter_title("active")), - ("name", custom_filter_title("target")), - ("restricted_to_group", custom_filter_title("restriction")), + ("is_enabled", custom_filter(title="active")), + ("name", custom_filter(title="target")), + ("restricted_to_group", custom_filter(title="restriction")), ) - def _name(self, obj): + @classmethod + def _name(cls, obj): return obj.name _name.short_description = "Ping Target" _name.admin_order_field = "name" - def _restricted_to_group(self, obj): + @classmethod + def _restricted_to_group(cls, obj): names = [x.name for x in obj.restricted_to_group.all().order_by("name")] if names: @@ -157,17 +173,19 @@ class FleetTypeAdmin(admin.ModelAdmin): ordering = ("name",) list_filter = ( - ("is_enabled", custom_filter_title("active")), - ("restricted_to_group", custom_filter_title("restriction")), + ("is_enabled", custom_filter(title="active")), + ("restricted_to_group", custom_filter(title="restriction")), ) - def _name(self, obj): + @classmethod + def _name(cls, obj): return obj.name _name.short_description = "Fleet Type" _name.admin_order_field = "name" - def _restricted_to_group(self, obj): + @classmethod + def _restricted_to_group(cls, obj): names = [x.name for x in obj.restricted_to_group.all().order_by("name")] if names: @@ -200,31 +218,35 @@ class WebhookAdmin(admin.ModelAdmin): ordering = ("name",) list_filter = ( - ("is_enabled", custom_filter_title("active")), - ("is_embedded", custom_filter_title("embedded")), - ("type", custom_filter_title("webhook type")), - ("restricted_to_group", custom_filter_title("restriction")), + ("is_enabled", custom_filter(title="active")), + ("is_embedded", custom_filter(title="embedded")), + ("type", custom_filter(title="webhook type")), + ("restricted_to_group", custom_filter(title="restriction")), ) - def _name(self, obj): + @classmethod + def _name(cls, obj): return obj.name _name.short_description = "Channel Name" _name.admin_order_field = "name" - def _type(self, obj): + @classmethod + def _type(cls, obj): return obj.type _type.short_description = "Webhook Type" _type.admin_order_field = "type" - def _url(self, obj): + @classmethod + def _url(cls, obj): return obj.url _url.short_description = "Webhook URL" _url.admin_order_field = "url" - def _restricted_to_group(self, obj): + @classmethod + def _restricted_to_group(cls, obj): names = [x.name for x in obj.restricted_to_group.all().order_by("name")] if names: diff --git a/fleetpings/auth_hooks.py b/fleetpings/auth_hooks.py index a744e741..f816df32 100644 --- a/fleetpings/auth_hooks.py +++ b/fleetpings/auth_hooks.py @@ -12,7 +12,7 @@ from . import urls, __title__ -class AaFleetpingsMenuItem(MenuItemHook): +class AaFleetpingsMenuItem(MenuItemHook): # pylint: disable=too-few-public-methods """ This class ensures only authorized users will see the menu entry """ def __init__(self): diff --git a/fleetpings/form.py b/fleetpings/form.py index 6bf2943a..065e5c84 100644 --- a/fleetpings/form.py +++ b/fleetpings/form.py @@ -13,7 +13,7 @@ class FleetTypeAdminForm(ModelForm): form definitions for the FleetType form in admin """ - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ Meta """ diff --git a/fleetpings/models.py b/fleetpings/models.py index 1e49174c..7e153b5e 100644 --- a/fleetpings/models.py +++ b/fleetpings/models.py @@ -10,19 +10,19 @@ from django.db import models from django.utils.translation import gettext_lazy as _ -from allianceauth.services.modules.discord.models import DiscordUser - from requests.exceptions import HTTPError from fleetpings.app_settings import discord_service_installed +from allianceauth.services.modules.discord.models import DiscordUser + class AaFleetpings(models.Model): """ Meta model for app permissions """ - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ AaFleetpings :: Meta """ @@ -60,7 +60,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ FleetComm :: Meta """ @@ -137,7 +137,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ FleetDoctrine :: Meta """ @@ -180,7 +180,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ FormupLocation :: Meta """ @@ -292,7 +292,7 @@ def __repr__(self) -> str: f") " ) - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ DiscordPingTargets :: Meta """ @@ -350,7 +350,7 @@ def __str__(self) -> str: def __repr__(self) -> str: return f"{self.__class__.__name__}(id={self.id}, name='{self.name}')" - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ FleetType :: Meta """ @@ -451,7 +451,7 @@ def __repr__(self) -> str: f")" ) - class Meta: + class Meta: # pylint: disable=too-few-public-methods """ Webhook :: Meta """ diff --git a/fleetpings/urls.py b/fleetpings/urls.py index 820a33b6..f4f181e7 100644 --- a/fleetpings/urls.py +++ b/fleetpings/urls.py @@ -9,7 +9,7 @@ from . import views -app_name = "fleetpings" +app_name: str = "fleetpings" urlpatterns = [ path("", views.index, name="index"), diff --git a/fleetpings/utils.py b/fleetpings/utils.py index f7ec43e2..9002de2d 100644 --- a/fleetpings/utils.py +++ b/fleetpings/utils.py @@ -46,9 +46,9 @@ def clean_setting( ): cleaned_value = getattr(settings, name) else: - logger.warn( - "You setting for {} is not valid. Please correct it. " - "Using default for now: {}".format(name, default_value) + logger.warning( + "You setting for {name} is not valid. Please correct it. " + "Using default for now: {value}".format(name=name, value=default_value) ) cleaned_value = default_value From 280da73be9bda9bfa71fd42a90b675686ab35da2 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 3 Oct 2020 16:56:14 +0200 Subject: [PATCH 10/13] english .po file added as template for transiflex --- fleetpings/locale/en/LC_MESSAGES/django.po | 329 +++++++++++++++++++++ 1 file changed, 329 insertions(+) create mode 100644 fleetpings/locale/en/LC_MESSAGES/django.po diff --git a/fleetpings/locale/en/LC_MESSAGES/django.po b/fleetpings/locale/en/LC_MESSAGES/django.po new file mode 100644 index 00000000..facc4487 --- /dev/null +++ b/fleetpings/locale/en/LC_MESSAGES/django.po @@ -0,0 +1,329 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-10-03 16:54+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +#: fleetpings/models.py:42 +msgid "Short name to identify this comms" +msgstr "" + +#: fleetpings/models.py:48 fleetpings/models.py:103 fleetpings/models.py:167 +#: fleetpings/models.py:232 fleetpings/models.py:337 +msgid "You can add notes about this configuration here if you want" +msgstr "" + +#: fleetpings/models.py:54 +msgid "Whether this comms is enabled or not" +msgstr "" + +#: fleetpings/models.py:68 +msgid "Fleet Comm" +msgstr "" + +#: fleetpings/models.py:69 +#: fleetpings/templates/fleetpings/form/fleetComms.html:4 +msgid "Fleet Comms" +msgstr "" + +#: fleetpings/models.py:81 +msgid "Short name to identify this doctrine" +msgstr "" + +#: fleetpings/models.py:87 +msgid "A link to a doctrine page for this doctrine if you have." +msgstr "" + +#: fleetpings/models.py:96 +msgid "Restrict this doctrine to the following group(s) ..." +msgstr "" + +#: fleetpings/models.py:110 +msgid "Whether this doctrine is enabled or not" +msgstr "" + +#: fleetpings/models.py:129 +msgid "Your doctrine URL is not valid." +msgstr "" + +#: fleetpings/models.py:145 +msgid "Fleet Doctrine" +msgstr "" + +#: fleetpings/models.py:146 +msgid "Fleet Doctrines" +msgstr "" + +#: fleetpings/models.py:160 +msgid "Short name to identify this formup location" +msgstr "" + +#: fleetpings/models.py:174 fleetpings/models.py:239 +msgid "Whether this formup location is enabled or not" +msgstr "" + +#: fleetpings/models.py:188 +#: fleetpings/templates/fleetpings/form/formupLocation.html:4 +msgid "Formup Location" +msgstr "" + +#: fleetpings/models.py:189 +msgid "Formup Locations" +msgstr "" + +#: fleetpings/models.py:206 +msgid "" +"Name of the Discord role to ping. (Note: This must be an Auth group that is " +"synched to Discord.)" +msgstr "" + +#: fleetpings/models.py:217 +msgid "ID of the Discord role to ping" +msgstr "" + +#: fleetpings/models.py:225 fleetpings/models.py:422 +msgid "Restrict ping rights to the following group(s) ..." +msgstr "" + +#: fleetpings/models.py:253 +msgid "You might want to install the Discord service first ..." +msgstr "" + +#: fleetpings/models.py:261 +msgid "Are you sure you have your Discord linked to your Alliance Auth?" +msgstr "" + +#: fleetpings/models.py:266 +msgid "This group has not been synched to Discord yet." +msgstr "" + +#: fleetpings/models.py:300 +msgid "Discord Ping Target" +msgstr "" + +#: fleetpings/models.py:301 +msgid "Discord Ping Targets" +msgstr "" + +#: fleetpings/models.py:315 +msgid "Short name to identify this fleet type" +msgstr "" + +#: fleetpings/models.py:322 +msgid "Hightlight color for the embed" +msgstr "" + +#: fleetpings/models.py:330 +msgid "Restrict this fleet type to the following group(s) ..." +msgstr "" + +#: fleetpings/models.py:344 +msgid "Whether this fleet type is enabled or not" +msgstr "" + +#: fleetpings/models.py:358 +#: fleetpings/templates/fleetpings/form/fleetType.html:4 +msgid "Fleet Type" +msgstr "" + +#: fleetpings/models.py:359 +msgid "Fleet Types" +msgstr "" + +#: fleetpings/models.py:382 +msgid "Is this a Discord or Slack webhook?" +msgstr "" + +#: fleetpings/models.py:389 +msgid "Name of the channel this webhook posts to" +msgstr "" + +#: fleetpings/models.py:398 +msgid "" +"URL of this webhook, e.g. https://discordapp.com/api/webhooks/123456/abcdef " +"or https://hooks.slack.com/services/xxxx/xxxx" +msgstr "" + +#: fleetpings/models.py:411 +msgid "" +"Whether this webhook's ping is embedded or not. (This setting only effects " +"Discord webhooks.)" +msgstr "" + +#: fleetpings/models.py:429 +msgid "You can add notes about this webhook here if you want" +msgstr "" + +#: fleetpings/models.py:436 +msgid "Whether this webhook is active or not" +msgstr "" + +#: fleetpings/models.py:459 +msgid "Webhook" +msgstr "" + +#: fleetpings/models.py:460 +msgid "Webhooks" +msgstr "" + +#: fleetpings/templates/fleetpings/base.html:5 +#: fleetpings/templates/fleetpings/base.html:9 +msgid "Fleet Ping Tool" +msgstr "" + +#: fleetpings/templates/fleetpings/form.html:43 +msgid "Create Ping" +msgstr "" + +#: fleetpings/templates/fleetpings/form/additionalInformation.html:4 +msgid "Additional Information" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetCommander.html:4 +msgid "FC Name" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetDoctrine.html:4 +msgid "Ships / Doctrine" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetName.html:4 +msgid "Fleet Name" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:7 +#: fleetpings/templates/fleetpings/form/srp.html:7 +msgid "Please select" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:8 +msgid "Roaming Fleet" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:9 +msgid "Home Defense" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:10 +msgid "StratOP" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:11 +msgid "CTA" +msgstr "" + +#: fleetpings/templates/fleetpings/form/fleetType.html:15 +msgid "Additionally configured fleet types" +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:4 +msgid "Formup Time" +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:4 +msgid "This is Eve Time" +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:7 +msgid "" +"To enable this field, either make it a Pre-Ping (checkbox above) or uncheck " +""Formup NOW" (checkbox below)." +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:9 +msgid "" +"Timezones module is installed. Link to time zone conversion will be added " +"automatically if you set a date and time here." +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:14 +msgid "Formup NOW" +msgstr "" + +#: fleetpings/templates/fleetpings/form/formupTime.html:15 +msgid "" +"If this checkbox is active, formup time will be set to "NOW" and " +"the time in the field above (if any is set) will be ignored." +msgstr "" + +#: fleetpings/templates/fleetpings/form/pingChannel.html:5 +msgid "Ping Channel" +msgstr "" + +#: fleetpings/templates/fleetpings/form/pingChannel.html:5 +msgid "Select a channel to ping it automatically" +msgstr "" + +#: fleetpings/templates/fleetpings/form/pingChannel.html:8 +msgid "None, just format it for me" +msgstr "" + +#: fleetpings/templates/fleetpings/form/pingTargets.html:4 +msgid "Ping Target" +msgstr "" + +#: fleetpings/templates/fleetpings/form/pingTargets.html:17 +msgid "Additionally configured ping targets" +msgstr "" + +#: fleetpings/templates/fleetpings/form/prePing.html:8 +msgid "Pre-Ping" +msgstr "" + +#: fleetpings/templates/fleetpings/form/srp.html:4 +msgid "SRP" +msgstr "" + +#: fleetpings/templates/fleetpings/form/srp.html:8 +msgid "Yes" +msgstr "" + +#: fleetpings/templates/fleetpings/form/srp.html:9 +msgid "No" +msgstr "" + +#: fleetpings/templates/fleetpings/index.html:19 +#, python-format +msgctxt "" +"%(usedPlatform)s is a variable that holds the current used platform. It can " +"be either Slack or Discord. Do not translate it, just use it as it is." +msgid "Success! Your ping has been sent to your %(platformUsed)s." +msgstr "" + +#: fleetpings/templates/fleetpings/index.html:22 +msgid "" +"Error! Your ping was not copied to your clipboard. Maybe your browser " +"doesn't support this feature." +msgstr "" + +#: fleetpings/templates/fleetpings/index.html:23 +#, python-format +msgctxt "" +"%(usedPlatform)s is a variable that holds the current used platform. It can " +"be either Slack or Discord. Do not translate it, just use it as it is." +msgid "" +"Success! Your ping text has been copied to your clipboard. Now be a good FC " +"and throw it in your %(platformUsed)s so you actually get some people in " +"fleet." +msgstr "" + +#: fleetpings/templates/fleetpings/ping.html:5 +msgid "Formatted Ping Text" +msgstr "" + +#: fleetpings/templates/fleetpings/ping.html:13 +msgid "Copy Ping Text" +msgstr "" From a05d5d9c34ca0f13e1628a6f7ece880db7c4eff4 Mon Sep 17 00:00:00 2001 From: "transifex-integration[bot]" <43880903+transifex-integration[bot]@users.noreply.github.com> Date: Sat, 3 Oct 2020 15:09:33 +0000 Subject: [PATCH 11/13] Apply translations in de translation completed updated for the source file '/fleetpings/locale/en/LC_MESSAGES/django.po' on the 'de' language. --- fleetpings/locale/de/LC_MESSAGES/django.po | 125 +++++++++++---------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/fleetpings/locale/de/LC_MESSAGES/django.po b/fleetpings/locale/de/LC_MESSAGES/django.po index 04d8b758..6c86ed8e 100644 --- a/fleetpings/locale/de/LC_MESSAGES/django.po +++ b/fleetpings/locale/de/LC_MESSAGES/django.po @@ -1,95 +1,94 @@ -# AA Fleet Pings +# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , 2020. -# +# FIRST AUTHOR , YEAR. +# +# Translators: +# Rounon Dax , 2020 +# +#, fuzzy msgid "" msgstr "" -"Project-Id-Version: \n" +"Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-09-16 20:37+0200\n" -"PO-Revision-Date: 2020-09-16 20:37+0200\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: de\n" +"POT-Creation-Date: 2020-10-03 16:54+0200\n" +"PO-Revision-Date: 2020-10-03 14:49+0000\n" +"Last-Translator: Rounon Dax , 2020\n" +"Language-Team: German (https://www.transifex.com/ppfeufer/teams/113732/de/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"Language: de\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 2.2.4\n" - -#: fleetpings/__init__.py:12 -msgid "Fleet Pings" -msgstr "Flottenankündigungen" -#: fleetpings/models.py:33 +#: fleetpings/models.py:42 msgid "Short name to identify this comms" msgstr "Name der Flotten Comms" -#: fleetpings/models.py:40 fleetpings/models.py:92 fleetpings/models.py:150 -#: fleetpings/models.py:212 fleetpings/models.py:298 +#: fleetpings/models.py:48 fleetpings/models.py:103 fleetpings/models.py:167 +#: fleetpings/models.py:232 fleetpings/models.py:337 msgid "You can add notes about this configuration here if you want" msgstr "Du kannst Notizen zu dieser Konfiguration hinzufügen wenn Du magst" -#: fleetpings/models.py:46 +#: fleetpings/models.py:54 msgid "Whether this comms is enabled or not" msgstr "Flotten Comms aktiv oder nicht" -#: fleetpings/models.py:58 +#: fleetpings/models.py:68 msgid "Fleet Comm" msgstr "Flotten Comms" -#: fleetpings/models.py:59 +#: fleetpings/models.py:69 #: fleetpings/templates/fleetpings/form/fleetComms.html:4 msgid "Fleet Comms" msgstr "Flotten Comms" -#: fleetpings/models.py:69 +#: fleetpings/models.py:81 msgid "Short name to identify this doctrine" msgstr "Name der Doktrin" -#: fleetpings/models.py:75 +#: fleetpings/models.py:87 msgid "A link to a doctrine page for this doctrine if you have." msgstr "Link zur Doktrin Webseite falls vorhzanden." -#: fleetpings/models.py:84 +#: fleetpings/models.py:96 msgid "Restrict this doctrine to the following group(s) ..." msgstr "Beschränke diese Doktrin auf folgende Gruppe(n) ..." -#: fleetpings/models.py:99 +#: fleetpings/models.py:110 msgid "Whether this doctrine is enabled or not" msgstr "Ist diese Doktrin aktiv oder nicht" -#: fleetpings/models.py:115 +#: fleetpings/models.py:129 msgid "Your doctrine URL is not valid." msgstr "Der Link ist ungültig." -#: fleetpings/models.py:129 +#: fleetpings/models.py:145 msgid "Fleet Doctrine" msgstr "Schiffe / Doktrin" -#: fleetpings/models.py:130 +#: fleetpings/models.py:146 msgid "Fleet Doctrines" msgstr "Schiffe / Doktrinen" -#: fleetpings/models.py:142 +#: fleetpings/models.py:160 msgid "Short name to identify this formup location" msgstr "Name des Sammelpunktes. System - Station" -#: fleetpings/models.py:157 fleetpings/models.py:219 +#: fleetpings/models.py:174 fleetpings/models.py:239 msgid "Whether this formup location is enabled or not" msgstr "Sammelpunkt ist aktiv" -#: fleetpings/models.py:169 +#: fleetpings/models.py:188 #: fleetpings/templates/fleetpings/form/formupLocation.html:4 msgid "Formup Location" msgstr "Sammelpunkt" -#: fleetpings/models.py:170 +#: fleetpings/models.py:189 msgid "Formup Locations" msgstr "Sammelpunkte" -#: fleetpings/models.py:185 +#: fleetpings/models.py:206 msgid "" "Name of the Discord role to ping. (Note: This must be an Auth group that is " "synched to Discord.)" @@ -97,68 +96,77 @@ msgstr "" "Name der Discord Gruppe die gepingt werden soll. (Hinweis: Dies muss eine " "Auth Gruppe sein, welche zum Discord synchronisiert wurde.)" -#: fleetpings/models.py:196 +#: fleetpings/models.py:217 msgid "ID of the Discord role to ping" msgstr "ID der Rolle auf Discord" -#: fleetpings/models.py:204 fleetpings/models.py:379 +#: fleetpings/models.py:225 fleetpings/models.py:422 msgid "Restrict ping rights to the following group(s) ..." msgstr "Beschränke die Ping Rechte auf folgende Gruppe(n) ..." -#: fleetpings/models.py:232 +#: fleetpings/models.py:253 +msgid "You might want to install the Discord service first ..." +msgstr "Du solltest eventuell den Discord Service installieren ..." + +#: fleetpings/models.py:261 +msgid "Are you sure you have your Discord linked to your Alliance Auth?" +msgstr "Bist Du sicher das Du Dein Discord mit Alliance Auth verlinkt hast?" + +#: fleetpings/models.py:266 msgid "This group has not been synched to Discord yet." msgstr "Diese Gruppe wurde noch nicht zu Discord synchronisiert." -#: fleetpings/models.py:262 +#: fleetpings/models.py:300 msgid "Discord Ping Target" msgstr "Ping Ziel" -#: fleetpings/models.py:263 +#: fleetpings/models.py:301 msgid "Discord Ping Targets" msgstr "Ping Ziele" -#: fleetpings/models.py:275 +#: fleetpings/models.py:315 msgid "Short name to identify this fleet type" msgstr "Flotten Art" -#: fleetpings/models.py:282 +#: fleetpings/models.py:322 msgid "Hightlight color for the embed" msgstr "Hervorhebungsfarbe des Embed" -#: fleetpings/models.py:290 +#: fleetpings/models.py:330 msgid "Restrict this fleet type to the following group(s) ..." msgstr "Beschränke diese Flotten Art auf folgende Gruppe(n) ..." -#: fleetpings/models.py:305 +#: fleetpings/models.py:344 msgid "Whether this fleet type is enabled or not" msgstr "Flotten Art ist aktiv oder nicht" -#: fleetpings/models.py:317 +#: fleetpings/models.py:358 #: fleetpings/templates/fleetpings/form/fleetType.html:4 msgid "Fleet Type" msgstr "Flotten Art" -#: fleetpings/models.py:318 +#: fleetpings/models.py:359 msgid "Fleet Types" msgstr "Flotten Arten" -#: fleetpings/models.py:339 +#: fleetpings/models.py:382 msgid "Is this a Discord or Slack webhook?" msgstr "Ist dies ein Discord oder Slack Webhook?" -#: fleetpings/models.py:346 +#: fleetpings/models.py:389 msgid "Name of the channel this webhook posts to" msgstr "Name des Kanals an den der Webhook senden soll" -#: fleetpings/models.py:355 +#: fleetpings/models.py:398 msgid "" "URL of this webhook, e.g. https://discordapp.com/api/webhooks/123456/abcdef " "or https://hooks.slack.com/services/xxxx/xxxx" msgstr "" -"URL des Webhooks, zum Beispiel https://discordapp.com/api/webhooks/123456/" -"abcdef oder https://hooks.slack.com/services/xxxx/xxxx" +"URL des Webhooks, zum Beispiel " +"https://discordapp.com/api/webhooks/123456/abcdef oder " +"https://hooks.slack.com/services/xxxx/xxxx" -#: fleetpings/models.py:368 +#: fleetpings/models.py:411 msgid "" "Whether this webhook's ping is embedded or not. (This setting only effects " "Discord webhooks.)" @@ -166,19 +174,19 @@ msgstr "" "Soll der Ping als Embed gesendet werden? (Dies betrifft nur Discord " "Webhooks.)" -#: fleetpings/models.py:387 +#: fleetpings/models.py:429 msgid "You can add notes about this webhook here if you want" msgstr "Du kannst einige Notizen zu diesem Webhook hinzufügen, wenn Du magst" -#: fleetpings/models.py:394 +#: fleetpings/models.py:436 msgid "Whether this webhook is active or not" msgstr "Ist dieser Webhook aktiv oder nicht" -#: fleetpings/models.py:415 +#: fleetpings/models.py:459 msgid "Webhook" msgstr "Webhook" -#: fleetpings/models.py:416 +#: fleetpings/models.py:460 msgid "Webhooks" msgstr "Webhooks" @@ -265,8 +273,9 @@ msgid "" "If this checkbox is active, formup time will be set to "NOW" and " "the time in the field above (if any is set) will be ignored." msgstr "" -"Wenn diese Checkbox aktiv ist, wird die Startzeit der Flotte auf "" -"JETZT" gesetzt und sämtliche Angaben im obigen Feld werden ignoriert." +"Wenn diese Checkbox aktiv ist, wird die Startzeit der Flotte auf " +""JETZT" gesetzt und sämtliche Angaben im obigen Feld werden " +"ignoriert." #: fleetpings/templates/fleetpings/form/pingChannel.html:5 msgid "Ping Channel" @@ -304,7 +313,7 @@ msgstr "Ja" msgid "No" msgstr "Nein" -#: fleetpings/templates/fleetpings/index.html:20 +#: fleetpings/templates/fleetpings/index.html:19 #, python-format msgctxt "" "%(usedPlatform)s is a variable that holds the current used platform. It can " @@ -312,7 +321,7 @@ msgctxt "" msgid "Success! Your ping has been sent to your %(platformUsed)s." msgstr "Erfolg! Dein Ping wurde an Dein %(platformUsed)s gesendet." -#: fleetpings/templates/fleetpings/index.html:23 +#: fleetpings/templates/fleetpings/index.html:22 msgid "" "Error! Your ping was not copied to your clipboard. Maybe your browser " "doesn't support this feature." @@ -320,7 +329,7 @@ msgstr "" "Fehler! Der Ping wurde nicht in Deine Zwischenablage kopiert. Vielleicht " "unterstützt Dein Browser diese Funktion nicht." -#: fleetpings/templates/fleetpings/index.html:24 +#: fleetpings/templates/fleetpings/index.html:23 #, python-format msgctxt "" "%(usedPlatform)s is a variable that holds the current used platform. It can " From ace4feb03dd20221d96cfa209ca7c9796d6d0119 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 3 Oct 2020 21:18:53 +0200 Subject: [PATCH 12/13] German translation updated --- fleetpings/locale/de/LC_MESSAGES/django.mo | Bin 7197 -> 7534 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/fleetpings/locale/de/LC_MESSAGES/django.mo b/fleetpings/locale/de/LC_MESSAGES/django.mo index ec8a41221e7352c8e4551da2a58ff2062936e50a..b8f52f7cb11b6e9f3f654d8a90ab7130a425160d 100644 GIT binary patch delta 1836 zcmY+@ZD<@t9LMpwHfNfer%MxS6O)c@lP0G3m}?Wynuj)NP-0)yC=`iy$xZH-Tz13W zULIbQtK!28ZK0kO3l`Kjf^7vkL7^&CDT*KnBJl|Y8&Qf@5G|qze*fvIxZK=lW^Q+O z<~MU^2Ck-xUpG~qQe5MdTPTz3l(O)tD!#ZHZ&2zZ3}Gao)HgUlyMBXGH{m#L#|Lo- zK7zyeGOouTupWQJ8}U!vgw-`lH7iwAZB(*!#IPDq<3@ZD<$-f31H6e1_g_?Gc9%KcNsA`>%Mlz|;8JF$c^feRSH@30e_ z8FdO%C=-1S@4)AAH-3iwSRYbqD;~h(oRt|&(f+kbsk0bmUu5E6Vk=fRlfS%p8z(^~ zayRZr7v)7|{cijv6pC`nzz+wc#R6?bmAzL0)o zcho_Y1w4c@vDwP+#b>At&~X+eqE&npe@9u#Q8wxrHgeP@;*%(c=QMWUOSla$qQ+Gu zJQXCK?bwC~aR}vKa{^_HPvV%I=TE7~A!%z@iZImu$k|yt4;lw4s&u?+YoNJwzG`Sp z29Ht>Q1()WDG7?CCzmWj5{px0q71iojq@#$-$@CT;=#==lDllKT#}_Muc0&*?C+7S z8lmi@$R#_nixQ^vQY3M?no4g6dxMf|WBI4xE9-_wJfoN0g3cEzm8`X}*5m0>J3sAu zX`Qp3S(DbjD>r(2B$u--XWHnIf}b5KKf56mD3@!tR44VEoyq!o(Q>{2mCI>A zYyKT7Z@dMYM`vs=@9Rh;Qu?4VU5v-Vu|6G7rjob!#<(_4Sb0A@=~+%bXZfy|(udrF z<2riOTGD&HwR$9NEe-p|^Q^FAIj(P}vyrqJ+@%w-gbd(h3RcF1Cyh0i(&NUPvmD)> z_5JyLDjHo}T#WcKygg%tmK6?_AK%m&C|_(I zt3JdyZZ78=#xx7Y@e79J(&oRh?yV$ON!2zUKN6rC<>eEMsbxL|C-dH0Ip5Ai)ZciB BAt3+& delta 1488 zcmYk*Ylw_d9LMqhFk@YJXLo0<`#$c*+BFutYt}VcR%;{V#U=*RW5USp5Rp-CFG$&G zqhwLMA)+ayMJ_37ZORMYxW6Dp5~9fWx1JYHbLMl-d7g9opYwc*o~%y4DDbx$sg^v1 zT;I(shP(XyDfKYx03Vk7%sR1}`kx%L{#e!1Y$P_|C~U&+cnov#1opx6Scq3KgpY8& zS=wGwU@TkE%d9spMs;XJ4d7xPZu6cW@ajiV@1615FM9RssEO{Q`aQ!SzDJG!6V=a8 zWf=2YkV0P?CU!NLO~-@O8&NxZi>on*USV911j$-(Ft(!lUqOC$i@$#O2-%xG!wP(j zQ!vEKl~{-UnBVqLP{@v;CTKyexE+UM2P(9maSVnSy%cLuk#lh(ZbtPxh1>BmrZ7wx zcVHXp{Q-nU3v)27fx{HWVgqUc+pru@<7n)}mG}*{(51{$gDY?}o`wUZid5}UNS zo=Y&F`YPlV+kynm_IvFuSVa9SavF9cMEo_t0~&OjpL!2IqB{QY>VA4@AwkqvG6=QM zDja|du?5%SIQ)+Lv4lYt$#dw(r>IChM{Ve5nt}%Q7ynyGE)r!Mf|WP{r{G%DXLlSG znJ1`-y~6SM4z=?P1s961H6M(wl?wXo&h^W9iYJ>5z{p?Zw_@C|Aw?m#Xk{z8R% zCkLlXvloZqVH|-M(80&ZrtLG1!~ma01BOvw%XXZLJ8>S~M%LWl0>qO$({&FVoJlUq zob;FY3NttTv*vLEUAG%-y8cKNWGzNX$Dl|}A}iEG$x5|kg?a`#n3)qOE>fHo3nd-8 zww0UN6sQW%rZk7FOR1!zpFl1nmy#7}rTk1spfsR^%gg=_obQ%>-!te7EKVfd=IobV zPEMvSfAy@$w6aN+PDLa-xvDf$5sCD!k2R;tmNmta%^PE>%}r5 Date: Sat, 3 Oct 2020 21:43:18 +0200 Subject: [PATCH 13/13] changelog updated / alpha of v2.3.0 --- CHANGELOG.md | 21 +++++++++++++++++++-- fleetpings/__init__.py | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 693b7849..016083d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,18 +6,35 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [2.2.3] - xxxx-xx-xx +## [2.3.0] - xxxx-xx-xx + +### Important! + +Before updating to this version, make sure you have your Alliance Auth updated to version 2.8.0 (or newer). +This version of AA Fleetpings uses a JavaScript library that is introduced in Alliance Auth 2.8.0, +so have your Auth updated before installing this version. + +### Fixed + +- mySQL text fields can't have default values ### Added - Filter to the admin backend +- More checks for Discord. Now checking if the Discord Service s actually activated and setup properly + +### 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 ## [2.2.2] - 2020-09-23 ### Added -- Django 3 stiff in setup.py, Should probably be in there as well ... +- Django 3 stuff in setup.py, Should probably be in there as well ... ## [2.2.1] - 2020-09-23 diff --git a/fleetpings/__init__.py b/fleetpings/__init__.py index f948df5a..9f4369b8 100644 --- a/fleetpings/__init__.py +++ b/fleetpings/__init__.py @@ -6,5 +6,5 @@ default_app_config: str = "fleetpings.apps.AaFleetpingsConfig" -__version__ = "2.2.2" +__version__ = "2.3.0a1" __title__ = "Fleet Pings"