Steve Losh avatar Steve Losh committed fbe2576

Require login to start a build.

Comments (0)

Files changed (3)

integration/views.py

         { 'run': run, 'hours': hours, 'minutes': minutes, 'seconds': seconds },
         context_instance=RequestContext(request) )
 
+@login_required
 def run_build(request, slug):
     project = get_object_or_404(Project, slug=slug)
     
-    if 'run' in request.POST and request.POST['run'] == 'run':
+    if ('run' in request.POST and project.last_build().end_time):
         project.run_build()
     
     return HttpResponseRedirect(project.get_absolute_url())
 MEDIA_ROOT = os.path.join(BASE_DIR, 'site-media/')
 MEDIA_URL = '/site-media/'
 ADMIN_MEDIA_PREFIX = '/media/'
+LOGIN_URL = '/admin/'
 
 # Make this unique, and don't share it with anybody.
 SECRET_KEY = '9focewlvxae*5(p-f^l=9kp@2to*&dnsk$*o4!k+s^lhy18f1%'

templates/integration/project.html

     </ul>
     
     {% if not project.last_build or project.last_build.end_time %}
-        <form method="post" action="{% url run_build slug=project.slug %}">
-            <p><input type="submit" value="Start a build" /></p>
-            <input type="hidden" name="run" value="run" />
-        </form>
+        {% if user.is_active %}
+            <form method="post" action="{% url run_build slug=project.slug %}">
+                <p><input type="submit" value="Start a build" /></p>
+                <input type="hidden" name="run" value="run" />
+            </form>
+        {% else %}
+            <p>You must be logged in to start a build!</p>
+        {% endif %}
     {% else %}
         {% if project.last_build %}
             <p><a href="{{ project.last_build.get_absolute_url }}">A build</a> is currently running (it started {{ project.last_build.start_time|timesince }} ago).  Wait for it to finish before you start another one!</p>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.