Skip to content

Commit

Permalink
Allow admins to trigger project builds (#4207)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfischer authored and agjohnson committed Jun 8, 2018
1 parent b693d56 commit 1dd68c3
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions readthedocs/builds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@

from django.shortcuts import get_object_or_404
from django.views.generic import ListView, DetailView
from django.http import HttpResponsePermanentRedirect, HttpResponseRedirect
from django.conf import settings
from django.http import (
HttpResponseForbidden,
HttpResponsePermanentRedirect,
HttpResponseRedirect,
)
from django.contrib.auth.decorators import login_required
from readthedocs.core.permissions import AdminPermission
from django.core.urlresolvers import reverse
from django.utils.decorators import method_decorator

Expand Down Expand Up @@ -38,10 +42,11 @@ class BuildTriggerMixin(object):

@method_decorator(login_required)
def post(self, request, project_slug):
project = get_object_or_404(
Project.objects.for_admin_user(self.request.user),
slug=project_slug
)
project = get_object_or_404(Project, slug=project_slug)

if not AdminPermission.is_admin(request.user, project):
return HttpResponseForbidden()

version_slug = request.POST.get('version_slug')
version = get_object_or_404(
Version,
Expand Down

0 comments on commit 1dd68c3

Please sign in to comment.