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
e4d9fdfa
Commit
e4d9fdfa
authored
4 years ago
by
jarmil
Browse files
Options
Downloads
Patches
Plain Diff
Napojeni na medailonky
parent
92379087
No related branches found
No related tags found
2 merge requests
!173
Release
,
!134
Weby pro MS
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
shared/migrations/0011_personpage_profile_id.py
+27
-0
27 additions, 0 deletions
shared/migrations/0011_personpage_profile_id.py
shared/models.py
+22
-9
22 additions, 9 deletions
shared/models.py
with
49 additions
and
9 deletions
shared/migrations/0011_personpage_profile_id.py
0 → 100644
+
27
−
0
View file @
e4d9fdfa
# Generated by Django 3.1.1 on 2020-10-20 03:14
import
django.core.validators
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
"
shared
"
,
"
0010_article_author
"
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
"
personpage
"
,
name
=
"
profile_id
"
,
field
=
models
.
IntegerField
(
blank
=
True
,
default
=
0
,
validators
=
[
django
.
core
.
validators
.
MinValueValidator
(
0
),
django
.
core
.
validators
.
MaxValueValidator
(
2
),
],
verbose_name
=
"
Číslo medailonku (0..2) z lide.pirati.cz
"
,
),
),
]
This diff is collapsed.
Click to expand it.
shared/models.py
+
22
−
9
View file @
e4d9fdfa
...
@@ -2,6 +2,7 @@ import random
...
@@ -2,6 +2,7 @@ import random
import
requests
import
requests
import
requests_cache
import
requests_cache
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
from
django.db
import
models
from
django.db
import
models
from
modelcluster.contrib.taggit
import
ClusterTaggableManager
from
modelcluster.contrib.taggit
import
ClusterTaggableManager
from
modelcluster.fields
import
ParentalKey
from
modelcluster.fields
import
ParentalKey
...
@@ -81,11 +82,18 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
...
@@ -81,11 +82,18 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
# ve formatu iapi: https://iapi.pirati.cz/v1/user?username=john.doe
# ve formatu iapi: https://iapi.pirati.cz/v1/user?username=john.doe
pirate_id
=
models
.
TextField
(
"
Pirate ID osoby
"
,
blank
=
False
)
pirate_id
=
models
.
TextField
(
"
Pirate ID osoby
"
,
blank
=
False
)
profile_id
=
models
.
IntegerField
(
"
Číslo medailonku (0..2) z lide.pirati.cz
"
,
blank
=
True
,
default
=
0
,
validators
=
[
MinValueValidator
(
0
),
MaxValueValidator
(
2
)],
)
perex
=
models
.
TextField
(
"
Perex osoby
"
,
blank
=
True
)
perex
=
models
.
TextField
(
"
Perex osoby
"
,
blank
=
True
)
content_panels
=
Page
.
content_panels
+
[
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
"
pirate_id
"
),
FieldPanel
(
"
pirate_id
"
),
FieldPanel
(
"
profile_id
"
),
FieldPanel
(
"
perex
"
),
FieldPanel
(
"
perex
"
),
]
]
...
@@ -95,33 +103,38 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
...
@@ -95,33 +103,38 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
"
https://iapi.pirati.cz/v1/user?username=%s
"
%
self
.
pirate_id
"
https://iapi.pirati.cz/v1/user?username=%s
"
%
self
.
pirate_id
).
json
()
).
json
()
def
_graph
(
self
):
"""
Vrati data o osobe z graph.pirati.cz (forum) jako json. Cached via requests_cache
"""
return
requests
.
get
(
"
https://graph.pirati.cz/user/%s
"
%
self
.
pirate_id
).
json
()
@property
@property
def
name
(
self
):
def
name
(
self
):
return
self
.
_iapi
().
get
(
"
displayname
"
)
return
self
.
_iapi
().
get
(
"
displayname
"
)
@property
@property
def
email
(
self
):
def
email
(
self
):
return
self
.
_graph
().
get
(
"
email
"
)
try
:
return
self
.
_iapi
()[
"
profiles
"
][
self
.
profile_id
][
"
email
"
]
except
(
IndexError
,
KeyError
):
return
None
@property
@property
def
phone
(
self
):
def
phone
(
self
):
return
None
# TODO
try
:
return
self
.
_iapi
()[
"
profiles
"
][
self
.
profile_id
][
"
phone
"
]
except
(
IndexError
,
KeyError
):
return
None
@property
@property
def
longtext
(
self
):
# medailonek
def
longtext
(
self
):
# medailonek
return
"
Lorem ipsum dolor amet
"
# TODO
return
""
# TODO
@property
@property
def
portrait
(
self
):
# profilova fotka
def
portrait
(
self
):
# profilova fotka
return
"
https://lide.pirati.cz/media/person/61/profile/1312/2.jpg
"
# TODO
try
:
return
self
.
_iapi
()[
"
profiles
"
][
self
.
profile_id
][
"
photo
"
]
except
(
IndexError
,
KeyError
):
return
None
@property
@property
def
facebook
(
self
):
def
facebook
(
self
):
return
"
https://www.facebook.com/ales.fuksa.9
"
# TODO
return
None
# TODO
class
Meta
:
class
Meta
:
verbose_name
=
"
Člověk
"
# to zni hrde
verbose_name
=
"
Člověk
"
# to zni hrde
...
...
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