-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #705 from openedx/saleem-latif/ENT-7544
ENT-7544: Added new app academy with related models
- Loading branch information
Showing
10 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
""" | ||
Academy app to handle implementation for academies. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
Admin for academy models. | ||
""" | ||
from django.contrib import admin | ||
from simple_history.admin import SimpleHistoryAdmin | ||
|
||
from enterprise_catalog.apps.academy.models import Academy, Tag | ||
|
||
|
||
@admin.register(Tag) | ||
class TagAdmin(admin.ModelAdmin): | ||
""" | ||
Django admin for Tag. | ||
""" | ||
list_display = ('id', 'title', ) | ||
search_fields = ('title', ) | ||
|
||
|
||
@admin.register(Academy) | ||
class AcademyAdmin(SimpleHistoryAdmin): | ||
""" | ||
Django admin for Academy. | ||
""" | ||
list_display = ('uuid', 'title', 'created', 'modified', ) | ||
search_fields = ('title', 'short_description', 'long_description', ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
""" | ||
Academy app to handle implementation for academies. | ||
""" | ||
from django.apps import AppConfig | ||
|
||
|
||
class AcademyConfig(AppConfig): | ||
name = 'academy' | ||
default = False |
76 changes: 76 additions & 0 deletions
76
enterprise_catalog/apps/academy/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Generated by Django 4.2.5 on 2023-11-02 07:29 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import model_utils.fields | ||
import simple_history.models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('catalog', '0037_alter_historicalcontentmetadata_options_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Tag', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(help_text='Tag title', max_length=255)), | ||
('description', models.TextField(help_text='Tag description.')), | ||
], | ||
options={ | ||
'verbose_name': 'Tag', | ||
'verbose_name_plural': 'Tags', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='HistoricalAcademy', | ||
fields=[ | ||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||
('uuid', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)), | ||
('title', models.CharField(help_text='Academy title', max_length=255)), | ||
('short_description', models.TextField(help_text='Short description of the academy.')), | ||
('long_description', models.TextField(help_text='Long description of the academy.')), | ||
('image', models.URLField(help_text='URL of the image shown on academy card on the frontend.')), | ||
('history_id', models.AutoField(primary_key=True, serialize=False)), | ||
('history_date', models.DateTimeField(db_index=True)), | ||
('history_change_reason', models.CharField(max_length=100, null=True)), | ||
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)), | ||
('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'verbose_name': 'historical Academy', | ||
'verbose_name_plural': 'historical Academies', | ||
'ordering': ('-history_date', '-history_id'), | ||
'get_latest_by': ('history_date', 'history_id'), | ||
}, | ||
bases=(simple_history.models.HistoricalChanges, models.Model), | ||
), | ||
migrations.CreateModel( | ||
name='Academy', | ||
fields=[ | ||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||
('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('title', models.CharField(help_text='Academy title', max_length=255)), | ||
('short_description', models.TextField(help_text='Short description of the academy.')), | ||
('long_description', models.TextField(help_text='Long description of the academy.')), | ||
('image', models.URLField(help_text='URL of the image shown on academy card on the frontend.')), | ||
('enterprise_catalogs', models.ManyToManyField(related_name='academies', to='catalog.enterprisecatalog')), | ||
('tags', models.ManyToManyField(related_name='academies', to='academy.tag')), | ||
], | ||
options={ | ||
'verbose_name': 'Academy', | ||
'verbose_name_plural': 'Academies', | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
Models for academy app. | ||
""" | ||
from uuid import uuid4 | ||
|
||
from django.db import models | ||
from django.utils.translation import gettext as _ | ||
from model_utils.models import TimeStampedModel | ||
from simple_history.models import HistoricalRecords | ||
|
||
from enterprise_catalog.apps.catalog.models import EnterpriseCatalog | ||
|
||
|
||
class Tag(models.Model): | ||
""" | ||
Model that can be used to tag records on any model. | ||
.. no_pii: | ||
""" | ||
title = models.CharField(max_length=255, help_text=_('Tag title')) | ||
description = models.TextField(help_text=_('Tag description.')) | ||
|
||
class Meta: | ||
verbose_name = _('Tag') | ||
verbose_name_plural = _('Tags') | ||
app_label = 'academy' | ||
|
||
def __str__(self): | ||
""" | ||
Return human-readable string representation. | ||
""" | ||
|
||
return f'<Tag title="{self.title}">' | ||
|
||
|
||
class Academy(TimeStampedModel): | ||
""" | ||
Model for storing academy related information. | ||
.. no_pii: | ||
""" | ||
uuid = models.UUIDField(primary_key=True, default=uuid4, editable=False) | ||
title = models.CharField(max_length=255, help_text=_('Academy title')) | ||
enterprise_catalogs = models.ManyToManyField(EnterpriseCatalog, related_name='academies') | ||
short_description = models.TextField(help_text=_('Short description of the academy.')) | ||
long_description = models.TextField(help_text=_('Long description of the academy.')) | ||
image = models.URLField(help_text=_('URL of the image shown on academy card on the frontend.')) | ||
|
||
tags = models.ManyToManyField(Tag, related_name='academies') | ||
|
||
history = HistoricalRecords() | ||
|
||
class Meta: | ||
verbose_name = _('Academy') | ||
verbose_name_plural = _('Academies') | ||
app_label = 'academy' | ||
|
||
def __str__(self): | ||
""" | ||
Return human-readable string representation. | ||
""" | ||
|
||
return f'<Academy UUID="{self.uuid}">' |
36 changes: 36 additions & 0 deletions
36
..._catalog/apps/catalog/migrations/0037_alter_historicalcontentmetadata_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 4.2.5 on 2023-10-30 07:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('catalog', '0036_auto_20230306_1550'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='historicalcontentmetadata', | ||
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Content Metadata', 'verbose_name_plural': 'historical Content Metadata'}, | ||
), | ||
migrations.AlterModelOptions( | ||
name='historicalenterprisecatalog', | ||
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Enterprise Catalog', 'verbose_name_plural': 'historical Enterprise Catalogs'}, | ||
), | ||
migrations.AlterField( | ||
model_name='contentmetadata', | ||
name='associated_content_metadata', | ||
field=models.ManyToManyField(blank=True, to='catalog.contentmetadata'), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalcontentmetadata', | ||
name='history_date', | ||
field=models.DateTimeField(db_index=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalenterprisecatalog', | ||
name='history_date', | ||
field=models.DateTimeField(db_index=True), | ||
), | ||
] |
40 changes: 40 additions & 0 deletions
40
...pps/curation/migrations/0003_alter_historicalenterprisecurationconfig_options_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Generated by Django 4.2.5 on 2023-10-30 07:39 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('curation', '0002_add_can_only_view_highlight_sets'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='historicalenterprisecurationconfig', | ||
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical Enterprise curation', 'verbose_name_plural': 'historical Enterprise curations'}, | ||
), | ||
migrations.AlterModelOptions( | ||
name='historicalhighlightedcontent', | ||
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical highlighted content', 'verbose_name_plural': 'historical highlighted contents'}, | ||
), | ||
migrations.AlterModelOptions( | ||
name='historicalhighlightset', | ||
options={'get_latest_by': ('history_date', 'history_id'), 'ordering': ('-history_date', '-history_id'), 'verbose_name': 'historical highlight set', 'verbose_name_plural': 'historical highlight sets'}, | ||
), | ||
migrations.AlterField( | ||
model_name='historicalenterprisecurationconfig', | ||
name='history_date', | ||
field=models.DateTimeField(db_index=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalhighlightedcontent', | ||
name='history_date', | ||
field=models.DateTimeField(db_index=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalhighlightset', | ||
name='history_date', | ||
field=models.DateTimeField(db_index=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters