Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
f973b5bd
Commit
f973b5bd
authored
9 months ago
by
Benoit Alessandroni
Browse files
Options
Downloads
Patches
Plain Diff
update: comments
parent
1507e345
No related branches found
No related tags found
1 merge request
!284
Feature/pregenerate anonymous views
Pipeline
#18119
passed
9 months ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/management/commands/generate_static_content.py
+5
-5
5 additions, 5 deletions
djangoldp/management/commands/generate_static_content.py
with
5 additions
and
5 deletions
djangoldp/management/commands/generate_static_content.py
+
5
−
5
View file @
f973b5bd
...
@@ -21,19 +21,19 @@ class Command(BaseCommand):
...
@@ -21,19 +21,19 @@ class Command(BaseCommand):
for
model
in
apps
.
get_models
():
for
model
in
apps
.
get_models
():
if
hasattr
(
model
.
_meta
,
'
static_version
'
):
if
hasattr
(
model
.
_meta
,
'
static_version
'
):
print
(
f
"
model:
{
model
}
"
)
print
(
f
"
Generating content for
model:
{
model
}
"
)
container_path
=
model
.
get_container_path
()
container_path
=
model
.
get_container_path
()
url
=
f
'
{
base_uri
}{
container_path
}
'
url
=
f
'
{
base_uri
}{
container_path
}
'
print
(
f
"
c
urrent request url before adding params:
{
url
}
"
)
print
(
f
"
C
urrent request url before adding params:
{
url
}
"
)
if
hasattr
(
model
.
_meta
,
'
static_params
'
):
if
hasattr
(
model
.
_meta
,
'
static_params
'
):
# static_params
which is a json must be decomposed and
added to the url as query parameters
, first with ? then with &
# static_params
are
added to the url as query parameters
url
+=
'
?
'
url
+=
'
?
'
for
key
,
value
in
model
.
_meta
.
static_params
.
items
():
for
key
,
value
in
model
.
_meta
.
static_params
.
items
():
url
+=
f
'
{
key
}
=
{
value
}
&
'
url
+=
f
'
{
key
}
=
{
value
}
&
'
url
=
url
[:
-
1
]
url
=
url
[:
-
1
]
print
(
f
"
c
urrent request url after adding params:
{
url
}
"
)
print
(
f
"
C
urrent request url after adding params:
{
url
}
"
)
response
=
requests
.
get
(
url
,
timeout
=
request_timeout
)
response
=
requests
.
get
(
url
,
timeout
=
request_timeout
)
if
response
.
status_code
==
200
:
if
response
.
status_code
==
200
:
...
@@ -43,7 +43,7 @@ class Command(BaseCommand):
...
@@ -43,7 +43,7 @@ class Command(BaseCommand):
filename
=
container_path
[
1
:
-
1
]
filename
=
container_path
[
1
:
-
1
]
file_path
=
os
.
path
.
join
(
output_dir
,
f
'
{
filename
}
.json
'
)
file_path
=
os
.
path
.
join
(
output_dir
,
f
'
{
filename
}
.json
'
)
print
(
f
"
file_path:
{
file_path
}
"
)
print
(
f
"
Output
file_path:
{
file_path
}
"
)
with
open
(
file_path
,
'
w
'
)
as
f
:
with
open
(
file_path
,
'
w
'
)
as
f
:
f
.
write
(
content
)
f
.
write
(
content
)
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
f
'
Successfully fetched and saved content for
{
model
.
_meta
.
model_name
}
from
{
url
}
'
))
self
.
stdout
.
write
(
self
.
style
.
SUCCESS
(
f
'
Successfully fetched and saved content for
{
model
.
_meta
.
model_name
}
from
{
url
}
'
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment