Skip to content
Snippets Groups Projects
Commit 4e428cd1 authored by Samuel GAIST's avatar Samuel GAIST Committed by Samuel GAIST
Browse files

[attestations] Add for_user method

This allows to accurately reflect what the user
can see from the platform.
parent a79f92df
No related branches found
No related tags found
2 merge requests!386Fix front page stats,!342Django 3 migration
This commit is part of merge request !386. Comments created here will be created in the context of that merge request.
...@@ -31,6 +31,7 @@ from datetime import timedelta ...@@ -31,6 +31,7 @@ from datetime import timedelta
from django.conf import settings from django.conf import settings
from django.db import models from django.db import models
from django.db.models import Q
from django.urls import reverse from django.urls import reverse
from ..algorithms.models import Algorithm from ..algorithms.models import Algorithm
...@@ -75,6 +76,17 @@ class AttestationManager(models.Manager): ...@@ -75,6 +76,17 @@ class AttestationManager(models.Manager):
def published(self): def published(self):
return self.filter(locked=False) 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): class Attestation(models.Model):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment