diff --git a/akarpov/about/admin.py b/akarpov/about/admin.py index 3e79cae..0fc0392 100644 --- a/akarpov/about/admin.py +++ b/akarpov/about/admin.py @@ -1,6 +1,7 @@ from django.contrib import admin -from akarpov.about.models import Project, ProjectChange +from akarpov.about.models import FAQ, Project, ProjectChange +admin.site.register(FAQ) admin.site.register(Project) admin.site.register(ProjectChange) diff --git a/akarpov/about/migrations/0003_faq.py b/akarpov/about/migrations/0003_faq.py new file mode 100644 index 0000000..48f02ce --- /dev/null +++ b/akarpov/about/migrations/0003_faq.py @@ -0,0 +1,34 @@ +# Generated by Django 4.2.3 on 2023-08-01 00:36 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("about", "0002_projectchange"), + ] + + operations = [ + migrations.CreateModel( + name="FAQ", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("ordering", models.IntegerField(default=0)), + ("question", models.CharField(max_length=250)), + ("link", models.URLField(blank=True, null=True)), + ("answer", models.TextField()), + ], + options={ + "ordering": ["-ordering"], + }, + ), + ] diff --git a/akarpov/about/models.py b/akarpov/about/models.py index e10cdf9..23bab6e 100644 --- a/akarpov/about/models.py +++ b/akarpov/about/models.py @@ -33,3 +33,16 @@ def __str__(self): class Meta: ordering = ("-created",) + + +class FAQ(models.Model): + ordering = models.IntegerField(default=0) + question = models.CharField(max_length=250) + link = models.URLField(null=True, blank=True) + answer = models.TextField() + + def __str__(self): + return self.question + + class Meta: + ordering = ["-ordering"] diff --git a/akarpov/about/views.py b/akarpov/about/views.py index 21361a0..ba5652e 100644 --- a/akarpov/about/views.py +++ b/akarpov/about/views.py @@ -1,6 +1,6 @@ -from django.views.generic import DetailView, TemplateView +from django.views.generic import DetailView, ListView, TemplateView -from akarpov.about.models import Project +from akarpov.about.models import FAQ, Project class AboutView(TemplateView): @@ -24,3 +24,11 @@ class ProjectView(DetailView): project_view = ProjectView.as_view() + + +class ListFAQView(ListView): + model = FAQ + template_name = "about/faq.html" + + +list_faq = ListFAQView.as_view() diff --git a/config/urls.py b/config/urls.py index f59f5d0..e6edb69 100644 --- a/config/urls.py +++ b/config/urls.py @@ -12,7 +12,7 @@ SpectacularSwaggerView, ) -from akarpov.about.views import about_view +from akarpov.about.views import about_view, list_faq from akarpov.tools.shortener.views import redirect_view from config.sitemaps import sitemaps @@ -34,7 +34,8 @@ path(settings.ADMIN_URL, admin.site.urls), # User management path("users/", include("akarpov.users.urls", namespace="users")), - path("about", cache_page(600)(about_view)), + path("about", cache_page(600)(about_view), name="about"), + path("faq/", list_faq, name="faq"), path("about/", include("akarpov.about.urls", namespace="about")), path("files/", include("akarpov.files.urls", namespace="files")), path("music/", include("akarpov.music.urls", namespace="music")), @@ -51,7 +52,7 @@ # API URLS urlpatterns += [ # API base url - path("api/", include("config.api_router")), + path("api/", include("config.api_router", namespace="api")), # DRF auth token path("api/schema/", SpectacularAPIView.as_view(), name="api-schema"), path("api/schema/", SpectacularAPIView.as_view(), name="api-redoc-schema"),