Skip to content

Commit

Permalink
Inline admin for diploma templates (#2480)
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 authored Dec 23, 2024
1 parent 4a2c82c commit c4ad246
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 36 deletions.
2 changes: 0 additions & 2 deletions src/apps/diplomas/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
18 changes: 0 additions & 18 deletions src/apps/diplomas/admin/template.py

This file was deleted.

3 changes: 3 additions & 0 deletions src/apps/diplomas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
13 changes: 0 additions & 13 deletions src/apps/mailing/admin/email_configuration.py

This file was deleted.

8 changes: 5 additions & 3 deletions src/apps/products/admin/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -77,7 +76,10 @@ class CourseAdmin(ModelAdmin):
prepopulated_fields = {
"slug": ["name"],
}
inlines = (EmailConfigurationAdmin,)
inlines = (
inlines.EmailConfigurationAdmin,
inlines.DiplomaTemplateAdmin,
)
action_form = actions.CourseActionForm

actions = [
Expand Down
26 changes: 26 additions & 0 deletions src/apps/products/admin/courses/inlines.py
Original file line number Diff line number Diff line change
@@ -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",
]

0 comments on commit c4ad246

Please sign in to comment.