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
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
hemp
Maják
Commits
d4e8d34d
Commit
d4e8d34d
authored
4 years ago
by
jarmil
Committed by
jan.bednarik
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Napojeni na medailonky
parent
557f9699
No related branches found
Branches containing commit
No related tags found
No related merge requests found
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 @
d4e8d34d
# 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 @
d4e8d34d
...
...
@@ -2,6 +2,7 @@ import random
import
requests
import
requests_cache
from
django.core.validators
import
MaxValueValidator
,
MinValueValidator
from
django.db
import
models
from
modelcluster.contrib.taggit
import
ClusterTaggableManager
from
modelcluster.fields
import
ParentalKey
...
...
@@ -81,11 +82,18 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
# ve formatu iapi: https://iapi.pirati.cz/v1/user?username=john.doe
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
)
content_panels
=
Page
.
content_panels
+
[
FieldPanel
(
"
pirate_id
"
),
FieldPanel
(
"
profile_id
"
),
FieldPanel
(
"
perex
"
),
]
...
...
@@ -95,33 +103,38 @@ class PersonPage(SharedSubpageMixin, MetadataPageMixin, Page):
"
https://iapi.pirati.cz/v1/user?username=%s
"
%
self
.
pirate_id
).
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
def
name
(
self
):
return
self
.
_iapi
().
get
(
"
displayname
"
)
@property
def
email
(
self
):
return
self
.
_graph
().
get
(
"
email
"
)
try
:
return
self
.
_iapi
()[
"
profiles
"
][
self
.
profile_id
][
"
email
"
]
except
(
IndexError
,
KeyError
):
return
None
@property
def
phone
(
self
):
return
None
# TODO
try
:
return
self
.
_iapi
()[
"
profiles
"
][
self
.
profile_id
][
"
phone
"
]
except
(
IndexError
,
KeyError
):
return
None
@property
def
longtext
(
self
):
# medailonek
return
"
Lorem ipsum dolor amet
"
# TODO
return
""
# TODO
@property
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
def
facebook
(
self
):
return
"
https://www.facebook.com/ales.fuksa.9
"
# TODO
return
None
# TODO
class
Meta
:
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