diff --git a/VERSION.txt b/VERSION.txt index c71c6cc..a46d739 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.0.3 (cab7c07) \ No newline at end of file +1.0.3 (e79ffee) \ No newline at end of file diff --git a/courses/models.py b/courses/models.py index 3001eb5..1c5a096 100644 --- a/courses/models.py +++ b/courses/models.py @@ -15,9 +15,6 @@ class Course(models.Model): def __str__(self): return self.name - def get_absolute_url(self): - return f"/courses/{self.slug}-{self.id}/" - class Module(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() @@ -28,9 +25,6 @@ class Module(models.Model): enable = models.BooleanField(default=True) order = models.PositiveIntegerField() - def __str__(self): - return self.name - class Lesson(models.Model): name = models.CharField(max_length=200) slug = models.SlugField() @@ -49,9 +43,6 @@ class Lesson(models.Model): def __str__(self): return self.name - def get_absolute_url(self): - return f"/courses/{self.module.course.slug}/{self.module.slug}/{self.slug}/" - class Comment(models.Model): lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, related_name='comments') diff --git a/courses/views.py b/courses/views.py index b51bce0..8a33bbb 100644 --- a/courses/views.py +++ b/courses/views.py @@ -9,7 +9,7 @@ def list_courses(request): courses = Course.objects.all() 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) course = get_object_or_404( Course.objects.select_related('author', 'author__profile'), diff --git a/devart/settings.py b/devart/settings.py index fa7d2d5..68e1525 100644 --- a/devart/settings.py +++ b/devart/settings.py @@ -46,7 +46,6 @@ INSTALLED_APPS = [ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'django.contrib.sitemaps', 'core', 'courses', diff --git a/devart/sitemap.py b/devart/sitemap.py deleted file mode 100644 index 05f4a77..0000000 --- a/devart/sitemap.py +++ /dev/null @@ -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" \ No newline at end of file diff --git a/devart/urls.py b/devart/urls.py index e198bae..86830eb 100644 --- a/devart/urls.py +++ b/devart/urls.py @@ -18,34 +18,12 @@ from django.conf import settings from django.conf.urls.static import static from django.contrib import admin 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 = [ path('admin/', admin.site.urls), path('', include('home.urls')), path('courses/', include('courses.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: