mirror of
https://github.com/Cian-H/invenio-config-iform.git
synced 2025-12-22 21:11:57 +00:00
Lint and format according to new codestyle
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
"""Custom fields."""
|
"""Custom fields."""
|
||||||
|
|
||||||
|
|
||||||
from invenio_records_resources.services.custom_fields import BooleanCF
|
from invenio_records_resources.services.custom_fields import BooleanCF
|
||||||
|
|
||||||
ip_network = BooleanCF(name="ip_network")
|
ip_network = BooleanCF(name="ip_network")
|
||||||
|
|||||||
@@ -66,10 +66,7 @@ class RecordSingleIP(Generator):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# if record has singleip, and the ip of the user matches the allowed ip
|
# if record has singleip, and the ip of the user matches the allowed ip
|
||||||
if (
|
if record.get("custom_fields", {}).get("single_ip", False) and self.check_permission():
|
||||||
record.get("custom_fields", {}).get("single_ip", False)
|
|
||||||
and self.check_permission()
|
|
||||||
):
|
|
||||||
return [any_user]
|
return [any_user]
|
||||||
|
|
||||||
# non of the above - return empty
|
# non of the above - return empty
|
||||||
@@ -94,10 +91,7 @@ class RecordSingleIP(Generator):
|
|||||||
Need provider is disallowed.
|
Need provider is disallowed.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if (
|
if kwargs["record"]["custom_fields"]["single_ip"] and not self.check_permission():
|
||||||
kwargs["record"]["custom_fields"]["single_ip"]
|
|
||||||
and not self.check_permission()
|
|
||||||
):
|
|
||||||
return [any_user]
|
return [any_user]
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@@ -138,10 +132,7 @@ class AllowedFromIPNetwork(Generator):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# if the record has set the ip_range allowance and is in the range
|
# if the record has set the ip_range allowance and is in the range
|
||||||
if (
|
if record.get("custom_fields", {}).get("ip_network", False) and self.check_permission():
|
||||||
record.get("custom_fields", {}).get("ip_network", False)
|
|
||||||
and self.check_permission()
|
|
||||||
):
|
|
||||||
return [any_user]
|
return [any_user]
|
||||||
|
|
||||||
# non of the above - return empty
|
# non of the above - return empty
|
||||||
@@ -166,10 +157,7 @@ class AllowedFromIPNetwork(Generator):
|
|||||||
Need provider is disallowed.
|
Need provider is disallowed.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if (
|
if kwargs["record"]["custom_fields"]["ip_network"] and not self.check_permission():
|
||||||
kwargs["record"]["custom_fields"]["ip_network"]
|
|
||||||
and not self.check_permission()
|
|
||||||
):
|
|
||||||
return [any_user]
|
return [any_user]
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ One can define any action as long as it follows that pattern and
|
|||||||
is verified at the moment it is undertaken.
|
is verified at the moment it is undertaken.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from invenio_administration.generators import Administration
|
from invenio_administration.generators import Administration
|
||||||
from invenio_communities.generators import CommunityCurators
|
from invenio_communities.generators import CommunityCurators
|
||||||
from invenio_rdm_records.services.generators import (
|
from invenio_rdm_records.services.generators import (
|
||||||
|
|||||||
@@ -13,9 +13,8 @@ See https://pytest-invenio.readthedocs.io/ for documentation on which test
|
|||||||
fixtures are available.
|
fixtures are available.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
import pytest
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
import pytest
|
||||||
|
|
||||||
from invenio_config_iform import InvenioConfigIform
|
from invenio_config_iform import InvenioConfigIform
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user