def _deserialize(self): """Look up the User objects from stored session ids and store them""" raw_data = self.request.session[self._session_key()] # If this is an older session, discard it and create a new default one if self._is_old_session(raw_data): self._create() raw_data = self.request.session[self._session_key()] self.participants = [ Participant( signup_session=self, id=p['id'], user=User.get_cached(id=p['user_id']) if p['user_id'] is not None else None, first_name=p['first_name'], last_name=p['last_name'], email=p['email'], phone=p['phone'], birth_date=datetime.strptime(p['birth_date'], "%Y-%m-%d").date() if p['birth_date'] is not None else None, state=p['state'], use_parent_contact_info=p['use_parent_contact_info'], use_signee_contact_info=p['use_signee_contact_info'], discount_code=p['discount_code'], signee_relation=p['signee_relation'], answers=p['answers'], extras=p['extras'], ) for p in raw_data['participants'] ] self.comment = raw_data['comment'] self.extras = raw_data['extras'] self.extras_defaults_set = raw_data['extras_defaults_set'] self.participate_together = raw_data['participate_together']
def get_user(self, user_id): try: # Important note: This method should *not* return a cached user # object on authentication - just for subsequent requests (so that # we avoid an extra DB user query for each request). Clearing the # user cache when `authenticate` is called should be sufficient to # achieve this. return User.get_cached( id=user_id, include_expired=True, ) except User.DoesNotExist: return None
def _deserialize(self): """Look up the User objects from stored session ids and store them""" raw_data = self.request.session[self._session_key()] # If this is an older session, discard it and create a new default one if self._is_old_session(raw_data): self._create() raw_data = self.request.session[self._session_key()] self.participants = [ Participant( signup_session=self, user=User.get_cached(id=p['id']), state=p['state'], use_guardian_contact_info=p['use_guardian_contact_info'], discount_code=p['discount_code'], ) for p in raw_data['participants'] ] self.comment = raw_data['comment'] self.participate_together = raw_data['participate_together']