Browse Source
feat(account, course): add enrolled courses count & improve admin
feat(account, course): add enrolled courses count & improve admin
- Added enrolled courses count to StudentUser admin - Improved StudentUser admin queryset - Added StudentParticipantInline to StudentUser admin - Added is_active field to Participant model - Improved Course admin registrationmaster
9 changed files with 83 additions and 43 deletions
-
15apps/account/admin/student.py
-
40apps/account/admin/user.py
-
2apps/account/models/user.py
-
7apps/course/admin/course.py
-
8apps/course/admin/lesson.py
-
33apps/course/admin/participant.py
-
18apps/course/migrations/0006_participant_is_active.py
-
1apps/course/models/participant.py
-
2apps/quiz/serializers/quiz.py
@ -1,33 +0,0 @@ |
|||
# from django.contrib import admin |
|||
|
|||
# from apps.course.models import Participant |
|||
# from apps.account.models import StudentUser, User |
|||
|
|||
|
|||
|
|||
# @admin.register(Participant) |
|||
# class ParticipantAdmin(admin.ModelAdmin): |
|||
# list_display = ('student', 'course', 'joined_date', 'unread_messages_count') |
|||
# search_fields = ('student__fullname', 'student__email', 'course__title') |
|||
# list_filter = ('course', 'joined_date') |
|||
# ordering = ('-joined_date',) |
|||
# autocomplete_fields = ['student',] # جستجوی پویا برای فیلد دانشآموز |
|||
|
|||
# def get_readonly_fields(self, request, obj=None): |
|||
# """ |
|||
# Make fields readonly if the object already exists. |
|||
# """ |
|||
# if obj: |
|||
# return ['student', 'course', 'joined_date'] |
|||
# return [] |
|||
|
|||
|
|||
# def get_form(self, request, obj=None, **kwargs): |
|||
# form = super().get_form(request, obj, **kwargs) |
|||
# if obj is None: # Adding a new participant |
|||
# # محدود کردن انتخاب دانشآموزان به کاربرانی که از نوع StudentUser هستند |
|||
# # form.base_fields['student'].queryset = StudentUser.objects.filter(user_type=User.UserType.STUDENT) |
|||
# form.base_fields['student'].widget.can_add_related = True # فعال کردن دکمه اضافه کردن |
|||
|
|||
# return form |
|||
|
|||
@ -0,0 +1,18 @@ |
|||
# Generated by Django 5.2.4 on 2025-08-07 14:41 |
|||
|
|||
from django.db import migrations, models |
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('course', '0005_add_database_indexes'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.AddField( |
|||
model_name='participant', |
|||
name='is_active', |
|||
field=models.BooleanField(default=True), |
|||
), |
|||
] |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue