mirror of
https://github.com/retspen/webvirtcloud
synced 2024-11-01 03:54:15 +00:00
allow multiple owners of single instance. this is controlled by settings.ALLOW_INSTANCE_MULTIPLE_OWNER
This commit is contained in:
parent
50ddda98f2
commit
6151792d9b
2 changed files with 18 additions and 9 deletions
|
@ -7,6 +7,7 @@ from django.contrib.auth.decorators import login_required
|
||||||
from accounts.models import UserInstance, UserSSHKey
|
from accounts.models import UserInstance, UserSSHKey
|
||||||
from instances.models import Instance
|
from instances.models import Instance
|
||||||
from accounts.forms import UserAddForm
|
from accounts.forms import UserAddForm
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -135,6 +136,11 @@ def account(request, user_id):
|
||||||
user_insts = UserInstance.objects.filter(user_id=user_id)
|
user_insts = UserInstance.objects.filter(user_id=user_id)
|
||||||
instances = Instance.objects.all()
|
instances = Instance.objects.all()
|
||||||
|
|
||||||
|
def add_user_inst(request, inst_id, user_id):
|
||||||
|
add_user_inst = UserInstance(instance_id=int(inst_id), user_id=user_id)
|
||||||
|
add_user_inst.save()
|
||||||
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
|
|
||||||
if user.username == request.user.username:
|
if user.username == request.user.username:
|
||||||
return HttpResponseRedirect(reverse('profile'))
|
return HttpResponseRedirect(reverse('profile'))
|
||||||
|
|
||||||
|
@ -155,13 +161,14 @@ def account(request, user_id):
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
return HttpResponseRedirect(request.get_full_path())
|
||||||
if 'add' in request.POST:
|
if 'add' in request.POST:
|
||||||
inst_id = request.POST.get('inst_id', '')
|
inst_id = request.POST.get('inst_id', '')
|
||||||
try:
|
if settings.ALLOW_INSTANCE_MULTIPLE_OWNER:
|
||||||
check_inst = UserInstance.objects.get(instance_id=int(inst_id))
|
return add_user_inst(request, inst_id, user_id)
|
||||||
msg = _("Instance already added")
|
else:
|
||||||
error_messages.append(msg)
|
try:
|
||||||
except UserInstance.DoesNotExist:
|
check_inst = UserInstance.objects.get(instance_id=int(inst_id))
|
||||||
add_user_inst = UserInstance(instance_id=int(inst_id), user_id=user_id)
|
msg = _("Instance already added")
|
||||||
add_user_inst.save()
|
error_messages.append(msg)
|
||||||
return HttpResponseRedirect(request.get_full_path())
|
except UserInstance.DoesNotExist:
|
||||||
|
return add_user_inst(request, inst_id, user_id)
|
||||||
|
|
||||||
return render(request, 'account.html', locals())
|
return render(request, 'account.html', locals())
|
||||||
|
|
|
@ -8,7 +8,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
SECRET_KEY = '4y(f4rfqc6f2!i8_vfuu)kav6tdv5#sc=n%o451dm+th0&3uci'
|
SECRET_KEY = '4y(f4rfqc6f2!i8_vfuu)kav6tdv5#sc=n%o451dm+th0&3uci'
|
||||||
|
|
||||||
DEBUG = True
|
DEBUG = False
|
||||||
|
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
|
|
||||||
|
@ -111,3 +111,5 @@ QEMU_KEYMAPS = ['ar', 'da', 'de', 'de-ch', 'en-gb', 'en-us', 'es', 'et', 'fi',
|
||||||
# keepalive interval and count for libvirt connections
|
# keepalive interval and count for libvirt connections
|
||||||
LIBVIRT_KEEPALIVE_INTERVAL = 5
|
LIBVIRT_KEEPALIVE_INTERVAL = 5
|
||||||
LIBVIRT_KEEPALIVE_COUNT = 5
|
LIBVIRT_KEEPALIVE_COUNT = 5
|
||||||
|
|
||||||
|
ALLOW_INSTANCE_MULTIPLE_OWNER = True
|
||||||
|
|
Loading…
Reference in a new issue