Skip to content

Commit

Permalink
Fixed critical... asbool(config.get...
Browse files Browse the repository at this point in the history
  • Loading branch information
m431m committed Dec 23, 2020
1 parent 48ae62c commit 4d937d6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions ckanext/restricted/action.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# coding: utf8

from __future__ import unicode_literals
from paste.deploy.converters import asbool

import ckan.authz as authz
from ckan.common import _

from ckan.lib.base import render_jinja2
from ckan.lib.mailer import mail_recipient
from ckan.lib.mailer import MailerException
Expand Down Expand Up @@ -63,7 +64,7 @@ def body_from_user_dict(user_dict):
body = render_jinja2(
'restricted/emails/restricted_user_registered.txt', extra_vars)

if config.getboolean('ckanext.restricted.enable_send_mail', True):
if asbool(config.get('ckanext.restricted.enable_send_mail', True)):
mail_recipient(name, email, subject, body)

except MailerException as mailer_exception:
Expand Down
2 changes: 2 additions & 0 deletions ckanext/restricted/controller.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# coding: utf8

from __future__ import unicode_literals
from paste.deploy.converters import asbool

from ckan.common import _
from ckan.common import request
import ckan.lib.base as base
Expand Down
3 changes: 2 additions & 1 deletion ckanext/restricted/logic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf8

from __future__ import unicode_literals
from paste.deploy.converters import asbool
from urlparse import urljoin

import ckan.authz as authz
Expand Down Expand Up @@ -167,7 +168,7 @@ def restricted_mail_allowed_user(user_id, resource):
mail_body = restricted_allowed_user_mail_body(user, resource)
mail_subject = _('Access granted to resource {}').format(resource_name)

if config.getboolean('ckanext.restricted.enable_send_mail', True):
if asbool(config.get('ckanext.restricted.enable_send_mail', True)):
# Send mail to user
mailer.mail_recipient(user_name, user_email, mail_subject, mail_body)
# Send copy to admin
Expand Down
5 changes: 3 additions & 2 deletions ckanext/restricted/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# coding: utf8

from __future__ import unicode_literals
from paste.deploy.converters import asbool

from ckan.lib.plugins import DefaultTranslation
import ckan.logic
Expand Down Expand Up @@ -74,6 +75,6 @@ def before_update(self, context, current, resource):

def after_update(self, context, resource):
previous_value = context.get('__restricted_previous_value')
if config.getboolean('ckanext.restricted.enable_send_mail', True):
if config.getboolean('ckanext.restricted.notify_allowed_users', True):
if asbool(config.get('ckanext.restricted.enable_send_mail', True)):
if asbool(config.get('ckanext.restricted.notify_allowed_users', True)):
logic.restricted_notify_allowed_users(previous_value, resource)

0 comments on commit 4d937d6

Please sign in to comment.