Commit 0cd4037b authored by Florent Chehab's avatar 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
......@@ -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):
......
......@@ -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";
/**
......
......@@ -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}/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment