<commit_before>import requests
import simplejson as json
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.shortcuts import (
    HttpResponse,
    HttpResponseRedirect,
    render_to_response,
)
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
from django.views.generic import TemplateView
from facebook.forms import BlackListWordsForm
from facebook.models import BlackListedWords, FacebookUser
from pyfb import Pyfb
from django.conf import settings


def facebook_login(request):
    # Gets the auth redirect url with code provided from facebook.
    facebook = Pyfb(
        settings.CLIENT_ID,
        permissions=settings.FACEBOOK_SCOPE
    )
    auth_code_url = facebook.get_auth_code_url(
        redirect_uri=settings.REDIRECT_URL
    )
    return HttpResponseRedirect(auth_code_url)


def facebook_login_success(request):
    code = request.GET.get('code')
    facebook = Pyfb(settings.CLIENT_ID)
    access_token = facebook.get_access_token(
        settings.CLIENT_APP_SECRET,
        code,
        redirect_uri=settings.REDIRECT_URL
    )
    me = facebook.get_myself()

    try:
        fb_user = FacebookUser.objects.get(email_address=me.email)
        fb_user.access_token = access_token
        fb_user.save()
        user = fb_user.user
    except FacebookUser.DoesNotExist:
        user = User.objects.create(
            username=me.email,
            first_name=me.first_name,
            last_name=me.last_name,
            email=me.email
        )
        user.set_password(me.email)
        user.save()
        fb_user = FacebookUser.objects.create(
            first_name = me.first_name,
            last_name = me.last_name,
            access_token = access_token,
            email_address = me.email,
            username=me.email,
            user=user
        )

    user = authenticate(
        username=me.email,
        password=me.email
    )
    # log the user in
    login(request, user)
    return HttpResponseRedirect(reverse('blacklist_words'))


class Facebook(TemplateView):
    feed_url = 'https://graph.facebook.com/me/feed'
    delete_url = 'https://graph.facebook.com/v2.3/{}'
    feed = None
    blacklist_words = [
        'nambara',
        'lol',
        'patta',
        'pathetic',
        'explanation',
        'Cherly',
        'khemanbhai',
        'enticing',
        'Lovely',
        'Yup',
        'capturing'
    ]

    def __init__(self):
        self.blacklist_comments = []<commit_msg>Removed unused blacklist words<commit_after>import requests
import simplejson as json
from django.contrib.auth import authenticate, login
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.shortcuts import (
    HttpResponse,
    HttpResponseRedirect,
    render_to_response,
)
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
from django.views.generic import TemplateView
from facebook.forms import BlackListWordsForm
from facebook.models import BlackListedWords, FacebookUser
from pyfb import Pyfb
from django.conf import settings


def facebook_login(request):
    # Gets the auth redirect url with code provided from facebook.
    facebook = Pyfb(
        settings.CLIENT_ID,
        permissions=settings.FACEBOOK_SCOPE
    )
    auth_code_url = facebook.get_auth_code_url(
        redirect_uri=settings.REDIRECT_URL
    )
    return HttpResponseRedirect(auth_code_url)


def facebook_login_success(request):
    code = request.GET.get('code')
    facebook = Pyfb(settings.CLIENT_ID)
    access_token = facebook.get_access_token(
        settings.CLIENT_APP_SECRET,
        code,
        redirect_uri=settings.REDIRECT_URL
    )
    me = facebook.get_myself()

    try:
        fb_user = FacebookUser.objects.get(email_address=me.email)
        fb_user.access_token = access_token
        fb_user.save()
        user = fb_user.user
    except FacebookUser.DoesNotExist:
        user = User.objects.create(
            username=me.email,
            first_name=me.first_name,
            last_name=me.last_name,
            email=me.email
        )
        user.set_password(<PASSWORD>)
        user.save()
        fb_user = FacebookUser.objects.create(
            first_name = me.first_name,
            last_name = me.last_name,
            access_token = access_token,
            email_address = me.email,
            username=me.email,
            user=user
        )

    user = authenticate(
        username=me.email,
        password=<PASSWORD>
    )
    # log the user in
    login(request, user)
    return HttpResponseRedirect(reverse('blacklist_words'))


class Facebook(TemplateView):
    feed_url = 'https://graph.facebook.com/me/feed'
    delete_url = 'https://graph.facebook.com/v2.3/{}'
    feed = None

    def __init__(self):
        self.blacklist_comments = []
{'fraction_non_alphanumeric': 0.0814595660749507, 'fraction_numerical': 0.0007889546351084812, 'mean_word_length': 2.7204695524578137, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3345992', 'n_tokens_mistral': 1517, 'n_tokens_neox': 1471, 'n_words': 305}