Skip to content

Commit

Permalink
fix: add validation for courseware_id
Browse files Browse the repository at this point in the history
  • Loading branch information
arslanashraf7 committed Jun 20, 2024
1 parent 8876864 commit 96d99c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions courses/migrations/0040_alter_courserun_courseware_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.13 on 2024-06-20 10:20

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('courses', '0039_add_external_course_id_and_course_run_id'),
]

operations = [
migrations.AlterField(
model_name='courserun',
name='courseware_id',
field=models.CharField(max_length=255, unique=True, validators=[django.core.validators.RegexValidator('^[\\w\\-+:]+$', 'This field is used to produce URL paths. It must contain only characters that match this pattern: [\\w\\-+:]')]),
),
]
2 changes: 1 addition & 1 deletion courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class CourseRun(TimestampedModel):
)
product = GenericRelation(Product, related_query_name="course_run")
title = models.CharField(max_length=255)
courseware_id = models.CharField(max_length=255, unique=True)
courseware_id = models.CharField(max_length=255, unique=True, validators=[validate_url_path_field])
run_tag = models.CharField(
max_length=10,
help_text="A string that identifies the set of runs that this run belongs to (example: 'R2')",
Expand Down

0 comments on commit 96d99c9

Please sign in to comment.