Skip to content

Commit

Permalink
Merge pull request #1 from connorcoley/master
Browse files Browse the repository at this point in the history
Sync with forked repo
  • Loading branch information
mefortunato committed Aug 13, 2019
2 parents 845ffb7 + 2e221f3 commit 7bf4f0e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions askcos/askcos_site/main/views/retro.py
Expand Up @@ -18,7 +18,7 @@

from ..utils import ajax_error_wrapper, resolve_smiles
from .price import price_smiles_func
from .users import can_control_robot
from .users import can_control_robot, can_avoid_banned_chemicals
from ..forms import SmilesInputForm
from ..models import BlacklistedReactions, BlacklistedChemicals

Expand All @@ -40,6 +40,13 @@
for smi in BANNED_SMILES
]

def is_banned(request, smiles):
if can_avoid_banned_chemicals(request):
return False
if smiles in BANNED_SMILES:
return True
return False

#@login_required
def retro(request, smiles=None, chiral=True, mincount=0, max_n=200):
'''
Expand Down Expand Up @@ -81,7 +88,7 @@ def retro(request, smiles=None, chiral=True, mincount=0, max_n=200):
context['err'] = 'Could not parse!'
return render(request, 'retro.html', context)

if smiles is not None and smiles not in BANNED_SMILES:
if smiles is not None and not is_banned(request, smiles):

# OLD: ALWAYS CHIRAL NOW
# if 'retro_lit' in request.POST: return redirect('retro_lit_target', smiles=smiles)
Expand Down
3 changes: 3 additions & 0 deletions askcos/askcos_site/main/views/users.py
Expand Up @@ -17,6 +17,9 @@
def can_view_reaxys(request):
return request.user.is_authenticated and request.user.groups.filter(name='reaxys_view').exists()

def can_avoid_banned_chemicals(request):
return request.user.is_authenticated and request.user.groups.filter(name='avoid_banned_chemicals').exists()

def log_this_request(method):
def f(*args, **kwargs):
try:
Expand Down

0 comments on commit 7bf4f0e

Please sign in to comment.