Commit b4e4afe4 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers 🐦

used cached property for fetching latest upload to prevent multiple hits

parent c6c6cb0f
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
......@@ -176,15 +177,15 @@ class Submission(models.Model):
raise ValueError("unknown submission type")
def current_upload(self):
return self.uploads.first()
def current_text(self):
return self.text_submissions.first()
def current(self):
if self.submission_type == "U":
return self.current_upload
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment