Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
0cd4037b
Commit
0cd4037b
authored
Apr 14, 2019
by
Florent Chehab
Browse files
Cleaned user info serializer and enhanced frotend.
removed compose related to redux
parent
de5ba0a3
Pipeline
#38369
passed with stages
in 3 minutes and 59 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
backend/base_app/models.py
View file @
0cd4037b
...
...
@@ -4,7 +4,6 @@ from django.contrib.auth.models import AbstractUser
from
django.core.exceptions
import
ValidationError
from
django.db
import
models
from
django.utils.functional
import
cached_property
from
rest_framework
import
serializers
from
rest_framework.response
import
Response
from
backend_app.models.abstract.base
import
BaseModelSerializer
...
...
@@ -54,17 +53,6 @@ class User(AbstractUser):
class
UserSerializer
(
BaseModelSerializer
):
# Read only fields
username
=
serializers
.
CharField
(
read_only
=
True
)
first_name
=
serializers
.
CharField
(
read_only
=
True
)
last_name
=
serializers
.
CharField
(
read_only
=
True
)
email
=
serializers
.
EmailField
(
read_only
=
True
)
# fields that the user can modify
allow_sharing_personal_info
=
serializers
.
BooleanField
()
secondary_email
=
serializers
.
EmailField
()
pseudo
=
serializers
.
CharField
()
def
validate
(
self
,
attrs
):
"""
Also validate at the serializer level to prevent error 500
...
...
@@ -86,6 +74,7 @@ class UserSerializer(BaseModelSerializer):
"pseudo"
,
"is_staff"
,
)
read_only_fields
=
(
"username"
,
"first_name"
,
"last_name"
,
"email"
)
class
UserViewset
(
BaseModelViewSet
):
...
...
frontend/src/components/pages/PageUser.js
View file @
0cd4037b
...
...
@@ -8,8 +8,8 @@ import CheckCircleIcon from "@material-ui/icons/CheckCircle";
import
Fab
from
"
@material-ui/core/Fab
"
;
import
Grid
from
"
@material-ui/core/Grid
"
;
import
Divider
from
"
@material-ui/core/Divider
"
;
import
{
compose
}
from
"
redux
"
;
import
UserInfo
from
"
../user/UserInfo
"
;
import
{
compose
}
from
"
recompose
"
;
/**
...
...
frontend/src/components/user/UserInfo.js
View file @
0cd4037b
...
...
@@ -7,10 +7,10 @@ import SendIcon from "@material-ui/icons/Send";
import
CancelIcon
from
"
@material-ui/icons/Cancel
"
;
import
CheckCircleIcon
from
"
@material-ui/icons/CheckCircle
"
;
import
CustomComponentForAPI
from
"
../common/CustomComponentForAPI
"
;
import
{
compose
}
from
"
redux
"
;
import
getActions
from
"
../../redux/api/getActions
"
;
import
{
connect
}
from
"
react-redux
"
;
import
SameLine
from
"
../common/SameLine
"
;
import
{
compose
}
from
"
recompose
"
;
import
UserInfoEditor
from
"
./UserInfoEditor
"
;
import
CreateIcon
from
"
@material-ui/icons/Create
"
;
...
...
@@ -138,18 +138,24 @@ class UserInfo extends CustomComponentForAPI {
variant={"h6"}
text={"Autre adresse de contact"}/>
{
displayData ?
<Button variant="outlined"
color="secondary"
className={classes.button}
href={`mailto:${secondaryEmail}`}>
{secondaryEmail} <SendIcon className={classes.rightIcon}/>
</Button>
: <></>
displayData && secondaryEmail !== null ?
<>
<Button variant="outlined"
color="secondary"
className={classes.button}
href={`mailto:${secondaryEmail}`}>
{secondaryEmail} <SendIcon className={classes.rightIcon}/>
</Button>
<Typography variant="caption">
Cette adresse mail a été mise à disposition par la personne comme autre point de contact.
</Typography>
</>
:
<Typography variant="caption">
Aucune addresse email secondaire n
'
est
disponible
.
<
/Typography
>
}
<Typography variant="caption">
Cette adresse mail a été mise à disposition par la personne comme autre point de contact.
</Typography>
<
div
className
=
{
classes
.
spacer
}
/
>
...
...
Write
Preview
Supports
Markdown
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