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
44698cfd
Commit
44698cfd
authored
2 years ago
by
quido.zientek
Browse files
Options
Downloads
Patches
Plain Diff
main models.py reformatted
parent
b6189376
No related branches found
No related tags found
3 merge requests
!607
Pirati.cz
,
!600
Article menu
,
!575
Feature/pirati cz
Pipeline
#9551
passed
2 years ago
Stage: build
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.isort.cfg
+1
-1
1 addition, 1 deletion
.isort.cfg
.pre-commit-config.yaml
+1
-1
1 addition, 1 deletion
.pre-commit-config.yaml
main/models.py
+37
-29
37 additions, 29 deletions
main/models.py
with
39 additions
and
31 deletions
.isort.cfg
+
1
−
1
View file @
44698cfd
...
...
@@ -3,4 +3,4 @@
line_length
=
88
multi_line_output
=
3
include_trailing_comma
=
true
known_third_party
=
PyPDF2,arrow,bleach,bs4,captcha,celery,django,environ,faker,fastjsonschema,icalevnt,markdown,modelcluster,pirates,pytest,pytz,requests,sentry_sdk,taggit,tweepy,wagtail,wagtailmetadata,weasyprint,yaml
,zoneinfo
known_third_party
=
PyPDF2,arrow,bleach,bs4,captcha,celery,django,environ,faker,fastjsonschema,icalevnt,markdown,modelcluster,pirates,pytest,pytz,requests,sentry_sdk,taggit,tweepy,wagtail,wagtailmetadata,weasyprint,yaml
This diff is collapsed.
Click to expand it.
.pre-commit-config.yaml
+
1
−
1
View file @
44698cfd
default_language_version
:
python
:
python3.
8
python
:
python3.
9
exclude
:
snapshots/
repos
:
...
...
This diff is collapsed.
Click to expand it.
main/models.py
+
37
−
29
View file @
44698cfd
...
...
@@ -180,39 +180,41 @@ class MainHomePage(MenuMixin, ExtendedMetadataHomePageMixin, MetadataPageMixin,
def
get_region_response
(
self
,
request
):
last_month
=
timezone
.
now
().
today
().
replace
(
day
=
1
)
-
timedelta
(
days
=
1
)
first_day_of_last_month
=
last_month
.
replace
(
day
=
1
)
if
request
.
GET
.
get
(
'
region
'
,
None
)
==
'
VSK
'
:
if
request
.
GET
.
get
(
"
region
"
,
None
)
==
"
VSK
"
:
sorted_article_qs
=
MainArticlePage
.
objects
.
filter
(
date__gt
=
first_day_of_last_month
).
order_by
(
"
-date
"
)
else
:
sorted_article_qs
=
MainArticlePage
.
objects
.
filter
(
date__gt
=
first_day_of_last_month
,
region
=
request
.
GET
.
get
(
'
region
'
,
None
)
date__gt
=
first_day_of_last_month
,
region
=
request
.
GET
.
get
(
"
region
"
,
None
)
).
order_by
(
"
-date
"
)
context
=
{
"
article_data_list
"
:
sorted_article_qs
[:
3
]
}
context
=
{
"
article_data_list
"
:
sorted_article_qs
[:
3
]}
data
=
{
'
html
'
:
render
(
request
,
'
main/includes/small_article_preview.html
'
,
context
).
content
.
decode
(
"
utf-8
"
)
"
html
"
:
render
(
request
,
"
main/includes/small_article_preview.html
"
,
context
).
content
.
decode
(
"
utf-8
"
)
}
return
JsonResponse
(
data
=
data
,
safe
=
False
)
def
get_twitter_response
(
self
,
request
):
tweet_paginator
=
Paginator
(
Tweet
.
objects
.
order_by
(
"
-twitter_id
"
),
self
.
max_items
)
tweet_page
=
tweet_paginator
.
get_page
(
request
.
GET
.
get
(
'
page
'
,
1
))
context
=
{
"
tweet_list
"
:
tweet_page
.
object_list
}
html_content
=
render
(
request
,
'
main/includes/twitter_widget.html
'
,
context
).
content
tweet_paginator
=
Paginator
(
Tweet
.
objects
.
order_by
(
"
-twitter_id
"
),
self
.
max_items
)
tweet_page
=
tweet_paginator
.
get_page
(
request
.
GET
.
get
(
"
page
"
,
1
))
context
=
{
"
tweet_list
"
:
tweet_page
.
object_list
}
html_content
=
render
(
request
,
"
main/includes/twitter_widget.html
"
,
context
).
content
data
=
{
'
html
'
:
html_content
.
decode
(
"
utf-8
"
),
'
last_page
'
:
tweet_page
.
paginator
.
num_pages
,
"
html
"
:
html_content
.
decode
(
"
utf-8
"
),
"
last_page
"
:
tweet_page
.
paginator
.
num_pages
,
}
return
JsonResponse
(
data
=
data
,
safe
=
False
)
def
serve
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
META
.
get
(
'
HTTP_X_REQUESTED_WITH
'
)
==
'
XMLHttpRequest
'
:
if
not
request
.
META
.
get
(
"
HTTP_X_REQUESTED_WITH
"
)
==
"
XMLHttpRequest
"
:
return
super
().
serve
(
request
,
*
args
,
**
kwargs
)
if
'
region
'
in
request
.
GET
:
if
"
region
"
in
request
.
GET
:
return
self
.
get_region_response
(
request
)
else
:
return
self
.
get_twitter_response
(
request
)
...
...
@@ -336,24 +338,30 @@ class MainArticlesPage(
ctx
=
super
().
get_context
(
request
,
args
,
kwargs
)
article_list
=
self
.
get_article_data_list
(
1
)
ctx
[
"
article_data_list
"
]
=
article_list
ctx
[
"
show_next_articles
"
]
=
MainArticlePage
.
objects
.
filter
(
article_type
=
ARTICLE_TYPES
.
WORK_TIMELINE
).
count
()
>
len
(
article_list
)
ctx
[
"
show_next_articles
"
]
=
MainArticlePage
.
objects
.
filter
(
article_type
=
ARTICLE_TYPES
.
WORK_TIMELINE
).
count
()
>
len
(
article_list
)
return
ctx
def
get_articles_response
(
self
,
request
):
article_list
=
self
.
get_article_data_list
(
int
(
request
.
GET
.
get
(
'
months
'
,
None
)))
context
=
{
"
article_data_list
"
:
article_list
}
article_list
=
self
.
get_article_data_list
(
int
(
request
.
GET
.
get
(
"
months
"
,
None
)))
context
=
{
"
article_data_list
"
:
article_list
}
data
=
{
'
html
'
:
render
(
request
,
'
main/blocks/articles_timeline_block.html
'
,
context
).
content
.
decode
(
"
utf-8
"
),
'
last_article
'
:
article_list
[
-
1
]
==
MainArticlePage
.
objects
.
filter
(
article_type
=
ARTICLE_TYPES
.
WORK_TIMELINE
).
order_by
(
'
-date
'
).
last
()
"
html
"
:
render
(
request
,
"
main/blocks/articles_timeline_block.html
"
,
context
).
content
.
decode
(
"
utf-8
"
),
"
last_article
"
:
article_list
[
-
1
]
==
MainArticlePage
.
objects
.
filter
(
article_type
=
ARTICLE_TYPES
.
WORK_TIMELINE
)
.
order_by
(
"
-date
"
)
.
last
(),
}
return
JsonResponse
(
data
=
data
,
safe
=
False
)
def
serve
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
META
.
get
(
'
HTTP_X_REQUESTED_WITH
'
)
==
'
XMLHttpRequest
'
:
if
not
request
.
META
.
get
(
"
HTTP_X_REQUESTED_WITH
"
)
==
"
XMLHttpRequest
"
:
return
super
().
serve
(
request
,
*
args
,
**
kwargs
)
if
'
months
'
in
request
.
GET
:
if
"
months
"
in
request
.
GET
:
return
self
.
get_articles_response
(
request
)
@staticmethod
...
...
@@ -507,7 +515,7 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
blank
=
True
,
null
=
True
,
verbose_name
=
"
Hlavní obrázek
"
,
related_name
=
"
+
"
related_name
=
"
+
"
,
)
profile_image
=
models
.
ForeignKey
(
...
...
@@ -516,7 +524,7 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
blank
=
True
,
null
=
True
,
verbose_name
=
"
Profilový obrázek
"
,
related_name
=
"
+
"
related_name
=
"
+
"
,
)
before_name
=
models
.
CharField
(
"
Tituly před jménem
"
,
max_length
=
32
,
blank
=
True
,
null
=
True
...
...
@@ -535,7 +543,7 @@ class MainPersonPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin,
blank
=
True
,
null
=
True
,
max_length
=
32
,
help_text
=
"
Uživatelské jméno zadejte bez @ na začátku
"
help_text
=
"
Uživatelské jméno zadejte bez @ na začátku
"
,
)
social_links
=
StreamField
(
...
...
@@ -622,7 +630,7 @@ class MainContactPage(ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin
text
=
StreamField
(
[(
"
two_columns_text
"
,
blocks
.
TwoTextColumnBlock
())],
verbose_name
=
"
Kontaktní informace
"
,
blank
=
True
blank
=
True
,
)
### PANELS
...
...
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