Commit fe949b17 by David Ormsbee

Renamed Rubric.content_hash_for_rubric_dict to Rubric.content_hash_from_dict and…

Renamed Rubric.content_hash_for_rubric_dict to Rubric.content_hash_from_dict and added more comments.
parent 4dcc2c71
......@@ -47,12 +47,16 @@ class Rubric(models.Model):
return sum(criteria_points) if criteria_points else 0
@staticmethod
def content_hash_for_rubric_dict(rubric_dict):
def content_hash_from_dict(rubric_dict):
"""Given a dict of rubric information, return a unique hash.
This is a static method because we want to provide the `content_hash`
when we create the rubric -- i.e. before the Rubric object could know or
access its child criteria or options.
access its child criteria or options. In Django, when you add child
elements to a model object using a foreign key relation, it will
immediately persist to the database. But in order to persist to the
database, the child object needs to have the ID of the parent, meaning
that Rubric would have to have already been created and persisted.
"""
rubric_dict = deepcopy(rubric_dict)
......
......@@ -170,7 +170,7 @@ def rubric_from_dict(rubric_dict):
rubric_dict = deepcopy(rubric_dict)
# Calculate the hash based on the rubric content...
content_hash = Rubric.content_hash_for_rubric_dict(rubric_dict)
content_hash = Rubric.content_hash_from_dict(rubric_dict)
try:
rubric = Rubric.objects.get(content_hash=content_hash)
......
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