Skip to content

Commit

Permalink
Merge 42e63f6 into 6652e60
Browse files Browse the repository at this point in the history
  • Loading branch information
Rineee committed Jan 25, 2021
2 parents 6652e60 + 42e63f6 commit cbe9d70
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
8 changes: 4 additions & 4 deletions apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ class User(auth_models.AbstractBaseUser, auth_models.PermissionsMixin):
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['username']

def get_projects_follow_list(self):
def get_projects_follow_list(self, exclude_private_projects=False):
projects = Project.objects \
.filter(follow__creator=self,
follow__enabled=True,
is_draft=False) \
.filter(models.Q(access=Access.PUBLIC) |
models.Q(access=Access.SEMIPUBLIC))
is_draft=False)
if exclude_private_projects:
projects = projects.exclude(models.Q(access=Access.PRIVATE))

now = timezone.now()

Expand Down
14 changes: 1 addition & 13 deletions apps/users/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from django.db.models import Q
from django.views.generic.detail import DetailView

from adhocracy4.actions.models import Action
from adhocracy4.projects.enums import Access
from adhocracy4.projects.models import Project
from apps.organisations.models import Organisation

from . import models
Expand All @@ -13,19 +10,10 @@ class ProfileView(DetailView):
model = models.User
slug_field = 'username'

@property
def projects(self):
return Project.objects \
.filter(follow__creator=self.object,
follow__enabled=True,
is_draft=False) \
.filter(Q(access=Access.PUBLIC) |
Q(access=Access.SEMIPUBLIC))

@property
def projects_carousel(self):
sorted_active_projects, sorted_future_projects, sorted_past_projects =\
self.object.get_projects_follow_list()
self.object.get_projects_follow_list(exclude_private_projects=True)
return (list(sorted_active_projects) +
list(sorted_future_projects))[:9]

Expand Down

0 comments on commit cbe9d70

Please sign in to comment.