Skip to content

Commit

Permalink
Merge pull request #173 from Ilhasoft/develop
Browse files Browse the repository at this point in the history
Version 1.13.7
  • Loading branch information
Douglas Paz committed Jul 11, 2018
2 parents f9c7eb1 + 42720b5 commit 2978a06
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ You can set environment variables in your OS, write on ```.env``` file or pass v
| BOTHUB_WEBAPP_BASE_URL | ```string``` | ```http://localhost:8080/``` | The bothub-webapp production application URL. Used to refer and redirect user correctly.
| BOTHUB_NLP_BASE_URL | ```string``` | ```http://localhost:2657/``` | The bothub-blp production application URL. Used to proxy requests.
| CHECK_ACCESSIBLE_API_URL | ```string``` | ```http://localhost/api/repositories/``` | URL used by ```bothub.health.check.check_accessible_api``` to make a HTTP request. The response status code must be 200.
| SEND_EMAILS | ```boolean``` | ```True``` | Send emails flag.


### Docker Environment Variables
Expand Down
4 changes: 4 additions & 0 deletions bothub/authentication/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def token_generator(self):
return PasswordResetTokenGenerator()

def send_welcome_email(self):
if not settings.SEND_EMAILS:
return False
context = {
'name': self.name,
}
Expand All @@ -121,6 +123,8 @@ def make_password_reset_token(self):
return self.token_generator.make_token(self)

def send_reset_password_email(self):
if not settings.SEND_EMAILS:
return False
token = self.make_password_reset_token()
reset_url = '{}reset-password/{}/{}/'.format(
settings.BOTHUB_WEBAPP_BASE_URL,
Expand Down
16 changes: 12 additions & 4 deletions bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ def role_verbose(self):
return dict(RepositoryAuthorization.ROLE_CHOICES).get(self.role)

def send_new_role_email(self, responsible=None):
if not settings.SEND_EMAILS:
return False
responsible_name = responsible and responsible.name \
or self.repository.owner.name
context = {
Expand Down Expand Up @@ -794,6 +796,8 @@ class Meta:
editable=False)

def send_new_request_email_to_admins(self):
if not settings.SEND_EMAILS:
return False
context = {
'user_name': self.user.name,
'repository_name': self.repository.name,
Expand All @@ -813,7 +817,9 @@ def send_new_request_email_to_admins(self):
'common/emails/new_request.html',
context))

def send_request_rejected(self):
def send_request_rejected_email(self):
if not settings.SEND_EMAILS:
return False
context = {
'repository_name': self.repository.name,
}
Expand All @@ -829,7 +835,9 @@ def send_request_rejected(self):
'common/emails/request_rejected.html',
context))

def send_request_approved(self):
def send_request_approved_email(self):
if not settings.SEND_EMAILS:
return False
context = {
'admin_name': self.approved_by.name,
'repository_name': self.repository.name,
Expand Down Expand Up @@ -864,7 +872,7 @@ def set_user_role_on_approved(instance, **kwargs):
instance.user)
user_authorization.role = RepositoryAuthorization.ROLE_USER
user_authorization.save(update_fields=['role'])
instance.send_request_approved()
instance.send_request_approved_email()
else:
raise ValidationError(
_('You can change approved_by just one time.'))
Expand All @@ -878,4 +886,4 @@ def send_new_request_email_to_admins_on_created(instance, created, **kwargs):

@receiver(models.signals.post_delete, sender=RequestRepositoryAuthorization)
def send_request_rejected_email(instance, **kwargs):
instance.send_request_rejected()
instance.send_request_rejected_email()
2 changes: 2 additions & 0 deletions bothub/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@
else:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

SEND_EMAILS = config('SEND_EMAILS', default=True, cast=bool)


# webapp

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='bothub',
version='1.13.5',
version='1.13.7',
description='bothub',
packages=find_packages(),
install_requires=[
Expand Down

0 comments on commit 2978a06

Please sign in to comment.