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
92b9bce6
Commit
92b9bce6
authored
1 year ago
by
Tomáš Valenta
Browse files
Options
Downloads
Patches
Plain Diff
fix imports (date assignment)
parent
66a5fd54
No related branches found
No related tags found
2 merge requests
!903
Release
,
!902
Fix date assignment in imports, date lookup in elections, elections header sizing
Pipeline
#16408
passed
1 year ago
Stage: build
Changes
3
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
elections/migrations/0020_alter_electionshomepage_content.py
+1
-1
1 addition, 1 deletion
elections/migrations/0020_alter_electionshomepage_content.py
shared/jekyll_import.py
+11
-6
11 additions, 6 deletions
shared/jekyll_import.py
shared/models/base.py
+5
-0
5 additions, 0 deletions
shared/models/base.py
with
17 additions
and
7 deletions
elections/migrations/0020_alter_electionshomepage_content.py
+
1
−
1
View file @
92b9bce6
# Generated by Django 4.1.10 on 2024-01-21 19:46
# Generated by Django 4.1.10 on 2024-01-21 19:46
from
django.db
import
migrations
import
wagtail.blocks
import
wagtail.blocks
import
wagtail.fields
import
wagtail.fields
import
wagtail.images.blocks
import
wagtail.images.blocks
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
class
Migration
(
migrations
.
Migration
):
...
...
This diff is collapsed.
Click to expand it.
shared/jekyll_import.py
+
11
−
6
View file @
92b9bce6
...
@@ -8,6 +8,7 @@ import urllib
...
@@ -8,6 +8,7 @@ import urllib
import
xml.etree.ElementTree
as
ET
import
xml.etree.ElementTree
as
ET
import
zipfile
import
zipfile
from
datetime
import
date
,
datetime
from
datetime
import
date
,
datetime
from
datetime
import
timezone
as
datetime_timezone
from
http.client
import
InvalidURL
from
http.client
import
InvalidURL
from
io
import
StringIO
from
io
import
StringIO
from
typing
import
List
from
typing
import
List
...
@@ -611,15 +612,16 @@ class JekyllArticleImporter:
...
@@ -611,15 +612,16 @@ class JekyllArticleImporter:
if
meta
.
get
(
"
date
"
,
None
):
if
meta
.
get
(
"
date
"
,
None
):
meta_date
=
meta
[
"
date
"
]
meta_date
=
meta
[
"
date
"
]
if
isinstance
(
meta_date
,
date
):
if
isinstance
(
meta_date
,
date
):
article
.
date
=
meta_date
article
.
timestamp
=
datetime
(
meta_date
.
year
,
meta_date
.
month
,
meta_date
.
day
).
replace
(
tzinfo
=
datetime_timezone
.
utc
)
else
:
else
:
parsed_date
=
meta
[
"
date
"
].
split
()[
0
]
parsed_date
=
meta
[
"
date
"
].
split
()[
0
]
article
.
date
=
(
article
.
timestamp
=
parsed_date
[
0
:
10
]
if
parsed_date
else
timezone
.
now
()
parsed_date
[
0
:
10
]
if
parsed_date
else
timezone
.
now
().
date
()
)
else
:
else
:
article
.
date
=
timezone
.
now
()
.
date
()
article
.
timestamp
=
timezone
.
now
()
article
.
title
=
meta
[
"
title
"
]
article
.
title
=
meta
[
"
title
"
]
article
.
author
=
meta
.
get
(
"
author
"
,
"
Česká pirátská strana
"
)
article
.
author
=
meta
.
get
(
"
author
"
,
"
Česká pirátská strana
"
)
...
@@ -694,7 +696,10 @@ class JekyllArticleImporter:
...
@@ -694,7 +696,10 @@ class JekyllArticleImporter:
self
.
create_summary_log
()
self
.
create_summary_log
()
finally
:
finally
:
os
.
remove
(
f
"
/tmp/.
{
self
.
article_parent_page_id
}
.import-lock
"
)
import_lock_filename
=
f
"
/tmp/.
{
self
.
article_parent_page_id
}
.import-lock
"
if
os
.
path
.
exists
(
import_lock_filename
):
os
.
remove
(
import_lock_filename
)
def
process_article
(
self
,
file_name
:
str
,
file_path
:
str
):
def
process_article
(
self
,
file_name
:
str
,
file_path
:
str
):
match
=
re
.
match
(
r
"
(\d*)-(\d*)-(\d*)-(.*)\.(.*)
"
,
file_name
)
match
=
re
.
match
(
r
"
(\d*)-(\d*)-(\d*)-(.*)\.(.*)
"
,
file_name
)
...
...
This diff is collapsed.
Click to expand it.
shared/models/base.py
+
5
−
0
View file @
92b9bce6
...
@@ -9,6 +9,7 @@ from django.core.paginator import Paginator
...
@@ -9,6 +9,7 @@ from django.core.paginator import Paginator
from
django.db
import
models
from
django.db
import
models
from
django.db.models
import
Q
from
django.db.models
import
Q
from
django.db.models.expressions
import
F
,
Subquery
,
Value
from
django.db.models.expressions
import
F
,
Subquery
,
Value
from
django.http
import
Http404
from
django.utils
import
timezone
from
django.utils
import
timezone
from
modelcluster.fields
import
ParentalKey
,
ParentalManyToManyField
from
modelcluster.fields
import
ParentalKey
,
ParentalManyToManyField
from
taggit.models
import
ItemBase
,
Tag
,
TagBase
from
taggit.models
import
ItemBase
,
Tag
,
TagBase
...
@@ -803,6 +804,10 @@ class ArticlesMixin:
...
@@ -803,6 +804,10 @@ class ArticlesMixin:
articles
=
self
.
append_all_shared_articles_query
(
articles
=
self
.
append_all_shared_articles_query
(
custom_article_query
=
lambda
query
:
query
.
filter
(
slug
=
slug
)
custom_article_query
=
lambda
query
:
query
.
filter
(
slug
=
slug
)
)[:
1
]
)[:
1
]
if
len
(
articles
)
==
0
:
raise
Http404
return
self
.
materialize_shared_articles_query
(
articles
)[
0
]
return
self
.
materialize_shared_articles_query
(
articles
)[
0
]
def
setup_article_page_context
(
self
,
request
):
def
setup_article_page_context
(
self
,
request
):
...
...
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