|
@@ -13,19 +13,32 @@ class UserValidation(Validation):
|
|
|
|
|
|
errors = {}
|
|
|
|
|
|
- if not 'first_name' in bundle.data:
|
|
|
- errors['first_name'] = 'this field is required'
|
|
|
+ if request.method == 'POST':
|
|
|
+ if not 'first_name' in bundle.data:
|
|
|
+ errors['first_name'] = 'this field is required'
|
|
|
|
|
|
- if not 'last_name' in bundle.data:
|
|
|
- errors['last_name'] = 'this field is required'
|
|
|
+ if not 'last_name' in bundle.data:
|
|
|
+ errors['last_name'] = 'this field is required'
|
|
|
|
|
|
- if not 'username' in bundle.data:
|
|
|
- errors['username'] = 'this field is required'
|
|
|
+ if not 'username' in bundle.data:
|
|
|
+ errors['username'] = 'this field is required'
|
|
|
|
|
|
- if not 'email' in bundle.data:
|
|
|
- errors['email'] = 'this field is required'
|
|
|
+ if not 'email' in bundle.data:
|
|
|
+ errors['email'] = 'this field is required'
|
|
|
|
|
|
- if not 'password' in bundle.data:
|
|
|
- errors['password'] = 'this field is required'
|
|
|
+ if not 'password' in bundle.data:
|
|
|
+ errors['password'] = 'this field is required'
|
|
|
+ else:
|
|
|
+ if 'username' in bundle.data:
|
|
|
+ errors['username'] = 'cannot update this field'
|
|
|
+
|
|
|
+ if 'password' in bundle.data:
|
|
|
+ errors['password'] = 'cannot update password here, use endpoint for specific action'
|
|
|
+
|
|
|
+ if 'last_login' in bundle.data:
|
|
|
+ errors['last_login'] = 'cannot create or update this field'
|
|
|
+
|
|
|
+ if 'date_joined' in bundle.data:
|
|
|
+ errors['date_joined'] = 'cannot create or update this field'
|
|
|
|
|
|
return errors
|