Skip to content

Do not show Build button when user is not project admin #3309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions readthedocs/rtd_tests/tests/test_privacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ def test_private_repo(self):
self.client.login(username='eric', password='test')
r = self.client.get('/projects/django-kong/')
self.assertEqual(r.status_code, 200)
# Build button should appear here
self.assertContains(r, 'Build a version')
r = self.client.get('/projects/django-kong/builds/')
self.assertEqual(r.status_code, 200)
# Build button should appear here
self.assertContains(r, 'Build Version:')
r = self.client.get('/projects/django-kong/downloads/')
self.assertEqual(r.status_code, 200)

Expand All @@ -100,16 +104,24 @@ def test_public_repo(self):
self.client.login(username='eric', password='test')
r = self.client.get('/projects/django-kong/')
self.assertEqual(r.status_code, 200)
# Build button should appear here
self.assertContains(r, 'Build a version')
r = self.client.get('/projects/django-kong/builds/')
self.assertEqual(r.status_code, 200)
# Build button should appear here
self.assertContains(r, 'Build Version:')
r = self.client.get('/projects/django-kong/downloads/')
self.assertEqual(r.status_code, 200)

self.client.login(username='tester', password='test')
r = self.client.get('/projects/django-kong/')
self.assertEqual(r.status_code, 200)
# Build button shouldn't appear here
self.assertNotContains(r, 'Build a version')
r = self.client.get('/projects/django-kong/builds/')
self.assertEqual(r.status_code, 200)
# Build button shouldn't appear here
self.assertNotContains(r, 'Build Version:')
r = self.client.get('/projects/django-kong/downloads/')
self.assertEqual(r.status_code, 200)

Expand Down Expand Up @@ -138,13 +150,14 @@ def test_public_branch(self):

self.client.login(username='eric', password='test')
Version.objects.create(project=kong, identifier='test id',
verbose_name='test verbose', slug='test-slug', active=True)
verbose_name='test verbose', slug='test-slug',
active=True, built=True)
self.assertEqual(Version.objects.count(), 2)
self.assertEqual(Version.objects.all()[0].privacy_level, 'public')
r = self.client.get('/projects/django-kong/')
self.assertContains(r, 'test-slug')

# Make sure it doesn't show up as tester
# Make sure it does show up as tester
self.client.login(username='tester', password='test')
r = self.client.get('/projects/django-kong/')
self.assertContains(r, 'test-slug')
Expand Down
3 changes: 2 additions & 1 deletion readthedocs/templates/builds/build_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load i18n %}

{% load pagination_tags %}
{% load privacy_tags %}
{% load projects_tags %}

{% block title %}Builds{% endblock %}
Expand Down Expand Up @@ -37,7 +38,7 @@
<div class="module-wrapper">

{% block build_versions %}
{% if versions %}
{% if versions and request.user|is_admin:project %}
<div class="module-header">
<div style="float:right;">
<form method="post" action="{% url "builds_project_list" project.slug %}">
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/templates/core/project_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h3>{% trans "Versions" %}</h3>
</div>

{% block build_versions %}
{% if versions %}
{% if versions and request.user|is_admin:project %}
<div class="build_a_version">
<h3>{% trans "Build a version" %}</h3>
<div class="version_right">
Expand Down