def hacker_state(self): if self.checked_in: return 'checkedin' if self.confirmed: return "confirmed" if not Settings.can_confirm(self.waitlist): return "late" if self.withdraw: return "withdraw" if self.waitlist: return "waitlist" if self.admitted: return "admitted" if self.declined: return "declined" if hasattr(self, 'application'): return "submitted" if not Settings.registration_is_open(): return "late" return "incomplete"
def hacker_state(self): # If the user submitted an application but didn't pay (i.e. asked for a refund or something) if Settings.get().require_payment and not self.payed and hasattr( self, 'application'): return 'unpaid' if self.checked_in: return 'checkedin' if self.confirmed: return "confirmed" if not Settings.can_confirm(self.waitlist): return "late" if self.withdraw: return "withdraw" if self.waitlist: return "waitlist" if self.admitted: return "admitted" if self.declined: return "declined" if hasattr(self, 'application'): return "submitted" if not Settings.registration_is_open(): return "late" return "incomplete"
def create_or_update(**kwargs): # Creates or updates a Social instance. Also creates User if email does not exist user = kwargs.pop('user') request = kwargs.pop('request', None) first_name = kwargs.pop('first_name') last_name = kwargs.pop('last_name') social_id = kwargs.pop('social_id') name = f'{first_name} {last_name}' user_created = False social_created = False temp_email = False email = kwargs.pop('email') if not email or email is None: email = Social.unique_email() temp_email = True social = Social.objects.filter(social_id=social_id) if social.exists(): user = social.first().profile.user # If the social email is not temporary and the user is not verified if not temp_email and not user.profile.is_verified: # update the user email and verify them user.email = email user.save() profile = user.profile profile.verified = True profile.save() else: try: if user is None: user = User.objects.get(email=email) except User.DoesNotExist: # Only create users if registration is open if not Settings.registration_is_open(): if request is not None: messages.add_message(request, messages.INFO, 'Período de registro fechado!') return None, user_created, social_created, request user = User( first_name=first_name, last_name=last_name, username=Social.unique_username(name), email=email ) user.save() user_created = True if not temp_email: profile = user.profile profile.verified = True profile.save() # New user created if Settings.default_hacker(): from hacker.models import Hacker Hacker(profile=user.profile).save() if Settings.default_staff(): from staff.models import Staff Staff(profile=user.profile).save() profile = user.profile try: social, social_created = Social.objects.update_or_create( profile=profile, social_id=social_id, provider=kwargs['provider'], defaults=kwargs ) except IntegrityError: messages.add_message(request, messages.ERROR, f"Parece que alguém já tentou se inscrever com esse perfil do {kwargs['provider']}") return None, user_created, social_created, request return social, user_created, social_created, request
def create_or_update(**kwargs): # Creates or updates a Social instance. Also creates User if email does not exist user = kwargs.pop('user') request = kwargs.pop('request', None) first_name = kwargs.pop('first_name') last_name = kwargs.pop('last_name') social_id = kwargs.pop('social_id') name = f'{first_name} {last_name}' user_created = False social_created = False temp_email = False email = kwargs.pop('email') if not email or email is None: email = Social.unique_email() temp_email = True social = Social.objects.filter(social_id=social_id) if social.exists(): user = social.first().profile.user # If the social email is not temporary and the user is not verified if not temp_email and not user.profile.is_verified: # update the user email and verify them user.email = email user.save() profile = user.profile profile.verified = True profile.save() else: try: if user is None: user = User.objects.get(email=email) except User.DoesNotExist: # Only create users if registration is open if not Settings.registration_is_open(): if request is not None: messages.add_message(request, messages.INFO, 'Período de registro fechado!') return None, user_created, social_created, request user = User(first_name=first_name, last_name=last_name, username=Social.unique_username(name), email=email) user.save() user_created = True if not temp_email: profile = user.profile profile.verified = True profile.save() # New user created if Settings.default_hacker(): from hacker.models import Hacker Hacker(profile=user.profile).save() if Settings.default_staff(): from staff.models import Staff Staff(profile=user.profile).save() profile = user.profile try: social, social_created = Social.objects.update_or_create( profile=profile, social_id=social_id, provider=kwargs['provider'], defaults=kwargs) except IntegrityError: messages.add_message( request, messages.ERROR, f"Parece que alguém já tentou se inscrever com esse perfil do {kwargs['provider']}" ) return None, user_created, social_created, request return social, user_created, social_created, request