Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Maják
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
TO
Maják
Commits
fba2fd0d
Commit
fba2fd0d
authored
1 year ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
fix imports
parent
28e0bff4
No related branches found
No related tags found
2 merge requests
!882
Release
,
!877
Fix article imports(?)
Pipeline
#16285
passed
1 year ago
Stage: build
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
shared/forms.py
+12
-11
12 additions, 11 deletions
shared/forms.py
shared/jekyll_import.py
+10
-3
10 additions, 3 deletions
shared/jekyll_import.py
shared/tasks.py
+27
-0
27 additions, 0 deletions
shared/tasks.py
with
49 additions
and
14 deletions
shared/forms.py
+
12
−
11
View file @
fba2fd0d
...
...
@@ -2,7 +2,7 @@ from django import forms
from
wagtail.admin.forms
import
WagtailAdminPageForm
from
wagtail.models.collections
import
Collection
from
shared.jekyll_
import
import
J
ekyll
A
rticle
Importer
from
.tasks
import
import
_j
ekyll
_a
rticle
s
class
SubscribeForm
(
forms
.
Form
):
...
...
@@ -65,19 +65,20 @@ class JekyllImportForm(WagtailAdminPageForm):
return
cleaned_data
def
handle_import
(
self
,
model
):
def
handle_import
(
self
):
# TODO: Portable function
from
.models
import
MainArticlePage
print
(
"
handling import
"
)
JekyllArticleImporter
(
article_parent_page
=
self
.
instance
,
collection_id
=
self
.
cleaned_data
[
"
collection
"
].
id
,
url
=
self
.
cleaned_data
[
"
jekyll_repo_url
"
],
dry_run
=
self
.
cleaned_data
[
"
dry_run
"
],
use_git
=
True
,
page_model
=
MainArticlePage
,
).
perform_import
()
print
(
import_jekyll_articles
.
delay
(
article_parent_page_id
=
self
.
instance
.
id
,
collection_id
=
self
.
cleaned_data
[
"
collection
"
].
id
,
url
=
self
.
cleaned_data
[
"
jekyll_repo_url
"
],
dry_run
=
self
.
cleaned_data
[
"
dry_run
"
],
use_git
=
True
,
)
)
def
save
(
self
,
commit
=
True
):
if
self
.
cleaned_data
.
get
(
"
do_import
"
):
...
...
This diff is collapsed.
Click to expand it.
shared/jekyll_import.py
+
10
−
3
View file @
fba2fd0d
...
...
@@ -323,7 +323,8 @@ params = {}
class
JekyllArticleImporter
:
def
__init__
(
self
,
article_parent_page
,
article_parent_page_id
:
int
,
article_parent_page_model
,
collection_id
:
int
,
url
:
str
,
dry_run
:
bool
,
...
...
@@ -333,13 +334,19 @@ class JekyllArticleImporter:
self
.
page_model
=
page_model
# Params
self
.
article_parent_page
=
article_parent_page
self
.
article_parent_page_id
=
article_parent_page_id
self
.
article_parent_page_model
=
article_parent_page_model
self
.
collection
=
Collection
.
objects
.
get
(
id
=
collection_id
)
self
.
dry_run
=
dry_run
self
.
use_git
=
use_git
self
.
url
=
url
# Computed props
# Computed proprs
import
time
time
.
sleep
(
5
)
self
.
article_parent_page
=
self
.
article_parent_page_model
.
objects
.
filter
(
id
=
self
.
article_parent_page_id
).
first
()
self
.
path
,
self
.
repo_name
=
get_path_and_repo_name
(
self
.
url
,
self
.
use_git
)
self
.
site
=
self
.
article_parent_page
.
get_site
()
self
.
site_config
=
get_site_config
(
self
.
path
)
...
...
This diff is collapsed.
Click to expand it.
shared/tasks.py
0 → 100644
+
27
−
0
View file @
fba2fd0d
import
logging
from
celery
import
shared_task
from
shared.jekyll_import
import
JekyllArticleImporter
logger
=
logging
.
getLogger
(
__name__
)
@shared_task
()
def
import_jekyll_articles
(
article_parent_page_id
,
collection_id
,
url
,
dry_run
,
use_git
,
):
from
main.models
import
MainArticlePage
,
MainArticlesPage
return
JekyllArticleImporter
(
article_parent_page_id
=
article_parent_page_id
,
article_parent_page_model
=
MainArticlesPage
,
collection_id
=
collection_id
,
url
=
url
,
dry_run
=
dry_run
,
use_git
=
use_git
,
page_model
=
MainArticlePage
,
).
perform_import
()
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