mirror of
https://github.com/retspen/webvirtcloud
synced 2024-12-26 08:05:22 +00:00
Merge pull request #603 from krejcar25/master
Get UserAttributes object using get_or_create
This commit is contained in:
commit
43fc419490
2 changed files with 3 additions and 3 deletions
|
@ -117,7 +117,7 @@ def user_create(request):
|
||||||
@superuser_only
|
@superuser_only
|
||||||
def user_update(request, pk):
|
def user_update(request, pk):
|
||||||
user = get_object_or_404(User, pk=pk)
|
user = get_object_or_404(User, pk=pk)
|
||||||
attributes = UserAttributes.objects.get(user=user)
|
attributes, attributes_created = UserAttributes.objects.get_or_create(user=user)
|
||||||
user_form = forms.UserForm(request.POST or None, instance=user)
|
user_form = forms.UserForm(request.POST or None, instance=user)
|
||||||
attributes_form = forms.UserAttributesForm(
|
attributes_form = forms.UserAttributesForm(
|
||||||
request.POST or None, instance=attributes
|
request.POST or None, instance=attributes
|
||||||
|
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from accounts.models import UserInstance
|
from accounts.models import UserInstance, UserAttributes
|
||||||
from appsettings.settings import app_settings
|
from appsettings.settings import app_settings
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -26,7 +26,7 @@ def get_clone_free_names(size=10):
|
||||||
|
|
||||||
|
|
||||||
def check_user_quota(user, instance, cpu, memory, disk_size):
|
def check_user_quota(user, instance, cpu, memory, disk_size):
|
||||||
ua = user.userattributes
|
ua, attributes_created = UserAttributes.objects.get_or_create(user=user)
|
||||||
msg = ""
|
msg = ""
|
||||||
|
|
||||||
if user.is_superuser:
|
if user.is_superuser:
|
||||||
|
|
Loading…
Reference in a new issue