def add_to_blacklist(): if not env.owner or not env.owner.id: raise NotFound try: res = users.add_to_blacklist(env.owner) except SubscribeError: raise Forbidden if env.request.is_xhr: return Response(json.dumps({"ok": bool(res)}), mimetype="application/json") return Response(redirect=env.request.referer)
def add_to_blacklist(): if not env.owner or not env.owner.id: raise NotFound try: res = users.add_to_blacklist(env.owner) except SubscribeError: raise Forbidden if env.request.is_xhr: return Response(json.dumps({'ok': bool(res)}), mimetype='application/json') return Response(redirect=env.request.referer)
def add_to_blacklist(logins): logins = re.split(r'[\s@,]+', logins.strip(' \t@')) added = [] already = [] not_found = [] for login in logins: try: if users.add_to_blacklist(login): added.append(login) else: already.append(login) except SubscribeError: pass except UserNotFound: not_found.append(login) return xmpp_template('bl_updated', added=added, already=already, not_found=not_found)
def add_to_blacklist(login): users.add_to_blacklist(login)