def remove_site(request): u = request.session.get('switched_user', request.user) try: object_id = request.POST['object_id'] s = get_object_or_404(UserSite, id=object_id) if s.owner != u: raise Exception("Forbidden operation") s.removed = True s.end_date = date.today() s.save() #Signal restart_master(config.mode, u) ur = UWSGIRequest(u, u.parms.web_machine) ur.stop(s) ur.mod_config() # calculate! u.parms.pay_for_sites(use_cache=False) return JsonResponse("OK", {1: ugettext("Site was successfuly removed")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error deleting site")})
def rm(request): try: u = request.session.get('switched_user', request.user) p = get_object_or_404(u.program_set, id=request.POST['object_id']) p.delete() return JsonResponse("OK", {1: _("Program was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: _("Error deleting program")})
def remove_cron(request): u = request.session.get('switched_user', request.user) superuser = request.user try: cron = request.user.cron_set.get(id=int(request.POST.get("object_id"))) cron.delete() sr = SystemRequest(request.user, request.user.parms.web_machine) sr.cron(request.user) return JsonResponse("OK", {1: ugettext("Cron record was successfuly removed")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error deleting cron record")})
def remove_site(request): user = request.session.get('switched_user', request.user) try: object_id = request.POST['object_id'] spp = get_object_or_404(user.usersite_set, id=int(object_id)) if spp.owner != user: raise Exception("Forbidden operation") remove_app_preparation(spp) spp.delete() return JsonResponse("OK", {1: ugettext("Site was successfuly removed")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error deleting site")})
def remove_ftp(request): try: object_id = request.POST['object_id'] try: ftp = Ftp.objects.get(id=object_id) except Ftp.DoesNotExist: raise Exception("redirect doesn't exist, obviously") else: ftp.delete() return JsonResponse("OK", {1: ugettext("FTP account was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error during FTP account delete")})
def rm(request): #try: user = request.session.get('switched_user', request.user) domain = get_object_or_404(user.domain_set, id=request.POST['object_id']) if domain.owner == user: logging.info(_("Deleting domain %s") % domain.name) for subdomain in Domain.objects.filter(parent=domain): for app in subdomain.apps(): if app.domains_count <= 1: remove_app_preparation(app, remove_domains=False) app.delete() subdomain.delete() for app in domain.apps(): if app.domains_count <= 1: remove_app_preparation(app) app.delete() if config.handle_dns and domain.dns: pri_br = BindRequest(user, "master") pri_br.remove_zone(domain) pri_br.mod_config() pri_br.reload() if config.handle_dns_secondary: sec_br = BindRequest(user, "slave") sec_br.mod_config() sec_br.reload() domain.delete() return JsonResponse("OK", {1: ugettext("Domain was successfuly deleted")})
def refresh_venv(request): if not request.is_ajax(): return HttpResponseForbidden('non ajax not allowed') venvs = get_user_venvs(request.session.get('switched_user', request.user), False) return JsonResponse('OK', venvs)
def alias_remove(request): try: object_id = request.POST['object_id'] u = request.session.get('switched_user', request.user) try: r = EmailRedirect.objects.get(id=object_id, domain__user=u) except EmailRedirect.DoesNotExist: raise Exception("redirect doesn't exist, obviously") else: r.delete() return JsonResponse( "OK", {1: ugettext("Email alias was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error during alias delete")})
def refresh_userdirs(request): if not request.is_ajax(): return HttpResponseForbidden('non ajax not allowed') user_dirs = user_directories(request.session.get('switched_user', request.user), use_cache=False) return JsonResponse('OK', user_dirs)
def mailbox_remove(request): try: object_id = request.POST['object_id'] u = request.session.get('switched_user', request.user) try: mail = Email.objects.get(domain__in=u.domain_set.all(), id=object_id) except EmailRedirect.DoesNotExist: raise Exception("redirect doesn't exist, obviously") else: mail.remove = True mail.save() er = EMailRequest(u, u.parms.mail_machine) er.remove_mailbox(mail) return JsonResponse("OK", {1: ugettext("Mailbox was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error during mailbox delete")})
def rm(request, dbtype): try: object_id = request.POST['object_id'] u = request.session.get('switched_user', request.user) if dbtype == 'mysql': m = u.mysqldb_set.get(pk=object_id) mr = MySQLRequest(u, u.parms.mysql_machine) elif dbtype == 'pgsql': m = u.pgsql_set.get(pk=object_id) mr = PostgreSQLRequest(u, u.parms.pgsql_machine) else: raise Exception(ugettext('Unknown database type')) mr.remove_db(m.dbname) m.delete() return JsonResponse("OK", {1: ugettext("Database was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error during delete database")})
def rm(request): try: u = request.session.get('switched_user', request.user) d = get_object_or_404(Domain, id=request.POST['object_id']) if d.owner == u: logging.info(_("Deleting domain %s") % d.name) if config.handle_dns and d.dns: pri_br = BindRequest(u, "master") pri_br.remove_zone(d) pri_br.mod_config() pri_br.reload() sec_br = BindRequest(u, "slave") sec_br.mod_config() sec_br.reload() d.delete() return JsonResponse("OK", {1: ugettext("Domain was successfuly deleted")}) except Exception, e: return JsonResponse("KO", {1: ugettext("Error deleting domain")})
def refresh_wsgi(request): if not (request.method == 'POST' and request.is_ajax()): return HttpResponseForbidden('non ajax not allowed') wsgis = get_user_wsgis(request.session.get('switched_user', request.user), False) return JsonResponse('OK', wsgis)