def _validate_one_email(request, cleaned_data, email, errors): """validate one email.""" if cleaned_data[email]: user = player_mgr.get_user_by_email(cleaned_data[email].lower()) if user == None or user == request.user: errors[email] = ErrorList(["Invalid email. Please input only one valid email."]) del cleaned_data[email]
def _validate_one_email(request, cleaned_data, email, errors): """validate one email.""" if cleaned_data[email]: user = player_mgr.get_user_by_email(cleaned_data[email].lower()) if user == None or user == request.user: errors[email] = ErrorList( ["Invalid email. Please input only one valid email."]) del cleaned_data[email]
def clean_social_email(self): """Check if this social_email is valid.""" email = self.cleaned_data['social_email'].strip().lower() if email: user = player_mgr.get_user_by_email(email) if user == None: raise forms.ValidationError('Can not find a registered user with such email.') elif user.username == self.username: raise forms.ValidationError('Can not use your own email.') return email
def clean_social_email(self): """Check if this social_email is valid.""" email = self.cleaned_data['social_email'].strip().lower() if email: user = player_mgr.get_user_by_email(email) if user == None: raise forms.ValidationError( 'Can not find a registered user with such email.') elif user.username == self.username: raise forms.ValidationError('Can not use your own email.') return email
def _process_post(log, outfile, output, p): """process the post content.""" partner = None if "referrer_email" in log.post_content: partner = _get_post_content_value(log.post_content, "referrer_email") if "social_email" in log.post_content: partner = _get_post_content_value(log.post_content, "social_email") if partner: user = player_mgr.get_user_by_email(partner) if user and user != p.user: partner_p = user.get_profile() if partner_p.team: output += _output(",%s,%s,%s" % ( user, partner_p.team.group, _get_profile_room(partner_p)), outfile) return output
def _process_post(log, outfile, output, p): """process the post content.""" partner = None if "referrer_email" in log.post_content: partner = _get_post_content_value(log.post_content, "referrer_email") if "social_email" in log.post_content: partner = _get_post_content_value(log.post_content, "social_email") if partner: user = player_mgr.get_user_by_email(partner) if user and user != p.user: partner_p = user.profile if partner_p.team: output += _output( ",%s,%s,%s" % (user, partner_p.team.group, _get_profile_room(partner_p)), outfile) return output
def _check_attend_code(user, form): """Check the confirmation code in AJAX.""" social_email = None code = None message = None is_bonus = False try: code = ConfirmationCode.objects.get( code=form.cleaned_data["response"].lower()) # CAM 11/08/12 this assumes that ConfirmationCodes are only for events. if code.action.event.event_date > datetime.datetime.today(): message = "The Event has not occurred, Please wait till after the event date to submit." elif code.action in user.action_set.filter( actionmember__award_date__isnull=False): message = "You have already redeemed a code for this event." elif not code.is_active: message = "This code has already been used." elif code.action.social_bonus: if form.cleaned_data["social_email"]: if form.cleaned_data["social_email"] != "Email": ref_user = player_mgr.get_user_by_email( form.cleaned_data["social_email"].lower()) if ref_user == None or ref_user == user: message = "Invalid email. Please input only one valid email." social_email = "true" else: message = "Please enter one Kukui Cup email or clear the email to submit" social_email = "true" except ConfirmationCode.DoesNotExist: try: code = BonusPoint.objects.get( code=form.cleaned_data['response'].lower()) is_bonus = True if not code.is_active: message = "This code has already been used." except BonusPoint.DoesNotExist: message = "This code is not valid." except KeyError: message = "Please input code." return message, social_email, code, is_bonus
def _check_attend_code(user, form): """Check the confirmation code in AJAX.""" social_email = None code = None message = None is_bonus = False try: code = ConfirmationCode.objects.get(code=form.cleaned_data["response"].lower()) # CAM 11/08/12 this assumes that ConfirmationCodes are only for events. if code.action.event.event_date > datetime.datetime.today(): message = "The Event has not occurred, Please wait till after the event date to submit." elif code.action in user.action_set.filter(actionmember__award_date__isnull=False): message = "You have already redeemed a code for this event/excursion." elif not code.is_active: message = "This code has already been used." elif code.action.social_bonus: if form.cleaned_data["social_email"]: if form.cleaned_data["social_email"] != "Email": ref_user = player_mgr.get_user_by_email( form.cleaned_data["social_email"].lower()) if ref_user == None or ref_user == user: message = "Invalid email. Please input only one valid email." social_email = "true" else: message = "Please enter one Kukui Cup email or clear the email to submit" social_email = "true" except ConfirmationCode.DoesNotExist: try: code = BonusPoint.objects.get(code=form.cleaned_data['response'].lower()) is_bonus = True if not code.is_active: message = "This code has already been used." except BonusPoint.DoesNotExist: message = "This code is not valid." except KeyError: message = "Please input code." return message, social_email, code, is_bonus