<commit_before>from django.contrib.auth.models import User, Group

from salesforce.salesforce import Salesforce
from social.apps.django_app.default.models import \
    DjangoStorage as SocialAuthStorage


def check_if_faculty_pending(user_id):
    with Salesforce() as sf:
        try:
            social_user = SocialAuthStorage.user.objects.filter(user_id=user_id)
            accounts_id = social_user[0].uid
            command = "SELECT OS_Accounts_ID__c FROM Lead WHERE OS_Accounts_ID__c = '{}' AND Status != 'Converted'".format(accounts_id)
            response = sf.query(command)

            try:
                record = response['records'][0]['OS_Accounts_ID__c']
                return True
            except IndexError:
                return False
        except IndexError:
            return False


def update_faculty_status(user_id):
    faculty_group, created = Group.objects.get_or_create(name="Faculty")

    with Salesforce() as sf:
        try:
            user = User.objects.get(pk=user_id)
            social_user = SocialAuthStorage.user.objects.filter(user=user)
            accounts_id = social_user[0].uid
            command = "SELECT Accounts_ID__c FROM Contact " \
                      "WHERE Faculty_Verified__c = 'Confirmed' " \
                      "AND Accounts_ID__c = '{}'".format(accounts_id)
            response = sf.query(command)

            try:
                record = response['records'][0]['Accounts_ID__c']
                if record:
                    faculty_group.user_set.add(user)
                    user.save()
                return True
            except IndexError:
                return False
        except IndexError:
            return False


def check_if_email_used(institutional_email):
    with Salesforce() as sf:
        try:
            #social_user = SocialAuthStorage.user.objects.filter(user_id=user_id)
            #accounts_id = social_user[0].uid
            command = "SELECT OS_Accounts_ID__c FROM Lead WHERE Institutional_Email__c = '{}' AND LeadSource = 'OSC Faculty' AND Status != 'Converted'".format(institutional_email)
            response = sf.query(command)

            try:
                record = response['records'][0]['OS_Accounts_ID__c']
                return True
            except IndexError:
                return False
        except IndexError:
            return False
<commit_msg>add lead source to pending_verification SF query<commit_after>from django.contrib.auth.models import User, Group

from salesforce.salesforce import Salesforce
from social.apps.django_app.default.models import \
    DjangoStorage as SocialAuthStorage


def check_if_faculty_pending(user_id):
    with Salesforce() as sf:
        try:
            social_user = SocialAuthStorage.user.objects.filter(user_id=user_id)
            accounts_id = social_user[0].uid
            command = "SELECT OS_Accounts_ID__c FROM Lead WHERE OS_Accounts_ID__c = '{}' AND Status != 'Converted' AND LeadSource = 'OSC Faculty'".format(accounts_id)
            response = sf.query(command)

            try:
                record = response['records'][0]['OS_Accounts_ID__c']
                return True
            except IndexError:
                return False
        except IndexError:
            return False


def update_faculty_status(user_id):
    faculty_group, created = Group.objects.get_or_create(name="Faculty")

    with Salesforce() as sf:
        try:
            user = User.objects.get(pk=user_id)
            social_user = SocialAuthStorage.user.objects.filter(user=user)
            accounts_id = social_user[0].uid
            command = "SELECT Accounts_ID__c FROM Contact " \
                      "WHERE Faculty_Verified__c = 'Confirmed' " \
                      "AND Accounts_ID__c = '{}'".format(accounts_id)
            response = sf.query(command)

            try:
                record = response['records'][0]['Accounts_ID__c']
                if record:
                    faculty_group.user_set.add(user)
                    user.save()
                return True
            except IndexError:
                return False
        except IndexError:
            return False


def check_if_email_used(institutional_email):
    with Salesforce() as sf:
        try:
            #social_user = SocialAuthStorage.user.objects.filter(user_id=user_id)
            #accounts_id = social_user[0].uid
            command = "SELECT OS_Accounts_ID__c FROM Lead WHERE Institutional_Email__c = '{}' AND LeadSource = 'OSC Faculty' AND Status != 'Converted'".format(institutional_email)
            response = sf.query(command)

            try:
                record = response['records'][0]['OS_Accounts_ID__c']
                return True
            except IndexError:
                return False
        except IndexError:
            return False

{'fraction_non_alphanumeric': 0.08268041237113402, 'fraction_numerical': 0.002474226804123711, 'mean_word_length': 2.0432873274780428, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7022950', 'n_tokens_mistral': 1338, 'n_tokens_neox': 1298, 'n_words': 284}