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
61ab88ec
Verified
Commit
61ab88ec
authored
1 year ago
by
jindra12
Browse files
Options
Downloads
Patches
Plain Diff
Add conversion
#210
parent
e6480fbc
No related branches found
No related tags found
2 merge requests
!816
Release
,
!801
Prepare basic shared tags
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
shared/models.py
+60
-23
60 additions, 23 deletions
shared/models.py
with
60 additions
and
23 deletions
shared/models.py
+
60
−
23
View file @
61ab88ec
...
...
@@ -421,31 +421,68 @@ class ArticlesMixin(models.Model):
results
=
results
.
order_by
(
"
union_date
"
)
evaluated
=
list
(
results
)
evaluated
=
list
(
results
)
# We MUST eval here since we can't turn values() into concrete class instances in QuerySet after union
mapped_to_real_values
=
list
(
if
source
is
SharedArticleTypes
.
DISTRICT
:
return
list
(
map
(
lambda
unioned
:
{
"
id
"
:
unioned
[
"
union_id
"
],
"
page_ptr_id
"
:
unioned
[
"
union_page_ptr_id
"
],
"
perex
"
:
unioned
[
"
union_perex
"
],
"
date
"
:
unioned
[
"
union_date
"
],
"
author
"
:
unioned
[
"
union_author
"
],
"
image_id
"
:
unioned
[
"
union_image_id
"
],
"
search_image_id
"
:
unioned
[
"
union_search_image_id
"
],
"
content
"
:
unioned
[
"
union_content
"
],
"
author_page_id
"
:
unioned
[
"
union_author_page_id
"
],
"
region
"
:
unioned
[
"
union_author_page_id
"
],
"
article_type
"
:
unioned
[
"
union_article_type
"
],
"
is_black
"
:
unioned
[
"
union_is_black
"
],
"
thumb_image_id
"
:
unioned
[
"
union_thumb_image_id
"
],
"
shared
"
:
unioned
[
"
shared
"
],
},
lambda
unioned
:
DistrictArticlePage
(
id
=
unioned
[
"
union_id
"
],
page_ptr_id
=
unioned
[
"
union_page_ptr_id
"
],
perex
=
unioned
[
"
union_perex
"
],
date
=
unioned
[
"
union_date
"
],
author
=
unioned
[
"
union_author
"
],
image_id
=
unioned
[
"
union_image_id
"
],
search_image_id
=
unioned
[
"
union_search_image_id
"
],
content
=
unioned
[
"
union_content
"
],
author_page_id
=
unioned
[
"
union_author_page_id
"
],
is_black
=
unioned
[
"
union_is_black
"
],
thumb_image_id
=
unioned
[
"
union_thumb_image_id
"
],
),
evaluated
,
)
)
return
mapped_to_real_values
if
source
is
SharedArticleTypes
.
UNIWEB
:
return
list
(
map
(
lambda
unioned
:
UniwebArticlePage
(
id
=
unioned
[
"
union_id
"
],
page_ptr_id
=
unioned
[
"
union_page_ptr_id
"
],
perex
=
unioned
[
"
union_perex
"
],
date
=
unioned
[
"
union_date
"
],
author
=
unioned
[
"
union_author
"
],
image_id
=
unioned
[
"
union_image_id
"
],
search_image_id
=
unioned
[
"
union_search_image_id
"
],
content
=
unioned
[
"
union_content
"
],
),
evaluated
,
)
)
if
source
is
SharedArticleTypes
.
MAIN
:
return
list
(
map
(
lambda
unioned
:
MainArticlePage
(
id
=
unioned
[
"
union_id
"
],
page_ptr_id
=
unioned
[
"
union_page_ptr_id
"
],
perex
=
unioned
[
"
union_perex
"
],
date
=
unioned
[
"
union_date
"
],
author
=
unioned
[
"
union_author
"
],
image_id
=
unioned
[
"
union_image_id
"
],
search_image_id
=
unioned
[
"
union_search_image_id
"
],
content
=
unioned
[
"
union_content
"
],
author_page_id
=
unioned
[
"
union_author_page_id
"
],
region
=
unioned
[
"
union_author_page_id
"
],
article_type
=
unioned
[
"
union_article_type
"
],
is_black
=
unioned
[
"
union_is_black
"
],
thumb_image_id
=
unioned
[
"
union_thumb_image_id
"
],
),
evaluated
,
)
)
def
get_article_page_by_slug
(
self
,
slug
:
str
):
articles
=
self
.
append_all_shared_articles
()
...
...
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