Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add model for messages #117

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Change Log

Unreleased
**********
* Add LearningAssistantMessage model

4.3.3 - 2024-10-15
******************
Expand Down
34 changes: 34 additions & 0 deletions learning_assistant/migrations/0007_learningassistantmessage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.15 on 2024-10-22 12:17

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 opaque_keys.edx.django.models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('learning_assistant', '0006_delete_courseprompt'),
]

operations = [
migrations.CreateModel(
name='LearningAssistantMessage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('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')),
('course_id', opaque_keys.edx.django.models.CourseKeyField(db_index=True, max_length=255)),
('role', models.CharField(max_length=64)),
('content', models.TextField()),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
options={
'abstract': False,
},
),
]
18 changes: 18 additions & 0 deletions learning_assistant/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
Database models for learning_assistant.
"""
from django.contrib.auth import get_user_model
from django.db import models
from model_utils.models import TimeStampedModel
from opaque_keys.edx.django.models import CourseKeyField

USER_MODEL = get_user_model()


class LearningAssistantCourseEnabled(TimeStampedModel):
"""
Expand All @@ -21,3 +24,18 @@ class LearningAssistantCourseEnabled(TimeStampedModel):
course_id = CourseKeyField(max_length=255, db_index=True, unique=True)

enabled = models.BooleanField()


class LearningAssistantMessage(TimeStampedModel):
"""
This model stores messages sent to and received from the learning assistant.

.. pii: content
.. pii_types: other
.. pii_retirement: third_party
"""

course_id = CourseKeyField(max_length=255, db_index=True)
user = models.ForeignKey(USER_MODEL, db_index=True, on_delete=models.CASCADE)
role = models.CharField(max_length=64)
content = models.TextField()
Loading