Skip to content

Commit

Permalink
Merge pull request #5096 from rtfd/humitos/skip-build-on-banned-users
Browse files Browse the repository at this point in the history
Do not build projects from banned users
  • Loading branch information
ericholscher committed Jan 15, 2019
2 parents a972eb1 + 873f5c3 commit 7aa57bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion readthedocs/projects/querysets.py
Expand Up @@ -62,14 +62,16 @@ def is_active(self, project):
The check consists on,
* the Project shouldn't be marked as skipped.
* any of the project's owners is banned.
:param project: project to be checked
:type project: readthedocs.projects.models.Project
:returns: whether or not the project is active
:rtype: bool
"""
if project.skip:
any_owner_banned = any(u.profile.banned for u in project.users.all())
if project.skip or any_owner_banned:
return False

return True
Expand Down
12 changes: 9 additions & 3 deletions readthedocs/rtd_tests/tests/test_project_querysets.py
@@ -1,11 +1,11 @@
from __future__ import absolute_import

# -*- coding: utf-8 -*-
from django.contrib.auth.models import User
from datetime import timedelta

import django_dynamic_fixture as fixture
from django.test import TestCase

from readthedocs.projects.models import Project, ProjectRelationship, Feature
from readthedocs.projects.models import Project, Feature
from readthedocs.projects.querysets import (ParentRelatedProjectQuerySet,
ChildRelatedProjectQuerySet)

Expand Down Expand Up @@ -37,6 +37,12 @@ def test_is_active(self):
project = fixture.get(Project, skip=True)
self.assertFalse(Project.objects.is_active(project))

user = fixture.get(User)
user.profile.banned = True
user.profile.save()
project = fixture.get(Project, skip=False, users=[user])
self.assertFalse(Project.objects.is_active(project))


class FeatureQuerySetTests(TestCase):

Expand Down

0 comments on commit 7aa57bb

Please sign in to comment.