Skip to content

Commit

Permalink
Improve the variable naming for correspondence (GH-26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtyomVancyan authored May 24, 2023
2 parents 1a28b9d + c6a4de9 commit af4c553
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ following keys:
- `OPTIONS` - a dictionary for additional settings
- `VPN` - use VPN detection and forbid access to VPN users
- `URL` - set of URLs to redirect to when the user is located in a forbidden country or using a VPN
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden country
- `FORBIDDEN_VPN` - the URL to redirect to when the user is using a VPN
- `FORBIDDEN_KIT` - the URL to redirect to when the user is using a forbidden device
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden geolocation
- `FORBIDDEN_NET` - the URL to redirect to when the user is using a forbidden network (VPN)
- `FORBIDDEN_DEV` - the URL to redirect to when the user is using a forbidden device

The available device types are: `smartphone`, `peripheral` - refers to all hardware components that are attached to a
computer, `wearable` - common types of wearable technology include smartwatches and smartglasses, `phablet` - a
Expand All @@ -72,8 +72,8 @@ DJANGO_FORBID = {
'VPN': True,
'URL': {
'FORBIDDEN_LOC': 'forbidden_location',
'FORBIDDEN_VPN': 'forbidden_network',
'FORBIDDEN_KIT': 'forbidden_device',
'FORBIDDEN_NET': 'forbidden_network',
'FORBIDDEN_DEV': 'forbidden_device',
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions docs/integration/settings/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ following keys.
- `OPTIONS` - a dictionary for additional settings
- `VPN` - use VPN detection and forbid access to VPN users
- `URL` - set of URLs to redirect to when the user is located in a forbidden country or using a VPN
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden country
- `FORBIDDEN_VPN` - the URL to redirect to when the user is using a VPN
- `FORBIDDEN_KIT` - the URL to redirect to when the user is using a forbidden device
- `FORBIDDEN_LOC` - the URL to redirect to when the user is located in a forbidden geolocation
- `FORBIDDEN_NET` - the URL to redirect to when the user is using a forbidden network (VPN)
- `FORBIDDEN_DEV` - the URL to redirect to when the user is using a forbidden device

These variables are all covered in more detail at the [next page](./variables.md).

Expand All @@ -32,8 +32,8 @@ DJANGO_FORBID = {
'VPN': True,
'URL': {
'FORBIDDEN_LOC': 'forbidden_location',
'FORBIDDEN_VPN': 'forbidden_network',
'FORBIDDEN_KIT': 'forbidden_device',
'FORBIDDEN_NET': 'forbidden_network',
'FORBIDDEN_DEV': 'forbidden_device',
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions docs/integration/settings/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ the default Django 403 page. The URL can be absolute or relative.

#### Forbidden Network

- Key: `FORBIDDEN_VPN`
- Key: `FORBIDDEN_NET`
- Type: `str`
- Default: `''`

This URL is used when the user is using a virtual private network (VPN). If not specified, the user will see the default
Django 403 page. The URL can be absolute or relative.
This URL is used when the user is using a virtual private network (VPN) while VPN detection is enabled. If not
specified, the user will see the default Django 403 page. The URL can be absolute or relative.

#### Forbidden Device

- Key: `FORBIDDEN_KIT`
- Key: `FORBIDDEN_DEV`
- Type: `str`
- Default: `''`

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ license_file = LICENSE
platforms = unix, linux, osx, win32
classifiers =
Operating System :: OS Independent
Development Status :: 4 - Beta
Development Status :: 5 - Production/Stable
Framework :: Django
Framework :: Django :: 2.1
Framework :: Django :: 2.2
Expand Down
2 changes: 1 addition & 1 deletion src/django_forbid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.9"
__version__ = "0.1.0"
6 changes: 3 additions & 3 deletions src/django_forbid/skills/forbid_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def __call__(self, request):
if Access(devices).grants(device_type):
return self.get_response(request)

# Redirects to the FORBIDDEN_KIT URL if set.
if Settings.has("OPTIONS.URL.FORBIDDEN_KIT"):
return redirect(Settings.get("OPTIONS.URL.FORBIDDEN_KIT"))
# Redirects to the FORBIDDEN_DEV URL if set.
if Settings.has("OPTIONS.URL.FORBIDDEN_DEV"):
return redirect(Settings.get("OPTIONS.URL.FORBIDDEN_DEV"))

return HttpResponseForbidden()
6 changes: 3 additions & 3 deletions src/django_forbid/skills/forbid_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def erase_response_attributes():

if geoip2_tz != "N/A" and client_tz != geoip2_tz:
erase_response_attributes()
# Redirects to the FORBIDDEN_VPN URL if set.
if Settings.has("OPTIONS.URL.FORBIDDEN_VPN"):
return redirect(Settings.get("OPTIONS.URL.FORBIDDEN_VPN"))
# Redirects to the FORBIDDEN_NET URL if set.
if Settings.has("OPTIONS.URL.FORBIDDEN_NET"):
return redirect(Settings.get("OPTIONS.URL.FORBIDDEN_NET"))
return HttpResponseForbidden()

# Restores the response from the session.
Expand Down

0 comments on commit af4c553

Please sign in to comment.