Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Dec 13, 2024
2 parents 4ad658b + 95d47c3 commit c2545e9
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 119 deletions.
77 changes: 65 additions & 12 deletions cds/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,85 @@

from .models import (
DidatticaCds,
DidatticaCdsCollegamento,
DidatticaCdsLingua,
DidatticaRegolamento,
DidatticaTestiRegolamento,
)


@admin.register(DidatticaCds)
class DidatticaCdsAdmin(admin.ModelAdmin):
readonly_fields = ()
list_display = ("nome_cds_it", "dip")
search_fields = ("nome_cds_it",)
list_display = ("cds_id", "cds_cod", "nome_cds_it", "dip")
search_fields = ("nome_cds_it", "cds_cod")
list_display_links = ("cds_id",)
list_filter = ("tipo_corso_cod",)


@admin.register(DidatticaCdsLingua)
class DidatticaCdsLinguaAdmin(admin.ModelAdmin):
readonly_fields = ()
list_display = ()
@admin.display(description="CDS")
def cds(self, obj):
return f"{obj.cdsord.cds_cod} - {obj.cdsord.nome_cds_it}"

@admin.display(description="ISO COD")
def iso_cod(self, obj):
return obj.iso6392_cod.upper()

list_display = ("cds", "iso_cod")
list_display_links = ("cds",)
list_filter = ("iso6392_cod",)
search_fields = (
"cdsord__nome_cds_it",
"cdsord__cds_cod",
)
search_help_text = "Search by Cds Name or Cds Cod"


@admin.register(DidatticaRegolamento)
class DidatticaRegolamentoAdmin(admin.ModelAdmin):
readonly_fields = ()
list_display = ()
list_display = ("regdid_id", "aa_reg_did", "cds")
list_display_links = ("regdid_id",)
list_filter = ("cds__tipo_corso_cod",)
search_fields = (
"cds__nome_cds_it",
"cds__cds_cod",
)
search_help_text = "Search by Cds Name or Cds Cod"

@admin.register(DidatticaCdsCollegamento)
class DidattiCdsCollegamentoAdmin(admin.ModelAdmin):
@admin.display(description="New CDS COD", ordering="cds__cds_cod")
def cds_cod(self, obj):
return obj.cds.cds_cod

@admin.display(description="Previous CDS COD", ordering="cds_prec__cds_cod")
def cds_prec_cod(self, obj):
return obj.cds_prec.cds_cod

@admin.display(description="New CDS Name", ordering="cds__nome_cds_it")
def cds_nome_cds_it(self, obj):
return obj.cds.nome_cds_it

@admin.display(description="Previous CDS Name", ordering="cds_prec__nome_cds_it")
def cds_prec_nome_cds_it(self, obj):
return obj.cds_prec.nome_cds_it

@admin.register(DidatticaTestiRegolamento)
class DidatticaTestiRegolamentoAdmin(admin.ModelAdmin):
readonly_fields = ()
list_display = ()
list_display = (
"cds_cod",
"cds_nome_cds_it",
"cds_prec_cod",
"cds_prec_nome_cds_it",
)
list_display_links = (
"cds_cod",
"cds_prec_cod",
)
search_fields = (
"cds__nome_cds_it",
"cds_prec__nome_cds_it",
"cds__cds_cod",
"cds_prec__cds_cod",
)
search_help_text = "Search by Cds Name or Cds Cod"
raw_id_fields = ("cds", "cds_prec")
list_select_related = ("cds", "cds_prec")
4 changes: 2 additions & 2 deletions cds/apps.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.apps import AppConfig

from django.utils.translation import gettext_lazy as _

class CdsConfig(AppConfig):
name = "cds"
verbose_name = "Courses of Study"
verbose_name = _("Courses of Study")

def ready(self):
from .management import signals # noqa: F401
14 changes: 12 additions & 2 deletions cds/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.contrib.auth import get_user_model
from django.db import models
from django.utils.translation import gettext_lazy as _
from generics.models import InsModAbstract, Permissions
from generics.validators import validate_file_size, validate_pdf_file_extension
from regdid.settings import (
Expand Down Expand Up @@ -39,6 +40,8 @@ class Meta:
db_table = "DIDATTICA_CDS_COLLEGAMENTO"
ordering = ["-cds__cds_cod"]
unique_together = (("cds", "cds_prec"),)
verbose_name = "Cds Morph"
verbose_name_plural = verbose_name

def __str__(self):
return f"{self.cds.cds_cod}-{self.cds_prec.cds_cod}"
Expand Down Expand Up @@ -430,9 +433,11 @@ class DidatticaCds(InsModAbstract):
class Meta:
managed = True
db_table = "DIDATTICA_CDS"
verbose_name = "Cds"
verbose_name_plural = verbose_name

def __str__(self): # pragma: no cover
return "{} {}".format(self.cds_id, self.nome_cds_it)
return "{} {}".format(self.cds_cod, self.nome_cds_it)


class DidatticaCdsPeriodi(models.Model):
Expand Down Expand Up @@ -530,9 +535,11 @@ class DidatticaCdsLingua(models.Model):
class Meta:
managed = True
db_table = "DIDATTICA_CDS_LINGUA"
verbose_name = _("Cds Language")
verbose_name_plural = _("Cds Languages")

def __str__(self): # pragma: no cover
return "{} {}".format(self.lin_did_ord_id, self.lingua_des_it)
return "{} {}".format(self.cdsord.cds_cod, self.lingua_des_it)


class DidatticaCopertura(InsModAbstract):
Expand Down Expand Up @@ -768,6 +775,9 @@ class Meta:
managed = True
db_table = "DIDATTICA_REGOLAMENTO"

verbose_name = _("Didactic Regulation")
verbose_name_plural = _("Didactic Regulations")

def get_ordinamento_didattico(self):
# se è stato caricato un ordinamento per quest'anno, lo restituisco
other_data = DidatticaCdsAltriDati.objects.filter(regdid_id=self).first()
Expand Down
Binary file modified locale/it/LC_MESSAGES/django.mo
Binary file not shown.
Loading

0 comments on commit c2545e9

Please sign in to comment.