Browse Source

impl: add campo para script do google analytics

pull/3645/head
LeandroJatai 2 years ago
parent
commit
ea06eded64
  1. 10
      sapl/base/forms.py
  2. 18
      sapl/base/migrations/0057_appconfig_google_analytics_id_metrica.py
  3. 7
      sapl/base/models.py
  4. 29
      sapl/templates/base.html
  5. 1
      sapl/templates/base/layouts.yaml

10
sapl/base/forms.py

@ -1620,6 +1620,12 @@ class ConfiguracoesAppForm(ModelForm):
max_length=256,
required=False)
google_analytics_id_metrica = forms.CharField(
label=AppConfig._meta.get_field(
'google_analytics_id_metrica').verbose_name,
max_length=256,
required=False)
class Meta:
model = AppConfig
fields = ['documentos_administrativos',
@ -1648,8 +1654,10 @@ class ConfiguracoesAppForm(ModelForm):
'tramitacao_documento',
'google_recaptcha_site_key',
'google_recaptcha_secret_key',
'google_analytics_id_metrica',
'sapl_as_sapn',
'identificacao_de_documentos']
'identificacao_de_documentos',
]
def __init__(self, *args, **kwargs):
super(ConfiguracoesAppForm, self).__init__(*args, **kwargs)

18
sapl/base/migrations/0057_appconfig_google_analytics_id_metrica.py

@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2023-05-29 19:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base', '0056_auto_20221118_1330'),
]
operations = [
migrations.AddField(
model_name='appconfig',
name='google_analytics_id_metrica',
field=models.CharField(default='', max_length=256, verbose_name='ID da Métrica do Google Analytics'),
),
]

7
sapl/base/models.py

@ -234,7 +234,8 @@ class AppConfig(models.Model):
verbose_name=_('Mostrar brasão da Casa no painel?'))
mostrar_voto = models.BooleanField(
verbose_name=_('Exibir voto do Parlamentar antes de encerrar a votação?'),
verbose_name=_(
'Exibir voto do Parlamentar antes de encerrar a votação?'),
choices=YES_NO_CHOICES, default=False)
# MÓDULO ESTATÍSTICAS DE ACESSO
@ -259,6 +260,10 @@ class AppConfig(models.Model):
verbose_name=_('Chave privada gerada pelo Google Recaptcha'),
max_length=256, default='')
google_analytics_id_metrica = models.CharField(
verbose_name=_('ID da Métrica do Google Analytics'),
max_length=256, default='')
class Meta:
verbose_name = _('Configurações da Aplicação')
verbose_name_plural = _('Configurações da Aplicação')

29
sapl/templates/base.html

@ -264,14 +264,6 @@
{% block extra_js %}{% endblock extra_js %}
{% if not DEBUG %}
<script src="https://vlibras.gov.br/app/vlibras-plugin.js"></script>
<script>
new window.VLibras.Widget('https://vlibras.gov.br/app');
</script>
{% endif %}
<script type="text/javascript" >
function inIframe () {
try {
@ -297,6 +289,27 @@
});
</script>
{% if not DEBUG %}
<script src="https://vlibras.gov.br/app/vlibras-plugin.js"></script>
<script>
new window.VLibras.Widget('https://vlibras.gov.br/app');
</script>
{% if "google_analytics_id_metrica"|get_config_attr %}
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{"google_analytics_id_metrica"|get_config_attr}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{"google_analytics_id_metrica"|get_config_attr}}');
</script>
{% endif %}
{% endif %}
{% endblock foot_js %}
</body>

1
sapl/templates/base/layouts.yaml

@ -52,6 +52,7 @@ AppConfig:
{% trans 'Estatísticas de acesso' %}:
- estatisticas_acesso_normas
- google_analytics_id_metrica
{% trans 'Segurança' %}:
- google_recaptcha_site_key google_recaptcha_secret_key

Loading…
Cancel
Save