Skip to content

Commit

Permalink
feat: django admin for content_assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Sep 19, 2023
1 parent e7309d5 commit c64d714
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ dmypy.json

# emacs
*~
.projectile

# VSCode
.vscode
Expand Down
54 changes: 54 additions & 0 deletions enterprise_access/apps/content_assignments/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
""" Admin configuration for content_assignment models. """

from django.contrib import admin
from djangoql.admin import DjangoQLSearchMixin
from simple_history.admin import SimpleHistoryAdmin

from enterprise_access.apps.content_assignments import models


@admin.register(models.AssignmentConfiguration)
class AssignmentConfigurationAdmin(DjangoQLSearchMixin, SimpleHistoryAdmin):
list_display = (
'enterprise_customer_uuid',
'uuid',
'active',
'modified',
)
search_fields = (
'uuid',
'enterprise_customer_uuid',
)
list_filter = ('active',)
ordering = ['-modified']
read_only_fields = (
'created',
'modified',
)


@admin.register(models.LearnerContentAssignment)
class LearnerContentAssignment(DjangoQLSearchMixin, SimpleHistoryAdmin):
list_display = (
'assignment_configuration',
'learner_email',
'lms_user_id',
'content_key',
'state',
'content_quantity',
'modified',
)
ordering = ['-modified']
search_fields = (
'uuid',
'learner_email',
'lms_user_id',
)
list_filter = ('state',)
read_only_fields = (
'last_notification_at',
'created',
'modified',
'lms_user_id',
'assignment_configuration',
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.21 on 2023-09-19 15:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('content_assignments', '0006_unique_assignments'),
]

operations = [
migrations.AlterField(
model_name='historicallearnercontentassignment',
name='state',
field=models.CharField(choices=[('allocated', 'Allocated'), ('accepted', 'Accepted'), ('cancelled', 'Cancelled'), ('errored', 'Errored')], db_index=True, default='allocated', help_text="The current state of the LearnerContentAssignment. One of: ['allocated', 'accepted', 'cancelled', 'errored']", max_length=255),
),
migrations.AlterField(
model_name='learnercontentassignment',
name='state',
field=models.CharField(choices=[('allocated', 'Allocated'), ('accepted', 'Accepted'), ('cancelled', 'Cancelled'), ('errored', 'Errored')], db_index=True, default='allocated', help_text="The current state of the LearnerContentAssignment. One of: ['allocated', 'accepted', 'cancelled', 'errored']", max_length=255),
),
]
1 change: 1 addition & 0 deletions enterprise_access/apps/content_assignments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class Meta:
max_length=255,
blank=False,
null=False,
db_index=True,
choices=LearnerContentAssignmentStateChoices.CHOICES,
default=LearnerContentAssignmentStateChoices.ALLOCATED,
help_text=(
Expand Down

0 comments on commit c64d714

Please sign in to comment.