Skip to content

Commit

Permalink
22.11 (#150)
Browse files Browse the repository at this point in the history
* Changes to be committed:
	modified:   bco_api/bco_api/settings.py
	modified:   bco_api/server.conf

* Enable Group and Prefix to be open to all users.

Changes to be committed:
	modified:   bco_api/api/permissions.py
	modified:   bco_api/server.conf

* Enable Prefix creation from the ui
Changes to be committed:
	modified:   bco_api/api/model/groups.py
	modified:   bco_api/api/model/prefix.py
	modified:   bco_api/api/scripts/method_specific/POST_api_objects_drafts_modify.py
	modified:   bco_api/api/views.py
	modified:   bco_api/bco_api/settings.py

* Docker building
Changes to be committed:
	modified:   Dockerfile
	modified:   admin_only/bco_api.conf
	modified:   bco_api/bco_api/settings.py
	modified:   bco_api/server.conf
	new file:   docker-compose.yml

* Docker support on release

Changes to be committed:
	new file:   .github/workflows/publish-Docker-image

* testing

Changes to be committed:
	renamed:    .github/workflows/publish-Docker-image -> .github/workflows/release-package.yml

* Push to dockerhub

Changes to be committed:
	modified:   Dockerfile
	deleted:    apitests.py
	deleted:    apitests_new.py
	deleted:    bco_api/static/img/android-chrome-192x192.png
	deleted:    bco_api/static/img/android-chrome-512x512.png
	deleted:    bco_api/static/img/apple-touch-icon.png
	deleted:    bco_api/static/img/favicon-16x16.png
	deleted:    bco_api/static/img/favicon-32x32.png
	deleted:    bco_api/static/img/favicon.ico
	deleted:    cag.sh
	deleted:    curl_fetch.txt
	modified:   docker-compose.yml

* Fix Extension domain validation

* linting
Changes to be committed:
	modified:   bco_api/api/model/groups.py
	modified:   bco_api/api/model/prefix.py
	modified:   bco_api/api/models.py
	modified:   bco_api/api/permissions.py
	modified:   bco_api/api/scripts/utilities/JsonUtils.py
	modified:   bco_api/bco_api/settings.py
	modified:   bco_api/server.conf
  • Loading branch information
HadleyKing authored Nov 16, 2022
1 parent d9e059f commit e22f99e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 27 deletions.
4 changes: 3 additions & 1 deletion bco_api/api/model/groups.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ def post_api_groups_modify(request):

if "owner_user" in action_set:
# Make sure the provided owner user exists.
if usr_utils.check_user_exists(user_name=action_set["owner_user"]):
if usr_utils.check_user_exists(
user_name=action_set["owner_user"]
):
group_information.owner_user = User.objects.get(
username=action_set["owner_user"]
)
Expand Down
26 changes: 13 additions & 13 deletions bco_api/api/model/prefix.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# Generic meta data model
# TODO: rename to prefix_meta
class prefix_table(models.Model):
""" The number of objects for a given prefix."""
"""The number of objects for a given prefix."""

# Field is required.
n_objects = models.IntegerField()
Expand Down Expand Up @@ -93,8 +93,8 @@ def post_api_prefixes_create(request):
return_data = []
any_failed = False
for creation_object in bulk_request:
owner_user = User.objects.get(username=creation_object['owner_user'])
if creation_object['owner_group'] == 'bco_drafter':
owner_user = User.objects.get(username=creation_object["owner_user"])
if creation_object["owner_group"] == "bco_drafter":
is_public = True
else:
is_public = False
Expand Down Expand Up @@ -136,9 +136,9 @@ def post_api_prefixes_create(request):
is not None
):
return_data.append(
db_utils.messages(parameters={"expiration_date": prfx["expiration_date"]})[
"400_invalid_expiration_date"
]
db_utils.messages(
parameters={"expiration_date": prfx["expiration_date"]}
)["400_invalid_expiration_date"]
)
any_failed = True
continue
Expand All @@ -157,7 +157,7 @@ def post_api_prefixes_create(request):
owner_user.groups.add(drafters)
GroupInfo.objects.create(
delete_members_on_group_deletion=False,
description=prfx['description'],
description=prfx["description"],
group=drafters,
max_n_members=-1,
owner_user=owner_user,
Expand All @@ -172,13 +172,13 @@ def post_api_prefixes_create(request):
owner_user.groups.add(publishers)
GroupInfo.objects.create(
delete_members_on_group_deletion=False,
description=prfx['description'],
description=prfx["description"],
group=publishers,
max_n_members=-1,
owner_user=owner_user,
)
if is_public is True:
owner_group = 'bco_drafter'
owner_group = "bco_drafter"
else:
owner_group = publish

Expand Down Expand Up @@ -212,9 +212,9 @@ def post_api_prefixes_create(request):
continue

return_data.append(
db_utils.messages(
parameters={"prefix": standardized}
)["201_prefix_create"]
db_utils.messages(parameters={"prefix": standardized})[
"201_prefix_create"
]
)
# Created the prefix.
# errors["201_prefix_create"] = db_utils.messages(
Expand All @@ -223,7 +223,7 @@ def post_api_prefixes_create(request):

# Append the possible "errors".
if any_failed and len(return_data) == 1:
return Response(status=return_data[0]['status_code'], data=return_data)
return Response(status=return_data[0]["status_code"], data=return_data)

if any_failed and len(return_data) > 1:
return Response(status=status.HTTP_207_MULTI_STATUS, data=return_data)
Expand Down
2 changes: 1 addition & 1 deletion bco_api/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BCO(models.Model):
schema: str
schema to which the BCO should be validated. Default is 'IEEE'
state:str
State of object. PUBLISHED, DRAFT, and DELETE are currently accepted values.
State of object. REFERENCED, PUBLISHED, DRAFT, and DELETE are currently accepted values.
last_update: DateTime
Date Time object for the last database change to this object
"""
Expand Down
9 changes: 4 additions & 5 deletions bco_api/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

class RequestorInGroupAdminsGroup(permissions.BasePermission):
"""Class docstring"""

def has_permission(self, request, view):
"""Check to see if the requester is in the group admins group.
Get the groups for this token (user).
This means getting the user ID for the token,
then the username."""
Get the groups for this token (user).
This means getting the user ID for the token,
then the username."""

user_id = Token.objects.get(
key=request.META.get("HTTP_AUTHORIZATION").split(" ")[1]
Expand Down Expand Up @@ -64,9 +65,7 @@ def has_permission(self, request, view):
).user_id

username = User.objects.get(id=user_id)

prefix_admins = Group.objects.filter(user=username, name="prefix_admins")
import pdb; pdb.set_trace()
return len(prefix_admins) > 0

else:
Expand Down
2 changes: 1 addition & 1 deletion bco_api/api/scripts/utilities/JsonUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def parse_bco(bco, results):

results = validate(spec_version, bco, results)
if "extension_domain" in bco.keys():
if bco["extension_domain"] is not list:
if isinstance(bco["extension_domain"], list) is False:
results[identifier]["extension_domain"] = {
"number_of_errors": 1,
"error_detail": ["extension_doamin invalid"],
Expand Down
10 changes: 5 additions & 5 deletions bco_api/bco_api/settings.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
HUMAN_READABLE_HOSTNAME = server_config["HRHOSTNAME"]["hrnames"]

if server_config["GROUP_PREFIX"]["allow_all_creation"] == "True":
GROUP=True
PREFIX=True
GROUP = True
PREFIX = True
elif server_config["GROUP_PREFIX"]["allow_group_creation"] == "True":
GROUP=True
GROUP = True
elif server_config["GROUP_PREFIX"]["allow_prefix_creation"] == "True":
PREFIX=True
PREFIX = True

# The publicly accessible hostname.
if server_config["PRODUCTION"]["production"] == "True":
Expand Down Expand Up @@ -185,7 +185,7 @@
"SECURITY_DEFINITIONS": {
"Bearer": {"type": "apiKey", "name": "Authorization", "in": "header"}
},
"DEEP_LINKING": True
"DEEP_LINKING": True,
}

REDOC_SETTINGS = {"LAZY_RENDERING": False}
Expand Down
2 changes: 1 addition & 1 deletion bco_api/server.conf
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ production=False

# DB Version
[VERSION]
version=22.08
version=22.11

# NOTE: Valid values are True or False (note the capitalization).
# Is this a publish-only server?
Expand Down

0 comments on commit e22f99e

Please sign in to comment.