Skip to content

Commit

Permalink
Updated relationship type logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Drayer committed Dec 30, 2014
1 parent effc17c commit 6e844a3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 96 deletions.
22 changes: 11 additions & 11 deletions milestones/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ def _get_milestone_relationship_type(relationship):
active=True
)
except internal.MilestoneRelationshipType.DoesNotExist:
raise exceptions.InvalidMilestoneRelationshipTypeException()
if relationship in ['requires', 'fulfills']:
return internal.MilestoneRelationshipType.objects.create(
name=relationship,
active=True
)
else:
raise exceptions.InvalidMilestoneRelationshipTypeException()


# PUBLIC METHODS
Expand Down Expand Up @@ -128,15 +134,12 @@ def create_course_milestone(course_key, relationship, milestone):
Inserts a new course-milestone into app/local state
No response currently defined for this operation
"""
mrt, __ = internal.MilestoneRelationshipType.objects.get_or_create( # pylint: disable=invalid-name
name=relationship,
active=True
)
relationship_type = _get_milestone_relationship_type(relationship)
milestone_obj = serializers.deserialize_milestone(milestone)
internal.CourseMilestone.objects.get_or_create(
course_id=unicode(course_key),
milestone=milestone_obj,
milestone_relationship_type=mrt,
milestone_relationship_type=relationship_type,
active=True,
)

Expand Down Expand Up @@ -193,16 +196,13 @@ def create_course_content_milestone(course_key, content_key, relationship, miles
Inserts a new course-content-milestone into app/local state
No response currently defined for this operation
"""
mrt, __ = internal.MilestoneRelationshipType.objects.get_or_create( # pylint: disable=invalid-name
name=relationship,
active=True
)
relationship_type = _get_milestone_relationship_type(relationship)
milestone_obj = serializers.deserialize_milestone(milestone)
internal.CourseContentMilestone.objects.get_or_create(
course_id=unicode(course_key),
content_id=unicode(content_key),
milestone=milestone_obj,
milestone_relationship_type=mrt,
milestone_relationship_type=relationship_type,
active=True,
)

Expand Down
85 changes: 0 additions & 85 deletions milestones/migrations/0002_seed_types.py

This file was deleted.

0 comments on commit 6e844a3

Please sign in to comment.