Request get exos
This commit is contained in:
parent
bf62ac718b
commit
58646f7cd9
@ -70,7 +70,11 @@ class ExerciceAPI(APIView):
|
|||||||
userExosListSorted = userExos
|
userExosListSorted = userExos
|
||||||
|
|
||||||
if code != 'all' and code != 'pdf' and code != "web":
|
if code != 'all' and code != 'pdf' and code != "web":
|
||||||
exo = Exercice.objects.get(id_code=code)
|
try:
|
||||||
|
exo = Exercice.objects.get(id_code=code)
|
||||||
|
except:
|
||||||
|
exo = None
|
||||||
|
return Response({'error': "Not found"}, status= status.HTTP_404_NOT_FOUND)
|
||||||
isUser = False
|
isUser = False
|
||||||
if request.user == exo.author:
|
if request.user == exo.author:
|
||||||
isUser = True
|
isUser = True
|
||||||
|
@ -29,14 +29,16 @@ export default function ModalCard({ step, onClose, onDelete, tags, queryKey }) {
|
|||||||
const alert = useAlert();
|
const alert = useAlert();
|
||||||
const [edit, setEdit] = useState(false);
|
const [edit, setEdit] = useState(false);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isLoading: isUpdating,
|
isLoading: isUpdating,
|
||||||
isFetching,
|
isFetching,
|
||||||
data: step_data,
|
data: step_data,
|
||||||
} = useQuery(
|
} = useQuery(
|
||||||
["exo-data", step.id_code],
|
["exo-data", step.id_code],
|
||||||
async () => await getExos(step.id_code),
|
async () => await getExos(step.id_code).catch(() => {
|
||||||
|
notificationService.error('Erreur', "Exercice introuvable")
|
||||||
|
}),
|
||||||
{ initialData: step, refetchOnWindowFocus: !edit }
|
{ initialData: step, refetchOnWindowFocus: !edit }
|
||||||
);
|
);
|
||||||
const [selected, setSelected] = useState([]);
|
const [selected, setSelected] = useState([]);
|
||||||
|
Loading…
Reference in New Issue
Block a user