# Path: minent/utils.py
# def signature(text):
#     """
#     This helper method normalizes text and takes the SHA1 hash of it,
#     returning the base64 encoded result. The normalization method includes
#     the removal of punctuation and white space as well as making the case
#     completely lowercase. These signatures will help us discover textual
#     similarities between questions.
#     """
#     text = normalize(text).encode('utf-8')
#     return base64.b64encode(hashlib.sha1(text).digest())


from fugato.models import *
from fugato.exceptions import *
from users.serializers import *
from minent.utils import signature
from rest_framework import serializers
            'url', 'text', 'author', 'page_url',
            'details', 'details_rendered', 'tags'
        )
        extra_kwargs = {
            'url': {'view_name': 'api:question-detail',},
            'details_rendered': {'read_only': True},
        }

    ######################################################################
    ## Serializer Methods
    ######################################################################

    def get_page_url(self, obj):
        """
        Returns the models' detail absolute url.
        """
        return obj.get_absolute_url()

    #####################################################################
    ## Override create and update for API
    ######################################################################

    def create(self, validated_data):
        """
        Override the create method to deal with duplicate questions and
        other API-specific errors that can happen on Question creation.
        """

        ## Check to make sure there is no duplicate
        qsig = signature(validated_data['text'])

# Path: minent/utils.py
# def signature(text):
#     """
#     This helper method normalizes text and takes the SHA1 hash of it,
#     returning the base64 encoded result. The normalization method includes
#     the removal of punctuation and white space as well as making the case
#     completely lowercase. These signatures will help us discover textual
#     similarities between questions.
#     """
#     text = normalize(text).encode('utf-8')
#     return base64.b64encode(hashlib.sha1(text).digest())


# Path: fugato/serializers.py
from fugato.models import *
from fugato.exceptions import *
from users.serializers import *
from minent.utils import signature
from rest_framework import serializers

            'url', 'text', 'author', 'page_url',
            'details', 'details_rendered', 'tags'
        )
        extra_kwargs = {
            'url': {'view_name': 'api:question-detail',},
            'details_rendered': {'read_only': True},
        }

    ######################################################################
    ## Serializer Methods
    ######################################################################

    def get_page_url(self, obj):
        """
        Returns the models' detail absolute url.
        """
        return obj.get_absolute_url()

    #####################################################################
    ## Override create and update for API
    ######################################################################

    def create(self, validated_data):
        """
        Override the create method to deal with duplicate questions and
        other API-specific errors that can happen on Question creation.
        """

        ## Check to make sure there is no duplicate
        qsig = signature(validated_data['text'])

        if Question.objects.filter(signature=qsig).exists():