Exemple #1
0
def clean_username(form_object, current_holder=None):
    # Only verify username if other fields passed their verification
    if not form_object.errors:
        status_id = None
        kennitala = None

        if "status" in form_object.cleaned_data:
            status_id = form_object.cleaned_data["status"]

            # If we are running this from the admin, the cleaned value is the
            # model instance itself, not only the id.
            if type(status_id) is UserStatus:
                status_id = status_id.id

        if "kennitala" in form_object.cleaned_data:
            kennitala = form_object.cleaned_data["kennitala"]

        validate_username(form_object.cleaned_data["username"], current_holder=current_holder)