# Path: src/accounts/models.py
# class AuthToken(models.Model):
#     """
#     Store auth tokens returned by the moderation backend service (Slack)
#     """
# 
#     service_name = models.TextField()
#     service_entity_auth_name = models.TextField()
#     service_entity_auth_id = models.TextField()
#     service_auth_token = models.TextField()
#     username = models.CharField(max_length=50)


from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.views.generic import ListView
from .models import AuthToken


class AuthListView(ListView):
    """
    Show Slack connect button with required data
    """
    model = AuthToken
    template_name = 'auth.html'


def social_complete(*args, **kwargs):
    """
    """
    data = kwargs.get('response')
    service_name = 'slack'
    channel = data['incoming_webhook']['channel']
    channel_id = data['incoming_webhook']['channel_id']
    access_token = data['access_token']

# Path: src/accounts/models.py
# class AuthToken(models.Model):
#     """
#     Store auth tokens returned by the moderation backend service (Slack)
#     """
# 
#     service_name = models.TextField()
#     service_entity_auth_name = models.TextField()
#     service_entity_auth_id = models.TextField()
#     service_auth_token = models.TextField()
#     username = models.CharField(max_length=50)


# Path: src/accounts/views.py
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.views.generic import ListView
from .models import AuthToken



class AuthListView(ListView):
    """
    Show Slack connect button with required data
    """
    model = AuthToken
    template_name = 'auth.html'


def social_complete(*args, **kwargs):
    """
    """
    data = kwargs.get('response')
    service_name = 'slack'
    channel = data['incoming_webhook']['channel']
    channel_id = data['incoming_webhook']['channel_id']
    access_token = data['access_token']

    entry = AuthToken.objects.filter(service_name=service_name,