Example #1
0
	def clean_email(self):
		cleaned_data = self.cleaned_data
		if(not 'email' in cleaned_data or not cleaned_data['email']):
			raise forms.ValidationError(MSG_FIELD_REQUIRED)
		email = cleaned_data['email']
		if has_mhluser_with_email(email):
			raise forms.ValidationError(_("This email has been registered. Please choose "
				"another email or invite him to your practice."))
		return email
Example #2
0
def contactInfo(request):
    fields = ('email', 'email_confirmed', 'mobile_phone', 'mobile_confirmed',
              'pager', 'pager_confirmed')

    email = "email" in request.GET and request.GET["email"] or None
    mobile_phone = "mobile_phone" in request.GET and request.GET[
        "mobile_phone"] or None
    pager = "pager" in request.GET and request.GET["pager"] or None

    retDict = dict()
    if ('Provider' in request.session['MHL_Users']):
        user = Provider.objects.get(id=request.user.id)
        retDict = model_to_dict(user, fields=fields)

    elif ('OfficeStaff' in request.session['MHL_Users']):
        staff = OfficeStaff.objects.get(user=request.user.id)
        user = staff.user
        retDict = model_to_dict(user, fields=fields)
        retDict.update(model_to_dict(staff, fields=fields))

    elif ('Broker' in request.session['MHL_Users']):
        broker = Broker.objects.get(user=request.user.id)
        user = broker.user
        retDict = model_to_dict(user, fields=fields)
        retDict.update(model_to_dict(broker, fields=fields))

    else:
        raise Exception('User is of unknown type')

    extends = {
        'email_send_enable':
        checkSendCodeEnable("1", request.user.id, email),
        'mobile_phone_send_enable':
        checkSendCodeEnable("2", request.user.id, mobile_phone),
        'pager_send_enable':
        checkSendCodeEnable("3", request.user.id, pager)
    }
    retDict.update(extends)

    if email:
        retDict["email_unique"] = not has_mhluser_with_email(
            email, request.user.id)
    else:
        retDict["email_unique"] = True

    if mobile_phone:
        retDict["mobile_phone_unique"] = not has_mhluser_with_mobile_phone(
            mobile_phone, request.user.id)
    else:
        retDict["mobile_phone_unique"] = True

    return HttpResponse(content=json.dumps({'user': retDict}),
                        mimetype='application/json')
Example #3
0
def contactInfo(request):
	fields = ('email', 'email_confirmed', 
				'mobile_phone', 'mobile_confirmed', 
				'pager', 'pager_confirmed')

	email = "email" in request.GET and request.GET["email"] or None
	mobile_phone = "mobile_phone" in request.GET and request.GET["mobile_phone"] or None
	pager = "pager" in request.GET and request.GET["pager"] or None

	retDict = dict()
	if ('Provider' in request.session['MHL_Users']):
		user = Provider.objects.get(id=request.user.id)
		retDict = model_to_dict(user, fields = fields)

	elif ('OfficeStaff' in request.session['MHL_Users']):
		staff = OfficeStaff.objects.get(user=request.user.id)
		user = staff.user
		retDict = model_to_dict(user, fields = fields)
		retDict.update(model_to_dict(staff, fields = fields))

	elif ('Broker' in request.session['MHL_Users']):
		broker = Broker.objects.get(user=request.user.id)
		user = broker.user
		retDict = model_to_dict(user, fields = fields)
		retDict.update(model_to_dict(broker, fields = fields))

	else:
		raise Exception('User is of unknown type')

	extends = {
		'email_send_enable': checkSendCodeEnable("1", request.user.id, email),
		'mobile_phone_send_enable': checkSendCodeEnable("2", request.user.id, mobile_phone),
		'pager_send_enable': checkSendCodeEnable("3", request.user.id, pager)
	}
	retDict.update(extends)

	if email:
		retDict["email_unique"] = not has_mhluser_with_email(email, request.user.id)
	else:
		retDict["email_unique"] = True

	if mobile_phone:
		retDict["mobile_phone_unique"] = not has_mhluser_with_mobile_phone(mobile_phone, request.user.id)
	else:
		retDict["mobile_phone_unique"] = True

	return HttpResponse(content=json.dumps({'user': retDict}), mimetype='application/json')
Example #4
0
def unique_check(request):
	"""
		Validate user's email/mobile_phone's uniqueness.
		If the email is unique, the email_unique's value is True, or it's False.
		If the mobile_phone is unique, the mobile_phone_unique's value is True, or it's False.
	"""
	result = dict()
	if (request.POST):
		email = request.POST["email"]
		mobile_phone = request.POST["mobile_phone"]

		result = {
				'email_unique': not has_mhluser_with_email(email, request.user.id),
				'mobile_phone_unique': not has_mhluser_with_mobile_phone(
										mobile_phone, request.user.id)
			}

	return HttpResponse(json.dumps(result), mimetype='application/json')
Example #5
0
def unique_check(request):
    """
		Validate user's email/mobile_phone's uniqueness.
		If the email is unique, the email_unique's value is True, or it's False.
		If the mobile_phone is unique, the mobile_phone_unique's value is True, or it's False.
	"""
    result = dict()
    if (request.POST):
        email = request.POST["email"]
        mobile_phone = request.POST["mobile_phone"]

        result = {
            'email_unique':
            not has_mhluser_with_email(email, request.user.id),
            'mobile_phone_unique':
            not has_mhluser_with_mobile_phone(mobile_phone, request.user.id)
        }

    return HttpResponse(json.dumps(result), mimetype='application/json')