Revision 2398cbad edumanage/views.py
b/edumanage/views.py | ||
---|---|---|
357 | 357 |
|
358 | 358 |
} |
359 | 359 |
|
360 |
@login_required |
|
361 |
def del_server(request): |
|
362 |
if request.method == 'GET': |
|
363 |
user = request.user |
|
364 |
req_data = request.GET.copy() |
|
365 |
server_pk = req_data['server_pk'] |
|
366 |
profile = user.get_profile() |
|
367 |
institution = profile.institution |
|
368 |
resp = {} |
|
369 |
try: |
|
370 |
server = InstServer.objects.get(instid=institution, pk=server_pk) |
|
371 |
except InstServer.DoesNotExist: |
|
372 |
resp['error'] = "Could not get server or you have no rights to delete" |
|
373 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
374 |
try: |
|
375 |
server.delete() |
|
376 |
except: |
|
377 |
resp['error'] = "Could not delete server" |
|
378 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
379 |
resp['success'] = "Server successfully deleted" |
|
380 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
381 |
|
|
382 |
|
|
383 |
@login_required |
|
384 |
def del_service(request): |
|
385 |
if request.method == 'GET': |
|
386 |
user = request.user |
|
387 |
req_data = request.GET.copy() |
|
388 |
service_pk = req_data['service_pk'] |
|
389 |
profile = user.get_profile() |
|
390 |
institution = profile.institution |
|
391 |
resp = {} |
|
392 |
try: |
|
393 |
service = ServiceLoc.objects.get(institutionid=institution, pk=service_pk) |
|
394 |
except ServiceLoc.DoesNotExist: |
|
395 |
resp['error'] = "Could not get service or you have no rights to delete" |
|
396 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
397 |
try: |
|
398 |
service.delete() |
|
399 |
except: |
|
400 |
resp['error'] = "Could not delete service" |
|
401 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
402 |
resp['success'] = "Service successfully deleted" |
|
403 |
return HttpResponse(json.dumps(resp), mimetype='application/json') |
|
404 |
|
|
405 |
|
|
406 |
|
|
360 | 407 |
def geolocate(request): |
361 | 408 |
return render_to_response('front/geolocate.html', |
362 | 409 |
context_instance=RequestContext(request)) |
Also available in: Unified diff