Spaces:
Sleeping
Sleeping
Commit
·
9434a1a
1
Parent(s):
61327a7
liste formations okay good
Browse files- db.sqlite3 +0 -0
- formations/__pycache__/models.cpython-310.pyc +0 -0
- formations/__pycache__/serializers.cpython-310.pyc +0 -0
- formations/__pycache__/views.cpython-310.pyc +0 -0
- formations/migrations/0004_alter_formation_categorie.py +19 -0
- formations/migrations/__pycache__/0004_alter_formation_categorie.cpython-310.pyc +0 -0
- formations/models.py +1 -1
- formations/serializers.py +14 -11
- formations/views.py +7 -6
- media/347258376_752544993542397_8667728642864495466_n.jpg +0 -0
- media/352698142_1334864067071379_6161131225698984499_n.jpg +0 -0
db.sqlite3
CHANGED
Binary files a/db.sqlite3 and b/db.sqlite3 differ
|
|
formations/__pycache__/models.cpython-310.pyc
CHANGED
Binary files a/formations/__pycache__/models.cpython-310.pyc and b/formations/__pycache__/models.cpython-310.pyc differ
|
|
formations/__pycache__/serializers.cpython-310.pyc
CHANGED
Binary files a/formations/__pycache__/serializers.cpython-310.pyc and b/formations/__pycache__/serializers.cpython-310.pyc differ
|
|
formations/__pycache__/views.cpython-310.pyc
CHANGED
Binary files a/formations/__pycache__/views.cpython-310.pyc and b/formations/__pycache__/views.cpython-310.pyc differ
|
|
formations/migrations/0004_alter_formation_categorie.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.5 on 2024-03-23 22:42
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
import django.db.models.deletion
|
5 |
+
|
6 |
+
|
7 |
+
class Migration(migrations.Migration):
|
8 |
+
|
9 |
+
dependencies = [
|
10 |
+
('formations', '0003_rename_video_link_ressourcecours_file_link'),
|
11 |
+
]
|
12 |
+
|
13 |
+
operations = [
|
14 |
+
migrations.AlterField(
|
15 |
+
model_name='formation',
|
16 |
+
name='categorie',
|
17 |
+
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='formations', to='formations.categorieformation'),
|
18 |
+
),
|
19 |
+
]
|
formations/migrations/__pycache__/0004_alter_formation_categorie.cpython-310.pyc
ADDED
Binary file (809 Bytes). View file
|
|
formations/models.py
CHANGED
@@ -23,7 +23,7 @@ class Formation(models.Model):
|
|
23 |
langue_subtitles = models.CharField(max_length=1024)
|
24 |
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
|
25 |
montant = models.DecimalField(default=0, max_digits=16, decimal_places= 2)
|
26 |
-
categorie = models.ForeignKey(CategorieFormation, on_delete=models.SET_NULL, null=True)
|
27 |
created_at = models.DateTimeField(auto_now_add=True)
|
28 |
updated_at = models.DateTimeField(auto_now = True)
|
29 |
|
|
|
23 |
langue_subtitles = models.CharField(max_length=1024)
|
24 |
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
|
25 |
montant = models.DecimalField(default=0, max_digits=16, decimal_places= 2)
|
26 |
+
categorie = models.ForeignKey(CategorieFormation, on_delete=models.SET_NULL, null=True,related_name='formations')
|
27 |
created_at = models.DateTimeField(auto_now_add=True)
|
28 |
updated_at = models.DateTimeField(auto_now = True)
|
29 |
|
formations/serializers.py
CHANGED
@@ -3,33 +3,36 @@ from rest_framework import serializers
|
|
3 |
from django.core.exceptions import ValidationError
|
4 |
from .models import CategorieFormation,Formation,UserFormation,Cours,ArchiveFormation,ListSouhaitFormation,FavorisFormation, PanierUser,AvisFormation,PaiementUser
|
5 |
|
6 |
-
class
|
7 |
|
8 |
class Meta:
|
9 |
-
model =
|
10 |
fields = ('__all__')
|
11 |
|
12 |
-
|
13 |
-
class FormationSerializer(serializers.ModelSerializer):
|
14 |
|
15 |
class Meta:
|
16 |
-
model =
|
17 |
fields = ('__all__')
|
18 |
|
19 |
|
20 |
-
class
|
|
|
|
|
|
|
|
|
21 |
|
22 |
class Meta:
|
23 |
-
model =
|
|
|
24 |
fields = ('__all__')
|
25 |
|
26 |
-
class
|
27 |
-
|
28 |
class Meta:
|
29 |
-
model =
|
30 |
fields = ('__all__')
|
31 |
|
32 |
-
|
33 |
class ListSouhaitFormationSerializer(serializers.ModelSerializer):
|
34 |
|
35 |
class Meta:
|
|
|
3 |
from django.core.exceptions import ValidationError
|
4 |
from .models import CategorieFormation,Formation,UserFormation,Cours,ArchiveFormation,ListSouhaitFormation,FavorisFormation, PanierUser,AvisFormation,PaiementUser
|
5 |
|
6 |
+
class UserFormationSerializer(serializers.ModelSerializer):
|
7 |
|
8 |
class Meta:
|
9 |
+
model = UserFormation
|
10 |
fields = ('__all__')
|
11 |
|
12 |
+
class CoursSerializer(serializers.ModelSerializer):
|
|
|
13 |
|
14 |
class Meta:
|
15 |
+
model = Cours
|
16 |
fields = ('__all__')
|
17 |
|
18 |
|
19 |
+
class FormationSerializer(serializers.ModelSerializer):
|
20 |
+
# Créer un sérialiseur de fichier pour le champ image
|
21 |
+
image = serializers.FileField(max_length=None, allow_empty_file=False, use_url=True)
|
22 |
+
cours = CoursSerializer(many=True, read_only=True)
|
23 |
+
# userformations = UserFormationSerializer(many=True, read_only=True)
|
24 |
|
25 |
class Meta:
|
26 |
+
model = Formation
|
27 |
+
# Inclure le champ image dans la liste des champs à sérialiser
|
28 |
fields = ('__all__')
|
29 |
|
30 |
+
class CategorieFormationSerializer(serializers.ModelSerializer):
|
31 |
+
formations = FormationSerializer(many=True, read_only=True)
|
32 |
class Meta:
|
33 |
+
model = CategorieFormation
|
34 |
fields = ('__all__')
|
35 |
|
|
|
36 |
class ListSouhaitFormationSerializer(serializers.ModelSerializer):
|
37 |
|
38 |
class Meta:
|
formations/views.py
CHANGED
@@ -3,6 +3,7 @@ from rest_framework import viewsets
|
|
3 |
from rest_framework.permissions import IsAuthenticated,AllowAny
|
4 |
from .models import CategorieFormation,Formation,UserFormation,Cours,ArchiveFormation,ListSouhaitFormation,FavorisFormation, PanierUser,AvisFormation,PaiementUser
|
5 |
from .serializers import ArchiveFormationSerializer, AvisFormationSerializer, CategorieFormationSerializer, CoursSerializer, FavorisFormationSerializer, FormationSerializer, ListSouhaitFormationSerializer, PaiementUserSerializer, PanierUserSerializer , UserFormationSerializer
|
|
|
6 |
|
7 |
|
8 |
# Create your views here.
|
@@ -10,20 +11,20 @@ class CategorieFormationViews(viewsets.ModelViewSet):
|
|
10 |
serializer_class = CategorieFormationSerializer
|
11 |
queryset = CategorieFormation.objects.all().order_by('-id')
|
12 |
|
13 |
-
|
14 |
def get_permissions(self):
|
15 |
return [AllowAny()]
|
16 |
|
17 |
-
def get_serializer_context(self):
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
|
23 |
class FormationViews(viewsets.ModelViewSet):
|
24 |
serializer_class = FormationSerializer
|
25 |
queryset = Formation.objects.all().order_by('-id')
|
26 |
-
|
|
|
27 |
def get_permissions(self):
|
28 |
return [AllowAny()]
|
29 |
|
|
|
3 |
from rest_framework.permissions import IsAuthenticated,AllowAny
|
4 |
from .models import CategorieFormation,Formation,UserFormation,Cours,ArchiveFormation,ListSouhaitFormation,FavorisFormation, PanierUser,AvisFormation,PaiementUser
|
5 |
from .serializers import ArchiveFormationSerializer, AvisFormationSerializer, CategorieFormationSerializer, CoursSerializer, FavorisFormationSerializer, FormationSerializer, ListSouhaitFormationSerializer, PaiementUserSerializer, PanierUserSerializer , UserFormationSerializer
|
6 |
+
from rest_framework.parsers import MultiPartParser, FormParser
|
7 |
|
8 |
|
9 |
# Create your views here.
|
|
|
11 |
serializer_class = CategorieFormationSerializer
|
12 |
queryset = CategorieFormation.objects.all().order_by('-id')
|
13 |
|
|
|
14 |
def get_permissions(self):
|
15 |
return [AllowAny()]
|
16 |
|
17 |
+
# def get_serializer_context(self):
|
18 |
+
# context = super(CategorieFormationViews, self).get_serializer_context()
|
19 |
+
# context.update({"request": self.request})
|
20 |
+
# return context
|
21 |
|
22 |
|
23 |
class FormationViews(viewsets.ModelViewSet):
|
24 |
serializer_class = FormationSerializer
|
25 |
queryset = Formation.objects.all().order_by('-id')
|
26 |
+
parser_classes = (MultiPartParser, FormParser)
|
27 |
+
|
28 |
def get_permissions(self):
|
29 |
return [AllowAny()]
|
30 |
|
media/347258376_752544993542397_8667728642864495466_n.jpg
ADDED
![]() |
media/352698142_1334864067071379_6161131225698984499_n.jpg
ADDED
![]() |