diff --git a/src/apps/diplomas/admin/__init__.py b/src/apps/diplomas/admin/__init__.py index fa8efbfd69b..bcad6a16973 100644 --- a/src/apps/diplomas/admin/__init__.py +++ b/src/apps/diplomas/admin/__init__.py @@ -1,9 +1,7 @@ from apps.diplomas.admin.diploma import DiplomaAdmin from apps.diplomas.admin.study import StudyAdmin -from apps.diplomas.admin.template import DiplomaTemplateAdmin __all__ = [ "DiplomaAdmin", - "DiplomaTemplateAdmin", "StudyAdmin", ] diff --git a/src/apps/diplomas/admin/template.py b/src/apps/diplomas/admin/template.py deleted file mode 100644 index 2c82eeb5065..00000000000 --- a/src/apps/diplomas/admin/template.py +++ /dev/null @@ -1,18 +0,0 @@ -from apps.diplomas.models import DiplomaTemplate -from core.admin import ModelAdmin, admin - - -@admin.register(DiplomaTemplate) -class DiplomaTemplateAdmin(ModelAdmin): - fields = list_display = ( - "course", - "language", - "slug", - "homework_accepted", - ) - - list_editable = [ - "slug", - "language", - "homework_accepted", - ] diff --git a/src/apps/diplomas/models.py b/src/apps/diplomas/models.py index f93e76e4918..7ba527f8da3 100644 --- a/src/apps/diplomas/models.py +++ b/src/apps/diplomas/models.py @@ -108,6 +108,9 @@ class Meta: models.Index(fields=["course", "language", "homework_accepted"]), ] + def __str__(self) -> str: + return self.slug + class DiplomaStudyProxy(Study): """Used in the admin to upload diplomas manually.""" diff --git a/src/apps/mailing/admin/email_configuration.py b/src/apps/mailing/admin/email_configuration.py deleted file mode 100644 index 15e7c56cf69..00000000000 --- a/src/apps/mailing/admin/email_configuration.py +++ /dev/null @@ -1,13 +0,0 @@ -from apps.mailing.models import EmailConfiguration -from core.admin import StackedInline - - -class EmailConfigurationAdmin(StackedInline): - model = EmailConfiguration - - fields = [ - "backend", - "from_email", - "reply_to", - "backend_options", - ] diff --git a/src/apps/products/admin/course.py b/src/apps/products/admin/course.py index 8a26e006884..777b94ba5d4 100644 --- a/src/apps/products/admin/course.py +++ b/src/apps/products/admin/course.py @@ -4,8 +4,7 @@ from django.utils.translation import gettext as _ from apps.amocrm import tasks -from apps.mailing.admin.email_configuration import EmailConfigurationAdmin -from apps.products.admin.courses import actions +from apps.products.admin.courses import actions, inlines from apps.products.models import Course from core.admin import ModelAdmin, admin @@ -77,7 +76,10 @@ class CourseAdmin(ModelAdmin): prepopulated_fields = { "slug": ["name"], } - inlines = (EmailConfigurationAdmin,) + inlines = ( + inlines.EmailConfigurationAdmin, + inlines.DiplomaTemplateAdmin, + ) action_form = actions.CourseActionForm actions = [ diff --git a/src/apps/products/admin/courses/inlines.py b/src/apps/products/admin/courses/inlines.py new file mode 100644 index 00000000000..ca1c4386373 --- /dev/null +++ b/src/apps/products/admin/courses/inlines.py @@ -0,0 +1,26 @@ +from apps.diplomas.models import DiplomaTemplate +from apps.mailing.models import EmailConfiguration +from core.admin import StackedInline, TabularInline + + +class DiplomaTemplateAdmin(TabularInline): + model = DiplomaTemplate + extra = 0 + list_editable = () + + +class EmailConfigurationAdmin(StackedInline): + model = EmailConfiguration + + fields = [ + "backend", + "from_email", + "reply_to", + "backend_options", + ] + + +__all__ = [ + "DiplomaTemplateAdmin", + "EmailConfigurationAdmin", +]