-
Notifications
You must be signed in to change notification settings - Fork 2
/
views.py
69 lines (57 loc) · 2.76 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from django.shortcuts import get_object_or_404, redirect, render_to_response
from django.http import HttpResponse, HttpResponseServerError
from django.template import RequestContext
from project.models import Project
from job_queue.jobs import queue_job, send_job
from job_queue.forms import StartAppForm
from notifications.models import Notification
def schedule_buildout(request, project_id):
return schedule_project_command(request, project_id, "BUILDOUT",
"Successfully queued buildout")
def schedule_bootstrap(request, project_id):
return schedule_project_command(request, project_id, "BOOTSTRAP",
"Successfully queued bootstrap")
def schedule_test(request, project_id):
return schedule_project_command(request, project_id, "TEST",
"Successfully queued test")
def schedule_pull(request, project_id):
return schedule_project_command(request, project_id, "GITPULL",
"Successfully queued git pull")
def schedule_syncdb(request, project_id):
return schedule_project_command(request, project_id, "SYNCDB",
"Successfully queued syncdb")
def schedule_migrate(request, project_id):
return schedule_project_command(request, project_id, "MIGRATE",
"Successfully queued south migrate")
def startapp(request, project_id):
# I feel like this belongs elsewhere
project = get_object_or_404(Project, id=project_id)
form = StartAppForm(request.POST or None)
if form.is_valid():
queue_job("STARTAPP", project_id=project_id, app_name=form.cleaned_data['app_name'])
return redirect(project.get_absolute_url())
return render_to_response("form.html", RequestContext(
request, {'form': form}))
def edit_buildout(request, project_id):
return schedule_project_command(request, project_id, "EDIT",
"Successfully edited")
def schedule_virtualenv(request, project_id):
return schedule_project_command(request, project_id, "VIRTUALENV",
"Successfully queued virtualenv")
def schedule_pip_install(request, project_id):
return schedule_project_command(request, project_id, "PIPINSTALL",
"Successfully queued pip_install")
def rerun_job(request, notification_id):
notification = get_object_or_404(Notification, id=notification_id)
print notification.rerun_job
if notification.rerun_job:
send_job(str(notification.rerun_job))
return HttpResponse("Queued")
return HttpResponse("No rerun specified")
def schedule_project_command(request, project_id, command, success_message):
project = get_object_or_404(Project, id=project_id)
try:
queue_job(command, project_id=project.id)
return HttpResponse(success_message)
except Exception as e:
return HttpResponseServerError("Error: " + str(e))