Commit ebf2f7de by Calen Pennington

Make enum for unit states

parent 0aa79ed4
......@@ -49,6 +49,12 @@ def get_lms_link_for_item(location):
return lms_link
class UnitState(object):
draft = 'draft'
private = 'private'
public = 'public'
def compute_unit_state(unit):
"""
Returns whether this unit is 'draft', 'public', or 'private'.
......@@ -62,8 +68,8 @@ def compute_unit_state(unit):
if unit.metadata.get('is_draft', False):
try:
modulestore('direct').get_item(unit.location)
return 'draft'
return UnitState.draft
except ItemNotFoundError:
return 'private'
return UnitState.private
else:
return 'public'
return UnitState.public
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment