diff --git a/basedosdados_api/account/admin.py b/basedosdados_api/account/admin.py index 5ba018b3..eb323909 100644 --- a/basedosdados_api/account/admin.py +++ b/basedosdados_api/account/admin.py @@ -27,6 +27,7 @@ class AccountCreationForm(forms.ModelForm): is_active = forms.BooleanField( label="Está ativo?", initial=True, + required=False, help_text="Marque ativo para não enviar email de confirmação", ) diff --git a/basedosdados_api/account/signals.py b/basedosdados_api/account/signals.py index 4dcdfe0c..8a7cad4b 100644 --- a/basedosdados_api/account/signals.py +++ b/basedosdados_api/account/signals.py @@ -9,7 +9,6 @@ from basedosdados_api.account.models import Account from basedosdados_api.account.token import token_generator from basedosdados_api.settings import EMAIL_HOST_USER -from basedosdados_api.utils import is_prod @receiver(post_save, sender=Account) @@ -20,9 +19,8 @@ def send_activation_email(sender, instance, created, raw, **kwargs): - The account is new - The account isn't active - The account isn't a fixture - - The account is in production environment """ - if created and not raw and not instance.is_active and is_prod(): + if created and not raw and not instance.is_active: to_email = instance.email from_email = EMAIL_HOST_USER subject = "Bem Vindo à Base dos Dados!" diff --git a/basedosdados_api/account/tests.py b/basedosdados_api/account/tests.py index 9bccdd0b..ad18e581 100644 --- a/basedosdados_api/account/tests.py +++ b/basedosdados_api/account/tests.py @@ -11,7 +11,6 @@ @pytest.mark.django_db -@patch("basedosdados_api.account.signals.is_prod", new=lambda: True) def test_account_create(): account = Account.objects.create( username="john.doe", @@ -22,7 +21,6 @@ def test_account_create(): @pytest.mark.django_db @patch("basedosdados_api.account.signals.EmailMultiAlternatives") -@patch("basedosdados_api.account.signals.is_prod", new=lambda: True) def test_activate_account_signal(mock: MagicMock): Account.objects.create( username="john.doe", @@ -35,7 +33,6 @@ def test_activate_account_signal(mock: MagicMock): @pytest.mark.django_db @patch("basedosdados_api.account.signals.render_to_string") -@patch("basedosdados_api.account.signals.is_prod", new=lambda: True) def test_activate_account_confirmation(mock: MagicMock, client: Client): account = Account.objects.create( username="john.doe", @@ -55,7 +52,6 @@ def test_activate_account_confirmation(mock: MagicMock, client: Client): @pytest.mark.django_db @patch("basedosdados_api.account.views.EmailMultiAlternatives") -@patch("basedosdados_api.account.signals.is_prod", new=lambda: True) def test_password_reset_request(mock: MagicMock, client: Client): account = Account.objects.create( username="john.doe", @@ -76,7 +72,6 @@ def test_password_reset_request(mock: MagicMock, client: Client): @pytest.mark.django_db @patch("basedosdados_api.account.views.render_to_string") @patch("basedosdados_api.account.signals.render_to_string") -@patch("basedosdados_api.account.signals.is_prod", new=lambda: True) def test_password_reset_confirmation(mock_signal: MagicMock, mock_view: MagicMock, client: Client): # Create account account = Account.objects.create(