From fbf55c883de36fe3dd7840ed0603e7eebdf24122 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9COMosimege=E2=80=9D?=
<“onalerona.mosimege@gmail.com”>
Date: Mon, 27 May 2024 09:27:59 +0200
Subject: [PATCH] Add verbose names and pluralisation to models
---
...007_alter_documentfile_options_and_more.py | 250 ++++++++++++++++++
app/general/models.py | 110 +++++---
2 files changed, 320 insertions(+), 40 deletions(-)
create mode 100644 app/general/migrations/0007_alter_documentfile_options_and_more.py
diff --git a/app/general/migrations/0007_alter_documentfile_options_and_more.py b/app/general/migrations/0007_alter_documentfile_options_and_more.py
new file mode 100644
index 00000000..b178a9bd
--- /dev/null
+++ b/app/general/migrations/0007_alter_documentfile_options_and_more.py
@@ -0,0 +1,250 @@
+# Generated by Django 5.0.2 on 2024-05-27 10:56
+
+import django.core.validators
+import django.db.models.deletion
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('general', '0006_documentfile_document_data'),
+ ]
+
+ operations = [
+ migrations.AlterModelOptions(
+ name='documentfile',
+ options={'verbose_name': 'Document File', 'verbose_name_plural': 'Document Files'},
+ ),
+ migrations.AlterModelOptions(
+ name='historicaldocumentfile',
+ options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Document File', 'verbose_name_plural': 'historical Document Files'},
+ ),
+ migrations.AlterModelOptions(
+ name='historicalinstitution',
+ options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Institution', 'verbose_name_plural': 'historical Institutions'},
+ ),
+ migrations.AlterModelOptions(
+ name='historicallanguage',
+ options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Language', 'verbose_name_plural': 'historical Languages'},
+ ),
+ migrations.AlterModelOptions(
+ name='historicalproject',
+ options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Project', 'verbose_name_plural': 'historical Projects'},
+ ),
+ migrations.AlterModelOptions(
+ name='historicalsubject',
+ options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Subject', 'verbose_name_plural': 'historical Subjects'},
+ ),
+ migrations.AlterModelOptions(
+ name='institution',
+ options={'verbose_name': 'Institution', 'verbose_name_plural': 'Institutions'},
+ ),
+ migrations.AlterModelOptions(
+ name='language',
+ options={'verbose_name': 'Language', 'verbose_name_plural': 'Languages'},
+ ),
+ migrations.AlterModelOptions(
+ name='project',
+ options={'verbose_name': 'Project', 'verbose_name_plural': 'Projects'},
+ ),
+ migrations.AlterModelOptions(
+ name='subject',
+ options={'verbose_name': 'Subject', 'verbose_name_plural': 'Subjects'},
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='available',
+ field=models.BooleanField(default=True, verbose_name='available'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='document_data',
+ field=models.TextField(blank=True, verbose_name='document data'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='document_type',
+ field=models.CharField(choices=[('Glossary', 'Glossary'), ('Policy', 'Policy')], max_length=200, verbose_name='document type'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='institution',
+ field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='general.institution', verbose_name='institution'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='languages',
+ field=models.ManyToManyField(blank=True, to='general.language', verbose_name='languages'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='license',
+ field=models.CharField(choices=[('(c)', 'All rights reserved'), ('CC0', 'No rights reserved'), ('CC BY', 'Creative Commons Attribution'), ('CC BY-SA', 'Creative Commons Attribution-ShareAlike'), ('CC BY-NC', 'Creative Commons Attribution-NonCommercial'), ('CC BY-NC-SA', 'Creative Commons Attribution-NonCommercial-ShareAlike')], default='(c)', help_text='\n More information about Creative Commons licenses.\n ', max_length=200, verbose_name='license'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='mime_type',
+ field=models.CharField(blank=True, help_text='This input will auto-populate.', max_length=200, verbose_name='MIME type'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='subjects',
+ field=models.ManyToManyField(blank=True, to='general.subject', verbose_name='subjects'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='title',
+ field=models.CharField(max_length=200, verbose_name='title'),
+ ),
+ migrations.AlterField(
+ model_name='documentfile',
+ name='uploaded_file',
+ field=models.FileField(blank=True, help_text='PDF files up to 10MB are allowed.', upload_to='documents/', validators=[django.core.validators.FileExtensionValidator(['pdf'])], verbose_name='uploaded file'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='available',
+ field=models.BooleanField(default=True, verbose_name='available'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='document_type',
+ field=models.CharField(choices=[('Glossary', 'Glossary'), ('Policy', 'Policy')], max_length=200, verbose_name='document type'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='institution',
+ field=models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='general.institution', verbose_name='institution'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='license',
+ field=models.CharField(choices=[('(c)', 'All rights reserved'), ('CC0', 'No rights reserved'), ('CC BY', 'Creative Commons Attribution'), ('CC BY-SA', 'Creative Commons Attribution-ShareAlike'), ('CC BY-NC', 'Creative Commons Attribution-NonCommercial'), ('CC BY-NC-SA', 'Creative Commons Attribution-NonCommercial-ShareAlike')], default='(c)', help_text='\n More information about Creative Commons licenses.\n ', max_length=200, verbose_name='license'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='mime_type',
+ field=models.CharField(blank=True, help_text='This input will auto-populate.', max_length=200, verbose_name='MIME type'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='title',
+ field=models.CharField(max_length=200, verbose_name='title'),
+ ),
+ migrations.AlterField(
+ model_name='historicaldocumentfile',
+ name='uploaded_file',
+ field=models.TextField(blank=True, help_text='PDF files up to 10MB are allowed.', max_length=100, validators=[django.core.validators.FileExtensionValidator(['pdf'])], verbose_name='uploaded file'),
+ ),
+ migrations.AlterField(
+ model_name='historicalinstitution',
+ name='abbreviation',
+ field=models.CharField(max_length=200, verbose_name='abbreviation'),
+ ),
+ migrations.AlterField(
+ model_name='historicalinstitution',
+ name='email',
+ field=models.EmailField(blank=True, max_length=200, verbose_name='email'),
+ ),
+ migrations.AlterField(
+ model_name='historicalinstitution',
+ name='logo',
+ field=models.TextField(blank=True, max_length=100, verbose_name='logo'),
+ ),
+ migrations.AlterField(
+ model_name='historicalinstitution',
+ name='name',
+ field=models.CharField(db_index=True, max_length=200, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='historicallanguage',
+ name='name',
+ field=models.CharField(db_index=True, max_length=150, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='historicalproject',
+ name='end_date',
+ field=models.DateField(blank=True, null=True, verbose_name='end date'),
+ ),
+ migrations.AlterField(
+ model_name='historicalproject',
+ name='logo',
+ field=models.TextField(blank=True, max_length=100, verbose_name='logo'),
+ ),
+ migrations.AlterField(
+ model_name='historicalproject',
+ name='name',
+ field=models.CharField(max_length=200, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='historicalproject',
+ name='start_date',
+ field=models.DateField(blank=True, null=True, verbose_name='start date'),
+ ),
+ migrations.AlterField(
+ model_name='historicalsubject',
+ name='name',
+ field=models.CharField(db_index=True, max_length=150, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='institution',
+ name='abbreviation',
+ field=models.CharField(max_length=200, verbose_name='abbreviation'),
+ ),
+ migrations.AlterField(
+ model_name='institution',
+ name='email',
+ field=models.EmailField(blank=True, max_length=200, verbose_name='email'),
+ ),
+ migrations.AlterField(
+ model_name='institution',
+ name='logo',
+ field=models.ImageField(blank=True, upload_to='institutions/logos/', verbose_name='logo'),
+ ),
+ migrations.AlterField(
+ model_name='institution',
+ name='name',
+ field=models.CharField(max_length=200, unique=True, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='language',
+ name='name',
+ field=models.CharField(max_length=150, unique=True, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='end_date',
+ field=models.DateField(blank=True, null=True, verbose_name='end date'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='languages',
+ field=models.ManyToManyField(blank=True, to='general.language', verbose_name='languages'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='logo',
+ field=models.ImageField(blank=True, upload_to='projects/logos/', verbose_name='logo'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='name',
+ field=models.CharField(max_length=200, verbose_name='name'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='start_date',
+ field=models.DateField(blank=True, null=True, verbose_name='start date'),
+ ),
+ migrations.AlterField(
+ model_name='project',
+ name='subjects',
+ field=models.ManyToManyField(blank=True, to='general.subject', verbose_name='subjects'),
+ ),
+ migrations.AlterField(
+ model_name='subject',
+ name='name',
+ field=models.CharField(max_length=150, unique=True, verbose_name='name'),
+ ),
+ ]
diff --git a/app/general/models.py b/app/general/models.py
index 7f6acf75..010221bc 100644
--- a/app/general/models.py
+++ b/app/general/models.py
@@ -1,63 +1,80 @@
from django.core.validators import FileExtensionValidator
from django.db import models
+from django.utils.translation import gettext_lazy as _
from simple_history.models import HistoricalRecords
class Project(models.Model):
- name = models.CharField(max_length=200)
- url = models.URLField(max_length=200, blank=True, verbose_name="URL")
- logo = models.ImageField(upload_to="projects/logos/", blank=True)
- start_date = models.DateField(blank=True, null=True)
- end_date = models.DateField(blank=True, null=True)
+ name = models.CharField(max_length=200, verbose_name=_("name"))
+ url = models.URLField(max_length=200, blank=True, verbose_name=_("URL"))
+ logo = models.ImageField(upload_to="projects/logos/", blank=True, verbose_name=_("logo"))
+ start_date = models.DateField(blank=True, null=True, verbose_name=_("start date"))
+ end_date = models.DateField(blank=True, null=True, verbose_name=_("end date"))
institution = models.ForeignKey(
- "Institution", on_delete=models.CASCADE, blank=True, verbose_name="institution"
+ "Institution", on_delete=models.CASCADE, blank=True, verbose_name=_("institution")
)
- subjects = models.ManyToManyField("Subject", blank=True)
- languages = models.ManyToManyField("Language", blank=True)
+ subjects = models.ManyToManyField("Subject", blank=True, verbose_name=_("subjects"))
+ languages = models.ManyToManyField("Language", blank=True, verbose_name=_("languages"))
# added simple historical records to the model
history = HistoricalRecords()
+ class Meta:
+ verbose_name = _("Project")
+ verbose_name_plural = _("Projects")
+
def __str__(self):
return self.name
class Institution(models.Model):
- name = models.CharField(max_length=200, unique=True)
- abbreviation = models.CharField(max_length=200)
- url = models.URLField(max_length=200, blank=True, verbose_name="URL")
- email = models.EmailField(max_length=200, blank=True)
- logo = models.ImageField(upload_to="institutions/logos/", blank=True)
+ name = models.CharField(max_length=200, unique=True, verbose_name=_("name"))
+ abbreviation = models.CharField(max_length=200, verbose_name=_("abbreviation"))
+ url = models.URLField(max_length=200, blank=True, verbose_name=_("URL"))
+ email = models.EmailField(max_length=200, blank=True, verbose_name=_("email"))
+ logo = models.ImageField(upload_to="institutions/logos/", blank=True, verbose_name=_("logo"))
# added simple historical records to the model
history = HistoricalRecords()
+ class Meta:
+ verbose_name = _("Institution")
+ verbose_name_plural = _("Institutions")
+
def __str__(self):
return f"{self.name} ({self.abbreviation})"
class Language(models.Model):
- name = models.CharField(max_length=150, unique=True)
+ name = models.CharField(max_length=150, unique=True, verbose_name=_("name"))
iso_code = models.CharField(
max_length=50,
unique=True,
- help_text="The 2 or 3 letter code from ISO 639.",
- verbose_name="ISO code",
+ help_text=_("The 2 or 3 letter code from ISO 639."),
+ verbose_name=_("ISO code"),
)
# added simple historical records to the model
history = HistoricalRecords()
+ class Meta:
+ verbose_name = _("Language")
+ verbose_name_plural = _("Languages")
+
def __str__(self):
return self.name
class Subject(models.Model):
- name = models.CharField(max_length=150, unique=True)
+ name = models.CharField(max_length=150, unique=True, verbose_name=_("name"))
# added simple historical records to the model
history = HistoricalRecords()
+ class Meta:
+ verbose_name = _("Subject")
+ verbose_name_plural = _("Subjects")
+
def __str__(self):
return self.name
@@ -68,52 +85,65 @@ class DocumentFile(models.Model):
# names and abbreviations based on
# https://en.wikipedia.org/wiki/Creative_Commons_license#Six_regularly_used_licenses
license_choices = [
- ("(c)", "All rights reserved"),
- ("CC0", "No rights reserved"),
- ("CC BY", "Creative Commons Attribution"),
- ("CC BY-SA", "Creative Commons Attribution-ShareAlike"),
- ("CC BY-NC", "Creative Commons Attribution-NonCommercial"),
- ("CC BY-NC-SA", "Creative Commons Attribution-NonCommercial-ShareAlike"),
+ ("(c)", _("All rights reserved")),
+ ("CC0", _("No rights reserved")),
+ ("CC BY", _("Creative Commons Attribution")),
+ ("CC BY-SA", _("Creative Commons Attribution-ShareAlike")),
+ ("CC BY-NC", _("Creative Commons Attribution-NonCommercial")),
+ ("CC BY-NC-SA", _("Creative Commons Attribution-NonCommercial-ShareAlike")),
]
- license_help_text = """
-
- More information about Creative Commons licenses.
- '
- """
- document_type_choices = [("Glossary", "Glossary"), ("Policy", "Policy")]
+ >
+ More information about Creative Commons licenses.
+ """
+ )
+ document_type_choices = [("Glossary", _("Glossary")), ("Policy", _("Policy"))]
file_type = "pdf"
- title = models.CharField(max_length=200)
- url = models.URLField(max_length=200, blank=True, verbose_name="URL")
+ title = models.CharField(max_length=200, verbose_name=_("title"))
+ url = models.URLField(max_length=200, blank=True, verbose_name=_("URL"))
uploaded_file = models.FileField(
upload_to="documents/",
validators=file_validators,
blank=True,
- help_text="PDF files up to 10MB are allowed.",
+ help_text=_("PDF files up to 10MB are allowed."),
+ verbose_name=_("uploaded file"),
)
- available = models.BooleanField(default=True)
+ available = models.BooleanField(default=True, verbose_name=_("available"))
license = models.CharField(
max_length=200,
choices=license_choices,
default="(c)",
help_text=license_help_text,
+ verbose_name=_("license"),
)
mime_type = models.CharField(
- max_length=200, blank=True, help_text="This input will auto-populate."
+ max_length=200,
+ blank=True,
+ help_text=_("This input will auto-populate."),
+ verbose_name=_("MIME type"),
+ )
+ document_type = models.CharField(
+ max_length=200, choices=document_type_choices, verbose_name=_("document type")
)
- document_type = models.CharField(max_length=200, choices=document_type_choices)
- document_data = models.TextField(blank=True)
- institution = models.ForeignKey("Institution", on_delete=models.CASCADE)
- subjects = models.ManyToManyField("Subject", blank=True)
- languages = models.ManyToManyField("Language", blank=True)
+ document_data = models.TextField(blank=True, verbose_name=_("document data"))
+ institution = models.ForeignKey(
+ "Institution", on_delete=models.CASCADE, verbose_name=_("institution")
+ )
+ subjects = models.ManyToManyField("Subject", blank=True, verbose_name=_("subjects"))
+ languages = models.ManyToManyField("Language", blank=True, verbose_name=_("languages"))
# added simple historical records to the model
history = HistoricalRecords(excluded_fields=["document_data"])
+ class Meta:
+ verbose_name = _("Document File")
+ verbose_name_plural = _("Document Files")
+
def __str__(self):
return self.title