feat: implement LMS core (CMS, Courses, Enrollment, Progress, Auth) (Admin + API)
Build & Push Docker Image (Backend) / build (push) Successful in 54s
Build & Push Docker Image (Backend) / build (push) Successful in 54s
This commit is contained in:
+10
-3
@@ -1,3 +1,10 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from django.contrib import admin
|
||||
from apps.content.models import Article
|
||||
from unfold.admin import ModelAdmin
|
||||
|
||||
@admin.register(Article)
|
||||
class ArticleAdmin(ModelAdmin):
|
||||
list_display = ('id', 'title', 'published', 'created_at')
|
||||
list_filter = ('published',)
|
||||
search_fields = ('title',)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ContentConfig(AppConfig):
|
||||
name = 'apps.content'
|
||||
from django.apps import AppConfig
|
||||
|
||||
class ContentConfig(AppConfig):
|
||||
name = 'apps.content'
|
||||
verbose_name = 'คลังเนื้อหา'
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# Generated by Django 6.0.2 on 2026-05-02 23:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Article',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200)),
|
||||
('body', models.TextField()),
|
||||
('published', models.BooleanField(default=False)),
|
||||
('create_at', models.DateTimeField(auto_now_add=True)),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 6.0.2 on 2026-05-02 23:10
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('content', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='article',
|
||||
old_name='create_at',
|
||||
new_name='created_at',
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Generated by Django 6.0.2 on 2026-05-03 02:29
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('content', '0002_rename_create_at_article_created_at'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name='article',
|
||||
options={'verbose_name': 'บทความ', 'verbose_name_plural': 'บทความ'},
|
||||
),
|
||||
]
|
||||
+14
-3
@@ -1,3 +1,14 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
from django.db import models
|
||||
|
||||
class Article(models.Model):
|
||||
title = models.CharField(max_length=200) # หัวข้อบทความ
|
||||
body = models.TextField() # เนื้อหา
|
||||
published = models.BooleanField(default=False) # ใช้เปิด/ปิดการแสดงผล
|
||||
created_at = models.DateTimeField(auto_now_add=True) # เวลาสร้าง (เอาไว้ sort / paginate)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "บทความ"
|
||||
verbose_name_plural = "บทความ"
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from apps.common.api.base_serializer import BaseModelSerializer
|
||||
from apps.content.models import Article
|
||||
|
||||
class ArticleSerializer(BaseModelSerializer):
|
||||
class Meta(BaseModelSerializer.Meta):
|
||||
model = Article
|
||||
+12
-3
@@ -1,3 +1,12 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from apps.common.api.base_viewset import BaseModelViewSet
|
||||
from apps.content.models import Article
|
||||
from apps.content.serializers import ArticleSerializer
|
||||
|
||||
class ArticleViewSet(BaseModelViewSet):
|
||||
queryset = Article.objects.all()
|
||||
serializer_class = ArticleSerializer
|
||||
|
||||
# CMS-like behavior
|
||||
search_fields = ('title', 'body')
|
||||
filterset_fields = ['published']
|
||||
ordering = ['-created_at']
|
||||
Reference in New Issue
Block a user