Skip to content

Commit

Permalink
Merge pull request #20 from Ilhasoft/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dyohan9 authored Feb 3, 2021
2 parents 6710ba4 + eaf0b59 commit 93d45e8
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 24 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You can set environment variables in your OS, write on ```.env``` file or pass v
| EMAIL_HOST_PASSWORD | ```string``` | ```''``` | Password to use for the SMTP server defined in ```EMAIL_HOST```.
| EMAIL_USE_SSL | ```boolean``` | ```False``` | Whether to use an implicit TLS (secure) connection when talking to the SMTP server.
| EMAIL_USE_TLS | ```boolean``` | ```False``` | Whether to use a TLS (secure) connection when talking to the SMTP server.
| SEND_EMAILS | ```boolean``` | ```False``` | Send emails flag.
| SEND_EMAILS | ```boolean``` | ```True``` | Send emails flag.
| INTELIGENCE_URL | ```string``` | ```https://bothub.it/``` | Specify the URL of the intelligence service.
| FLOWS_URL | ```string``` | ```https://new.push.al/``` | Specify the URL of the flows service.
| USE_SENTRY | ```bool``` | ```False``` | Enable Support Sentry
Expand All @@ -58,7 +58,7 @@ You can set environment variables in your OS, write on ```.env``` file or pass v

## License

Distributed under the GPL-3.0 License. See `LICENSE` for more information.
Distributed under the MPL-2.0 License. See `LICENSE` for more information.


## Contributing
Expand Down
10 changes: 4 additions & 6 deletions weni/api/v1/account/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import filetype
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from keycloak import KeycloakGetError
from rest_framework import mixins, permissions, parsers
Expand Down Expand Up @@ -120,10 +119,9 @@ def change_password(self, request, **kwargs): # pragma: no cover
user_id=user_id, password=request.data.get("password"), temporary=False
)
self.request.user.send_change_password_email()
except KeycloakGetError:
if not settings.DEBUG:
raise ValidationError(
_("System temporarily unavailable, please try again later.")
)
except KeycloakGetError or ValidationError:
raise ValidationError(
_("System temporarily unavailable, please try again later.")
)

return Response()
8 changes: 4 additions & 4 deletions weni/api/v1/dashboard/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Meta:
default=Service.TYPE_SERVICE_CHAT,
label=_("Type Service"),
source="service.type_service",
read_only=True
read_only=True,
)


Expand All @@ -54,8 +54,8 @@ def get_menu(self, obj):
"inteligence": settings.INTELIGENCE_URL,
"flows": settings.FLOWS_URL,
"chat": list(
obj.service_status.filter(service__type_service=Service.TYPE_SERVICE_CHAT).values_list(
"service__url", flat=True
)
obj.service_status.filter(
service__type_service=Service.TYPE_SERVICE_CHAT
).values_list("service__url", flat=True)
),
}
4 changes: 3 additions & 1 deletion weni/api/v1/tests/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def setUp(self):
self.factory = RequestFactory()

self.service = Service.objects.create(
url="http://test-rocketchat.com", status=False, type_service=Service.TYPE_SERVICE_CHAT
url="http://test-rocketchat.com",
status=False,
type_service=Service.TYPE_SERVICE_CHAT,
)

self.user, self.token = create_user_and_token()
Expand Down
15 changes: 10 additions & 5 deletions weni/authentication/signals.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from django.conf import settings
from django.db import models
from django.dispatch import receiver
Expand All @@ -9,6 +11,9 @@
from weni.authentication.models import User


logger = logging.getLogger("weni.authentication.signals")


@receiver(models.signals.pre_save, sender=User)
def update_user_keycloak(instance, **kwargs):
if not settings.TESTING:
Expand All @@ -23,8 +28,8 @@ def update_user_keycloak(instance, **kwargs):
"lastName": instance.last_name,
},
)
except exceptions.KeycloakGetError:
if not settings.DEBUG:
raise ValidationError(
_("System temporarily unavailable, please try again later.")
)
except exceptions.KeycloakGetError as e:
logger.error(e)
raise ValidationError(
_("System temporarily unavailable, please try again later.")
)
21 changes: 15 additions & 6 deletions weni/common/migrations/0005_service_type_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@ def migrate(apps, schema_editor): # pragma: no cover
class Migration(migrations.Migration):

dependencies = [
('common', '0004_auto_20210114_1405'),
("common", "0004_auto_20210114_1405"),
]

operations = [
migrations.AddField(
model_name='service',
name='type_service',
field=models.CharField(choices=[('type_service_flows', 'Flows service'), ('type_service_inteligence', 'Inteligence Service'), ('type_service_chat', 'Chat Service')], default='type_service_chat', max_length=50, verbose_name='type service'),
model_name="service",
name="type_service",
field=models.CharField(
choices=[
("type_service_flows", "Flows service"),
("type_service_inteligence", "Inteligence Service"),
("type_service_chat", "Chat Service"),
],
default="type_service_chat",
max_length=50,
verbose_name="type service",
),
),
migrations.RunPython(migrate, noop),
migrations.RemoveField(
model_name='service',
name='rocket_chat',
model_name="service",
name="rocket_chat",
),
]
5 changes: 5 additions & 0 deletions weni/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@
"handlers": ["console"],
"propagate": False,
}
LOGGING["loggers"]["weni.authentication.signals"] = {
"level": "ERROR",
"handlers": ["console"],
"propagate": False,
}

# rest framework

Expand Down

0 comments on commit 93d45e8

Please sign in to comment.