Skip to content

Commit

Permalink
refactor: integrate apis_entities.apis_urls into [apis_entities.]urls
Browse files Browse the repository at this point in the history
There where three routes in a separate file included under the `/api2`
path - the `savenetworkfiles` endpoint was removed, the
`getorcreateentity` endpoint was moved to `apis_entities.urls` and the
`/entity/<int:pk>` endpoint was moved to the main apis `urls.py`

Closes: #266
Closes: #379
  • Loading branch information
b1rger committed Nov 23, 2023
1 parent 18234e7 commit 2b68757
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 45 deletions.
22 changes: 0 additions & 22 deletions apis_core/apis_entities/api_urls.py

This file was deleted.

22 changes: 0 additions & 22 deletions apis_core/apis_entities/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,28 +341,6 @@ def get(self, request, pk):
# return Response(res)
#
# __after_rdf_refactoring__
class SaveNetworkFiles(APIView):
def post(self, request, format=None):
file_name = request.data["file_name"]
file_name_list = file_name.split(".")
data = request.data["file"]
nmb = False
for file in os.listdir("downloads/"):
if (
fnmatch.fnmatch(file, file_name_list[0] + "_*." + file_name_list[1])
or file == file_name
):
if nmb:
nmb += 1
else:
nmb = 1
if nmb:
file_name = file_name_list[0] + "_" + str(nmb) + "." + file_name_list[1]
with open("downloads/" + file_name, "wb") as fw:
data = data.replace('"edges"', '"links"', 1)
fw.write(data.encode("utf-8"))
res = {"test": True, "file_name": "/downloads/" + file_name}
return Response(res)


class ResolveAbbreviations(APIView):
Expand Down
6 changes: 6 additions & 0 deletions apis_core/apis_entities/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

# from .views import ReversionCompareView TODO: add again when import is fixed
from .edit_generic import GenericEntitiesCreateStanbolView
from .api_views import GetOrCreateEntity

app_name = "apis_entities"

Expand Down Expand Up @@ -103,4 +104,9 @@
# r'^compare/(?P<app>[a-z_]+)/(?P<kind>[a-z]+)/(?P<pk>\d+)$', ReversionCompareView.as_view()
# ),
path("merge-objects/", merge_views.merge_objects, name="merge_objects"),
path(
"getorcreateentity/",
GetOrCreateEntity.as_view(),
name="GetOrCreateEntity",
),
]
9 changes: 8 additions & 1 deletion apis_core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def build_apis_mock_request(method, path, view, original_request, **kwargs):
return request


from apis_core.apis_entities.api_views import GetEntityGeneric


urlpatterns = [
path("", TemplateView.as_view(template_name="base.html"), name="apis_index"),
path("admin/", admin.site.urls),
Expand Down Expand Up @@ -149,7 +152,6 @@ def build_apis_mock_request(method, path, view, original_request, **kwargs):
# description="APIS API schema definition",
# urlconf='apis_core.apis_entities.api_urls',
# ), name='openapi-schema-api'),
path("api2/", include("apis_core.apis_entities.api_urls", namespace="apis_api2")),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
# url(r'^api-schema/', schema_view),
re_path(
Expand All @@ -161,6 +163,11 @@ def build_apis_mock_request(method, path, view, original_request, **kwargs):
# url(r'^docs/', include('sphinxdoc.urls')),
# url(r'^accounts/', include('registration.backends.simple.urls')),
path("accounts/", include("django.contrib.auth.urls")),
path(
"entity/<int:pk>/",
GetEntityGeneric.as_view(),
name="GetEntityGeneric",
),
]

if "apis_fulltext_download" in settings.INSTALLED_APPS:
Expand Down

0 comments on commit 2b68757

Please sign in to comment.