Support IP range editing in Organization view_embed
This commit is contained in:
@@ -54,6 +54,7 @@ def view_embed(organization_id: str):
|
|||||||
|
|
||||||
# Make sure it's never None
|
# Make sure it's never None
|
||||||
organization.unknown_members = organization.unknown_members or []
|
organization.unknown_members = organization.unknown_members or []
|
||||||
|
organization.human_ip_ranges = [ipr['human'] for ipr in (organization.ip_ranges or [])]
|
||||||
|
|
||||||
can_super_edit = current_user.has_cap('admin')
|
can_super_edit = current_user.has_cap('admin')
|
||||||
can_edit = can_super_edit or om.user_is_admin(organization_oid)
|
can_edit = can_super_edit or om.user_is_admin(organization_oid)
|
||||||
|
@@ -32,3 +32,7 @@ body.organizations
|
|||||||
.org-admin
|
.org-admin
|
||||||
#admin-name
|
#admin-name
|
||||||
padding: 10px 0
|
padding: 10px 0
|
||||||
|
|
||||||
|
.help-block
|
||||||
|
font-size: 0.9em
|
||||||
|
color: $color-text-dark-secondary
|
||||||
|
@@ -29,6 +29,19 @@
|
|||||||
type="text",
|
type="text",
|
||||||
placeholder="Organization's location",
|
placeholder="Organization's location",
|
||||||
value="{{ organization.location | hide_none }}")
|
value="{{ organization.location | hide_none }}")
|
||||||
|
.input-group
|
||||||
|
label(for='org-ip-ranges-field') IP Ranges
|
||||||
|
textarea.item-ip-ranges#org-ip-ranges-field(
|
||||||
|
name="ip_ranges",
|
||||||
|
type="text",
|
||||||
|
rows="{{ organization.human_ip_ranges|length|default(1, true) }}",
|
||||||
|
placeholder="IP ranges in CIDR notation, one on each line",
|
||||||
|
title="IPv6 like 2a01:1234:abcd:3b::0/64\nIPv4 like 172.16.0.0/16")
|
||||||
|
| {{ organization.human_ip_ranges | join('\n') }}
|
||||||
|
p.help-block.
|
||||||
|
Clients with a matching IP address will be considered part of the organization. IPv4
|
||||||
|
ranges are always normalized to IPv6 prior to saving. Changes to IP Ranges take up
|
||||||
|
to an hour to affect already logged-in users.
|
||||||
|
|
||||||
| {% if can_super_edit %}
|
| {% if can_super_edit %}
|
||||||
.input-group
|
.input-group
|
||||||
@@ -38,6 +51,7 @@
|
|||||||
type="text",
|
type="text",
|
||||||
placeholder="Seat count",
|
placeholder="Seat count",
|
||||||
value="{{ organization.seat_count | hide_none }}")
|
value="{{ organization.seat_count | hide_none }}")
|
||||||
|
p.help-block Users covered by the IP Ranges do not count towards the seat count.
|
||||||
.input-group
|
.input-group
|
||||||
label(for='org-roles-field') Roles
|
label(for='org-roles-field') Roles
|
||||||
input.item-location.input-transparent#org-roles-field(
|
input.item-location.input-transparent#org-roles-field(
|
||||||
@@ -292,6 +306,7 @@ script.
|
|||||||
description: $form.find('*[name="description"]').val(),
|
description: $form.find('*[name="description"]').val(),
|
||||||
website: $form.find('*[name="website"]').val(),
|
website: $form.find('*[name="website"]').val(),
|
||||||
location: $form.find('*[name="location"]').val(),
|
location: $form.find('*[name="location"]').val(),
|
||||||
|
ip_ranges: $form.find('*[name="ip_ranges"]').val().trim().split('\n'),
|
||||||
{% if can_super_edit %}
|
{% if can_super_edit %}
|
||||||
seat_count: parseInt($form.find('*[name="seat_count"]').val()),
|
seat_count: parseInt($form.find('*[name="seat_count"]').val()),
|
||||||
org_roles: org_roles,
|
org_roles: org_roles,
|
||||||
|
@@ -818,7 +818,7 @@ class IPRangeTest(AbstractOrgTest):
|
|||||||
# IP ranges should be saved as integers for fast matching.
|
# IP ranges should be saved as integers for fast matching.
|
||||||
db_org = self._patch({'ip_ranges': [
|
db_org = self._patch({'ip_ranges': [
|
||||||
'192.168.3.0/24',
|
'192.168.3.0/24',
|
||||||
'192.168.3.1/32',
|
' 192.168.3.1/32 \r\n ', # Whitespace should be ignored
|
||||||
'2a03:b0c0:0:1010::8fe:6ef1/120',
|
'2a03:b0c0:0:1010::8fe:6ef1/120',
|
||||||
]})
|
]})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user