def add_app_type request app_name all_names name for in Application ob

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
def add_app_type(request, app_name):
all_names = [o.name for o in Application.objects.all()]
types = [ t[1] for t in Application.TYPE_CHOICES ]
if app_name not in all_names:
Application.objects.create(name=app_name)
app = Application.objects.get(name__exact=app_name)
if request.POST:
for type in types:
if request.POST.has_key(type):
app.type = type
app.save()
if request.POST.has_key('change'):
app.type = ""
app.save()
has_type = bool(app.type)
stuff = {'app_name': app_name, 'app_type': app.type, 'has_type': has_type, 'types': types}
return render_to_response("edit_application.html", stuff)