Commit 4e428cd1 authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST

[attestations] Add for_user method

This allows to accurately reflect what the user
can see from the platform.
parent a79f92df
......@@ -31,6 +31,7 @@ from datetime import timedelta
from django.conf import settings
from django.db import models
from django.db.models import Q
from django.urls import reverse
from ..algorithms.models import Algorithm
......@@ -75,6 +76,17 @@ class AttestationManager(models.Manager):
def published(self):
return self.filter(locked=False)
def for_user(self, user, add_public=False):
if user.is_anonymous:
return self.published()
query = Q(experiment__author=user)
if add_public:
query |= Q(locked=False)
return self.filter(query).distinct()
class Attestation(models.Model):
......
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