Compare commits
No commits in common. "84c94e28de5e3e35c2918b8b5cc747825d7b86f0" and "e77ea7e20eff0a6c33af1d283dc7544fcd6b2c77" have entirely different histories.
84c94e28de
...
e77ea7e20e
6 changed files with 2 additions and 63 deletions
|
|
@ -1 +1 @@
|
||||||
1.0.3 (cab7c07)
|
1.0.3 (e79ffee)
|
||||||
|
|
@ -15,9 +15,6 @@ class Course(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return f"/courses/{self.slug}-{self.id}/"
|
|
||||||
|
|
||||||
class Module(models.Model):
|
class Module(models.Model):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
|
|
@ -28,9 +25,6 @@ class Module(models.Model):
|
||||||
enable = models.BooleanField(default=True)
|
enable = models.BooleanField(default=True)
|
||||||
order = models.PositiveIntegerField()
|
order = models.PositiveIntegerField()
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
class Lesson(models.Model):
|
class Lesson(models.Model):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
|
|
@ -49,9 +43,6 @@ class Lesson(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return f"/courses/{self.module.course.slug}/{self.module.slug}/{self.slug}/"
|
|
||||||
|
|
||||||
|
|
||||||
class Comment(models.Model):
|
class Comment(models.Model):
|
||||||
lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, related_name='comments')
|
lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, related_name='comments')
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ def list_courses(request):
|
||||||
courses = Course.objects.all()
|
courses = Course.objects.all()
|
||||||
return render(request, 'courses/list.html', {'courses': courses})
|
return render(request, 'courses/list.html', {'courses': courses})
|
||||||
|
|
||||||
def show(request, course_id):
|
def show(request, course_name, course_id):
|
||||||
# Optimized course fetch with related author and profile (if present)
|
# Optimized course fetch with related author and profile (if present)
|
||||||
course = get_object_or_404(
|
course = get_object_or_404(
|
||||||
Course.objects.select_related('author', 'author__profile'),
|
Course.objects.select_related('author', 'author__profile'),
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django.contrib.sitemaps',
|
|
||||||
|
|
||||||
'core',
|
'core',
|
||||||
'courses',
|
'courses',
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
from django.contrib import sitemaps
|
|
||||||
from django.urls import reverse
|
|
||||||
|
|
||||||
# --- IMPORTS DEPUIS TES DIFFÉRENTES FEATURES ---
|
|
||||||
from courses.models import Course
|
|
||||||
from users.models import Profile
|
|
||||||
|
|
||||||
# --- SITEMAP : LES Cours ---
|
|
||||||
class CourseSitemap(sitemaps.Sitemap):
|
|
||||||
changefreq = "weekly"
|
|
||||||
priority = 0.9
|
|
||||||
|
|
||||||
def items(self):
|
|
||||||
return Course.objects.filter(enable=True) # Exemple de filtre
|
|
||||||
|
|
||||||
def location(self, item):
|
|
||||||
# Assure-toi que ton modèle Course a bien une méthode get_absolute_url
|
|
||||||
return item.get_absolute_url()
|
|
||||||
|
|
||||||
# --- SITEMAP : PAGES STATIQUES ---
|
|
||||||
class StaticViewSitemap(sitemaps.Sitemap):
|
|
||||||
priority = 0.5
|
|
||||||
changefreq = "monthly"
|
|
||||||
|
|
||||||
def items(self):
|
|
||||||
return ["home"] # Les noms de tes URLs
|
|
||||||
|
|
||||||
def location(self, item):
|
|
||||||
return "https://partirdezero.com"
|
|
||||||
|
|
@ -18,34 +18,12 @@ from django.conf import settings
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
from django.http import HttpResponse
|
|
||||||
from devart.sitemap import CourseSitemap, StaticViewSitemap
|
|
||||||
from django.contrib.sitemaps.views import sitemap
|
|
||||||
|
|
||||||
# La vue pour le robots.txt
|
|
||||||
def robots_txt(request):
|
|
||||||
lines = [
|
|
||||||
"User-agent: *",
|
|
||||||
"Disallow: /admin/",
|
|
||||||
"Disallow: /users/",
|
|
||||||
"Allow: /",
|
|
||||||
"Sitemap: https://partirdezero.com/sitemap.xml", # On indique déjà où sera le plan
|
|
||||||
]
|
|
||||||
return HttpResponse("\n".join(lines), content_type="text/plain")
|
|
||||||
|
|
||||||
sitemaps_dict = {
|
|
||||||
'cours': CourseSitemap,
|
|
||||||
'static': StaticViewSitemap,
|
|
||||||
}
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('', include('home.urls')),
|
path('', include('home.urls')),
|
||||||
path('courses/', include('courses.urls')),
|
path('courses/', include('courses.urls')),
|
||||||
path('users/', include('users.urls')),
|
path('users/', include('users.urls')),
|
||||||
|
|
||||||
path('sitemap.xml', sitemap, {'sitemaps': sitemaps_dict}, name='django.contrib.sitemaps.views.sitemap'),
|
|
||||||
path('robots.txt', robots_txt),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue