def save(self, *args, **kwargs): if not self.email: self.email = self.get_dummy_email() elif in_dbca_domain(self): # checks and updates department user details from address book after every login user_details = get_department_user_compact(self.email) if user_details: # check if keys can be found in ITAssets api - the response JSON sent by API may have have changed if 'telephone' not in user_details or 'mobile_phone' not in user_details or 'title' not in user_details or 'location' not in user_details: logger.warn( 'Cannot find user details in ITAssets api call for user {}' .format(self.email)) # Only set the below fields if there is a value from address book (in ITAssets API). # This will allow fields in EmailUser object to be: # a. overridden whenever newer/updated fields (e.g. telephone number) are available in address book # b. if value for the field in address book empty/null, a previous value entered by user will not be overwritten with null if user_details.get('telephone'): self.phone_number = user_details.get('telephone') if user_details.get('mobile_phone'): self.mobile_number = user_details.get('mobile_phone') if user_details.get('title'): self.position_title = user_details.get('title') if user_details.get('location', {}).get('fax'): self.fax_number = user_details.get('location', {}).get('fax') self.is_staff = True self.email = self.email.lower() super(EmailUser, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if not self.email: self.email = self.get_dummy_email() elif in_dbca_domain(self): # checks and updates department user details from address book after every login user_details = get_department_user_compact(self.email) if user_details: self.phone_number = user_details.get('telephone') self.mobile_number = user_details.get('mobile_phone') self.title = user_details.get('title') self.fax_number = user_details.get('org_unit__location__fax') super(EmailUser, self).save(*args, **kwargs)
def save(self, *args, **kwargs): if not self.email: self.email = self.get_dummy_email() elif in_dbca_domain(self): # checks and updates department user details from address book after every login user_details = get_department_user_compact(self.email) if user_details: self.phone_number = user_details.get('telephone') self.mobile_number = user_details.get('mobile_phone') self.title = user_details.get('title') self.fax_number = user_details.get('org_unit__location__fax') super(EmailUser, self).save(*args, **kwargs)
def get_is_department_user(self, obj): if obj.email: return in_dbca_domain(obj) else: return False
def get_is_department_user(self, obj): if obj.email: return in_dbca_domain(obj) else: return False
def is_departmentUser(request): return request.user.is_authenticated() and is_model_backend(request) and in_dbca_domain(request.user)
def is_disturbance_admin(request): return request.user.is_authenticated() and is_model_backend(request) and in_dbca_domain(request.user) and (belongs_to(request.user, 'Disturbance Admin'))
def is_departmentUser(request): return request.user.is_authenticated() and is_model_backend( request) and in_dbca_domain(request.user)
def is_disturbance_admin(request): return request.user.is_authenticated() and is_model_backend( request) and in_dbca_domain(request.user) and (belongs_to( request.user, 'Disturbance Admin'))