First commit
This commit is contained in:
commit
440f5a7df4
1563 changed files with 217996 additions and 0 deletions
29
courses/models.py
Normal file
29
courses/models.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.html import escape
|
||||
|
||||
class Course(models.Model):
|
||||
name = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
thumbnail = models.ImageField(upload_to='static/uploads/thumbnails/courses/', default='default.jpg')
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Lesson(models.Model):
|
||||
course_id = models.ForeignKey(Course, on_delete=models.CASCADE, related_name='lecons')
|
||||
name = models.CharField(max_length=200)
|
||||
content = models.TextField()
|
||||
order = models.PositiveIntegerField()
|
||||
|
||||
def clean(self):
|
||||
# Remplacer les chevrons <?php et ?> par leurs équivalents HTML
|
||||
if self.content:
|
||||
self.content = self.content.replace('<?php', '<?php')
|
||||
self.content = self.content.replace('?>', '?>')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
Loading…
Add table
Add a link
Reference in a new issue