<commit_before>"""
    Root views of api
"""

import json
import os
import markdown2
from django.http import HttpResponse

from django.db import models
from rest_framework.decorators import api_view

from seven23 import settings
from seven23.models.terms.models import TermsAndConditions

@api_view(["GET"])
def api_init(request):
    """
        Return status on client initialisation
    """
    result = {}

    # Return API Version.
    result['api_version'] = settings.API_VERSION
    result['allow_account_creation'] = settings.ALLOW_ACCOUNT_CREATION
    result['contact'] = settings.CONTACT_EMAIL

    try:
        terms = TermsAndConditions.objects.latest('date')
        result['terms_and_conditions_date'] = terms.date
        result['terms_and_conditions'] = markdown2.markdown(terms.markdown)
    except TermsAndConditions.DoesNotExist:
       result['terms_and_conditions_date'] = None
       result['terms_and_conditions'] = None


    if request.user.is_authenticated():
        result['is_authenticated'] = True
        result['id'] = request.user.id
    else:
        result['is_authenticated'] = False

    # Return json format string.
    j = json.dumps(result, separators=(',', ':'))
    return HttpResponse(j, content_type='application/json')
<commit_msg>Fix bug on API with date in Terms and Conditions not serializable<commit_after>"""
    Root views of api
"""

import json
import os
import markdown2
from django.http import HttpResponse

from django.db import models
from rest_framework.decorators import api_view

from seven23 import settings
from seven23.models.terms.models import TermsAndConditions

@api_view(["GET"])
def api_init(request):
    """
        Return status on client initialisation
    """
    result = {}

    # Return API Version.
    result['api_version'] = settings.API_VERSION
    result['allow_account_creation'] = settings.ALLOW_ACCOUNT_CREATION
    result['contact'] = settings.CONTACT_EMAIL

    try:
        terms = TermsAndConditions.objects.latest('date')
        result['terms_and_conditions_date'] = terms.date.strftime("%Y-%m-%d")
        result['terms_and_conditions'] = markdown2.markdown(terms.markdown)
    except TermsAndConditions.DoesNotExist:
       result['terms_and_conditions_date'] = None
       result['terms_and_conditions'] = None


    if request.user.is_authenticated():
        result['is_authenticated'] = True
        result['id'] = request.user.id
    else:
        result['is_authenticated'] = False

    # Return json format string.
    j = json.dumps(result, separators=(',', ':'))
    return HttpResponse(j, content_type='application/json')

{'fraction_non_alphanumeric': 0.10742857142857143, 'fraction_numerical': 0.004571428571428572, 'mean_word_length': 3.8539741219963033, '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': '7017754', 'n_tokens_mistral': 787, 'n_tokens_neox': 744, 'n_words': 173}