first commit
This commit is contained in:
commit
3e4574dcdd
163 files changed
+3559
No files matched your search
@@ -0,0 +1,36 @@
|
||||
from apps.userprofile.models import UserProfile as UserProfileModel
|
||||
from rest_framework.validators import ValidationError
|
||||
from apps.cuser.models import CUser as CUserModel
|
||||
|
||||
|
||||
def update_userprofile(user_id: int, **kwargs):
|
||||
try:
|
||||
user_profile_obj = UserProfileModel.objects.get(cuser_id=user_id)
|
||||
|
||||
if 'ax_mojri' in kwargs:
|
||||
user_profile_obj.ax_mojri = kwargs.get('ax_mojri', None)
|
||||
kwargs.pop('ax_mojri')
|
||||
if 'ax_meli' in kwargs:
|
||||
user_profile_obj.ax_meli = kwargs.get('ax_meli', None)
|
||||
kwargs.pop('ax_meli')
|
||||
if 'ax_fani' in kwargs:
|
||||
user_profile_obj.ax_fani = kwargs.get('ax_fani', None)
|
||||
kwargs.pop('ax_fani')
|
||||
if 'ax_sayer' in kwargs:
|
||||
user_profile_obj.ax_sayer = kwargs.get('ax_sayer', None)
|
||||
kwargs.pop('ax_sayer')
|
||||
|
||||
user_profile_obj.save()
|
||||
|
||||
user_profile = UserProfileModel.objects.filter(cuser_id=user_id)
|
||||
name_family = kwargs.get('name_family')
|
||||
if name_family:
|
||||
kwargs.pop('name_family')
|
||||
CUserModel.objects.filter(id=user_id).update(name_family=name_family)
|
||||
|
||||
user_profile.update(**kwargs)
|
||||
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
raise ValidationError(e)
|
||||
Reference in new issue
Block a user