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):
else:
raise ValueError("unknown submission type")
@property
@cached_property
def current_upload(self):
return self.uploads.first()
@property
@cached_property
def current_text(self):
return self.text_submissions.first()
@property
@cached_property
def current(self):
if self.submission_type == "U":
return self.current_upload
......
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