Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Babyfut
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PR-Baby-A18
Babyfut
Commits
72b509e5
Commit
72b509e5
authored
Jan 17, 2019
by
Antoine Lima
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed profile pictures not displaying!!
parent
efbf04ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
115 deletions
+65
-115
core/downloader.py
core/downloader.py
+7
-3
core/player.py
core/player.py
+13
-7
translations/babyfut_fr.ts
translations/babyfut_fr.ts
+6
-6
ui/authleague.ui
ui/authleague.ui
+3
-24
ui/authquick.ui
ui/authquick.ui
+16
-43
ui/endgame.ui
ui/endgame.ui
+20
-32
No files found.
core/downloader.py
View file @
72b509e5
...
...
@@ -46,9 +46,13 @@ class Downloader(Thread, QObject):
if
nAttemps
==
None
:
nAttemps
=
Downloader
.
N_ATTEMPS
print
(
'Adding "{}". {} before it'
.
format
(
url_in
,
len
(
self
.
_request_stack
)))
self
.
_request_stack
.
append
((
url_in
,
uri_out
,
nAttemps
))
# Add if not already queued
req
=
(
url_in
,
uri_out
,
nAttemps
)
if
req
not
in
self
.
_request_stack
:
logging
.
debug
(
'Adding "{}". {} before it'
.
format
(
url_in
,
len
(
self
.
_request_stack
)))
self
.
_request_stack
.
append
(
req
)
else
:
logging
.
debug
(
'"{}" is already queued, ignoring.'
.
format
(
url_in
))
def
run
(
self
):
while
not
self
.
_close
:
...
...
core/player.py
View file @
72b509e5
...
...
@@ -4,6 +4,7 @@
@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""
import
os
import
logging
from
enum
import
Enum
from
http
import
HTTPStatus
...
...
@@ -13,6 +14,7 @@ from PyQt5.QtGui import QPixmap
from
PyQt5.QtWidgets
import
QDialog
,
QApplication
from
Babyfut.babyfut
import
getMainWin
,
IMG_PATH
from
Babyfut.core.downloader
import
Downloader
from
Babyfut.core.ginger
import
Ginger
from
Babyfut.core.database
import
Database
,
DatabaseError
from
Babyfut.ui.consent_dialog_ui
import
Ui_Dialog
as
ConsentDialogUI
...
...
@@ -62,6 +64,7 @@ class Player(QObject):
__query_victories
=
'SELECT COUNT(*) AS victories FROM Players INNER JOIN Teams ON (Players.id==Teams.player1 OR Players.id==Teams.player2) INNER JOIN Matchs ON (Teams.id==Matchs.winningTeam) WHERE Players.id==?'
_placeholder_pic_path
=
':ui/img/placeholder_head.jpg'
_utcPictureURL
=
'https://demeter.utc.fr/portal/pls/portal30/portal30.get_photo_utilisateur?username={}'
def
__init__
(
self
,
id
,
rfid
,
login
,
fname
,
lname
,
stats
=
None
):
QObject
.
__init__
(
self
)
...
...
@@ -98,7 +101,6 @@ class Player(QObject):
return
player
def
displayImg
(
self
,
container_widget
):
@
staticmethod
def
_loadFromDB
(
rfid
):
db
=
Database
.
instance
()
...
...
@@ -128,7 +130,7 @@ class Player(QObject):
'''
response
=
Ginger
.
call
(
'badge/{}'
.
format
(
rfid
))
if
isinstance
(
response
,
HTTPStatus
):
logging
.
debug
(
'Request to Ginger failed ({}): returning Guest'
.
format
(
response
.
value
))
logging
.
warn
(
'Request to Ginger failed ({}): returning Guest'
.
format
(
response
.
value
))
return
PlayerGuest
else
:
infos
=
json
.
loads
(
response
)
...
...
@@ -136,24 +138,28 @@ class Player(QObject):
return
Player
.
_loadFromDB
(
rfid
)
def
displayImg
(
self
,
container_widget
,
*
args
):
self
.
pic_container
=
container_widget
if
self
.
pic_path
.
startswith
(
'http'
):
# Download from the internet
# Download from the internet
but display a temporary image between
self
.
pic_container
.
setStyleSheet
(
'border-image: url({});'
.
format
(
Player
.
_placeholder_pic_path
))
Downloader
.
instance
().
request
(
self
.
pic_path
,
os
.
path
.
join
(
IMG_PATH
,
'{}.jpg'
.
format
(
self
.
id
)))
Downloader
.
instance
().
finished
.
connect
(
self
.
_downloader_callback
)
else
:
# Already downloaded and stored locally
self
.
pic_container
.
setStyleSheet
(
'border-image: url({});'
.
format
(
self
.
pic_path
))
self
.
_forceWidgetUpdate
()
QApplication
.
processEvents
()
@
pyqtSlot
(
str
)
def
_downloader_callback
(
self
,
path
):
self
.
pic_path
=
path
Downloader
.
instance
().
finished
.
disconnect
(
self
.
_downloader_callback
)
self
.
displayImg
(
self
.
pic_container
)
# Take the callback if not already done and we are the targer
if
IMG_PATH
in
path
and
str
(
self
.
id
)
in
path
and
IMG_PATH
not
in
self
.
pic_path
:
self
.
pic_path
=
path
Downloader
.
instance
().
finished
.
disconnect
(
self
.
_downloader_callback
)
if
self
.
pic_container
!=
None
:
self
.
displayImg
(
self
.
pic_container
)
def
forgetPicture
(
self
):
self
.
pic_path
=
Player
.
_placeholder_pic_path
...
...
translations/babyfut_fr.ts
View file @
72b509e5
...
...
@@ -46,12 +46,12 @@
<
translation
>
Form
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
31
"
/>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
22
"
/>
<
source
>
Identify
yourselves
!
<
/source
>
<
translation
>
Identifiez
vous
!
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
32
"
/>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
23
"
/>
<
source
>
Use
the
table
&
apos
;
s
RFID
reader
with
your
card
.
<
/source
>
<
translation
>
Utilisez
les
lecteurs
RFID
de
la
table
avec
votre
carte
étu
.
<
/translation
>
<
/message
>
...
...
@@ -61,7 +61,7 @@
<
translation
>
Nom
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authleague_ui.py
"
line
=
"
1
47
"
/>
<
location
filename
=
"
../ui/authleague_ui.py
"
line
=
"
1
38
"
/>
<
source
>
Stat
<
/source
>
<
translation
>
Stat
<
/translation
>
<
/message
>
...
...
@@ -76,17 +76,17 @@
<
translation
>
Joueur
2
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
35
"
/>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
26
"
/>
<
source
>
vs
.
<
/source
>
<
translation
>
vs
.
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
36
"
/>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
27
"
/>
<
source
>
Player
3
<
/source
>
<
translation
>
Joueur
3
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
37
"
/>
<
location
filename
=
"
../ui/authquick_ui.py
"
line
=
"
2
28
"
/>
<
source
>
Player
4
<
/source
>
<
translation
>
Joueur
4
<
/translation
>
<
/message
>
...
...
ui/authleague.ui
View file @
72b509e5
...
...
@@ -97,36 +97,15 @@
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_5"
>
<item>
<widget
class=
"QLabel"
name=
"img"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<widget
class=
"QWidget"
name=
"img"
native=
"true"
>
<property
name=
"minimumSize"
>
<size>
<width>
300
</width>
<height>
300
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
200
</width>
<height>
200
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
<property
name=
"pixmap"
>
<pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap>
</property>
<property
name=
"scaledContents"
>
<bool>
true
</bool>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string>
</property>
</widget>
</item>
...
...
ui/authquick.ui
View file @
72b509e5
...
...
@@ -107,9 +107,9 @@
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_5"
>
<item>
<widget
class=
"Q
Label"
name=
"imgP1
"
>
<widget
class=
"Q
Widget"
name=
"imgP1"
native=
"true
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferr
ed"
>
<sizepolicy
hsizetype=
"
Fixed"
vsizetype=
"Fix
ed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -126,17 +126,8 @@
<height>
200
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
<property
name=
"pixmap"
>
<pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap>
</property>
<property
name=
"scaledContents"
>
<bool>
true
</bool>
</property>
<property
name=
"alignment"
>
<set>
Qt::AlignCenter
</set>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string>
</property>
</widget>
</item>
...
...
@@ -185,9 +176,9 @@
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_6"
>
<item>
<widget
class=
"Q
Label"
name=
"imgP2
"
>
<widget
class=
"Q
Widget"
name=
"imgP2"
native=
"true
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferr
ed"
>
<sizepolicy
hsizetype=
"
Fixed"
vsizetype=
"Fix
ed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -204,14 +195,8 @@
<height>
200
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
<property
name=
"pixmap"
>
<pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap>
</property>
<property
name=
"scaledContents"
>
<bool>
true
</bool>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string>
</property>
</widget>
</item>
...
...
@@ -337,9 +322,9 @@
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_7"
>
<item>
<widget
class=
"Q
Label"
name=
"imgP3
"
>
<widget
class=
"Q
Widget"
name=
"imgP3"
native=
"true
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferr
ed"
>
<sizepolicy
hsizetype=
"
Fixed"
vsizetype=
"Fix
ed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -356,14 +341,8 @@
<height>
200
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
<property
name=
"pixmap"
>
<pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap>
</property>
<property
name=
"scaledContents"
>
<bool>
true
</bool>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string>
</property>
</widget>
</item>
...
...
@@ -412,9 +391,9 @@
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_9"
>
<item>
<widget
class=
"Q
Label"
name=
"imgP4
"
>
<widget
class=
"Q
Widget"
name=
"imgP4"
native=
"true
"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferr
ed"
>
<sizepolicy
hsizetype=
"
Fixed"
vsizetype=
"Fix
ed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -431,14 +410,8 @@
<height>
200
</height>
</size>
</property>
<property
name=
"text"
>
<string/>
</property>
<property
name=
"pixmap"
>
<pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap>
</property>
<property
name=
"scaledContents"
>
<bool>
true
</bool>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string>
</property>
</widget>
</item>
...
...
ui/endgame.ui
View file @
72b509e5
...
...
@@ -69,13 +69,7 @@
<widget
class=
"QWidget"
name=
"widgetLayoutP1"
native=
"true"
>
<layout
class=
"QVBoxLayout"
name=
"layoutP1"
>
<item>
<widget
class=
"QLabel"
name=
"imgP1"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<widget
class=
"QWidget"
name=
"imgP1"
native=
"true"
>
<property
name=
"minimumSize"
>
<size>
<width>
400
</width>
...
...
@@ -84,18 +78,18 @@
</property>
<property
name=
"maximumSize"
>
<size>
<width>
3
00
</width>
<height>
3
00
</height>
<width>
4
00
</width>
<height>
4
00
</height>
</size>
</property>
<property
name=
"
text
"
>
<s
tring/
>
</property
>
<property
name=
"pixmap"
>
<
pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap
>
<property
name=
"
baseSize
"
>
<s
ize
>
<width>
400
</width
>
<height>
400
</height
>
<
/size
>
</property>
<property
name=
"s
caledContents
"
>
<
bool>
true
</bool
>
<property
name=
"s
tyleSheet
"
>
<
string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string
>
</property>
</widget>
</item>
...
...
@@ -159,13 +153,7 @@
<widget
class=
"QWidget"
name=
"widgetLayoutP2"
native=
"true"
>
<layout
class=
"QVBoxLayout"
name=
"layoutP2"
>
<item>
<widget
class=
"QLabel"
name=
"imgP2"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Preferred"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
<widget
class=
"QWidget"
name=
"ImgP2"
native=
"true"
>
<property
name=
"minimumSize"
>
<size>
<width>
400
</width>
...
...
@@ -174,18 +162,18 @@
</property>
<property
name=
"maximumSize"
>
<size>
<width>
3
00
</width>
<height>
3
00
</height>
<width>
4
00
</width>
<height>
4
00
</height>
</size>
</property>
<property
name=
"
text
"
>
<s
tring/
>
</property
>
<property
name=
"pixmap"
>
<
pixmap
resource=
"assets.qrc"
>
:/ui/img/placeholder_head.jpg
</pixmap
>
<property
name=
"
baseSize
"
>
<s
ize
>
<width>
400
</width
>
<height>
400
</height
>
<
/size
>
</property>
<property
name=
"s
caledContents
"
>
<
bool>
true
</bool
>
<property
name=
"s
tyleSheet
"
>
<
string
notr=
"true"
>
border-image: url(:/ui/img/placeholder_head.jpg);
</string
>
</property>
</widget>
</item>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment