Fix issues with retirement state population and unenrollment

- Prevent RetirementState state_execution_order collisions when updating
- Add slash to end of unenroll API endpoint to match other retirement endpoints
This commit is contained in:
bmedx
2018-05-09 10:40:00 -04:00
parent 330ca36d16
commit 01ebe1e26e
2 changed files with 6 additions and 1 deletions

View File

@@ -17,5 +17,5 @@ urlpatterns = [
url(r'^enrollment$', EnrollmentListView.as_view(), name='courseenrollments'),
url(r'^course/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN),
EnrollmentCourseDetailView.as_view(), name='courseenrollmentdetails'),
url(r'^unenroll$', UnenrollmentView.as_view(), name='unenrollment'),
url(r'^unenroll/$', UnenrollmentView.as_view(), name='unenrollment'),
]

View File

@@ -16,6 +16,7 @@ import logging
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.db.models import F
from openedx.core.djangoapps.user_api.models import RetirementState, UserRetirementStatus
@@ -101,6 +102,10 @@ class Command(BaseCommand):
# Delete states slated for removal
RetirementState.objects.filter(state_name__in=states_to_delete).delete()
# Get all of our remaining states out of the way so we don't have
# state_execution_order collisions
RetirementState.objects.all().update(state_execution_order=F('state_execution_order') + 500)
# Add new rows, with space in between to manually insert stages via Django admin if necessary
curr_sort_order = 1
for state in new_states: