<commit_before>from django.db.models import Q
from django.contrib import messages
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.forms.models import model_to_dict
from django.utils.safestring import mark_safe
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.contrib.auth.decorators import login_required

from djspace.registration.forms import *
from djspace.core.utils import get_profile_status
from djspace.dashboard.forms import UserForm, UserProfileForm
from djspace.core.forms import UserFilesForm
from djspace.core.models import UserFiles

from djtools.utils.convert import str_to_class

import json


@login_required
def home(request):
    """
    User dashboard home
    """

    user = request.user
    try:
        instance = UserFiles.objects.get(user=user)
    except:
        instance = None

    user_files = UserFilesForm(instance=instance)

    try:
        mod = str_to_class(
            "djspace.registration.models",
            user.profile.registration_type
        )
        reg = mod.objects.get(user=user)
    except:
        reg = None
    # if the user does not have any applications, the gm2m
    # field will throw an error
    try:
        apps = user.profile.applications
    except:
        apps = None

    approved = False
    for a in apps.all():
        if a.status:
            approved = True

    messages.add_message(
        request, messages.ERROR,
        '''
        You have not uploaded required files. Please do so below.
        ''',
        extra_tags='danger'
    )

    status = get_profile_status(user)
    return render_to_response(
        "dashboard/home.html", {<commit_msg>commented out messages on dashboard for now<commit_after>from django.db.models import Q
from django.contrib import messages
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.forms.models import model_to_dict
from django.utils.safestring import mark_safe
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
from django.views.decorators.csrf import csrf_exempt
from django.http import HttpResponse, HttpResponseRedirect, Http404
from django.contrib.auth.decorators import login_required

from djspace.registration.forms import *
from djspace.core.utils import get_profile_status
from djspace.dashboard.forms import UserForm, UserProfileForm
from djspace.core.forms import UserFilesForm
from djspace.core.models import UserFiles

from djtools.utils.convert import str_to_class

import json


@login_required
def home(request):
    """
    User dashboard home
    """

    user = request.user
    try:
        instance = UserFiles.objects.get(user=user)
    except:
        instance = None

    user_files = UserFilesForm(instance=instance)

    try:
        mod = str_to_class(
            "djspace.registration.models",
            user.profile.registration_type
        )
        reg = mod.objects.get(user=user)
    except:
        reg = None
    # if the user does not have any applications, the gm2m
    # field will throw an error
    try:
        apps = user.profile.applications
    except:
        apps = None

    approved = False
    for a in apps.all():
        if a.status:
            approved = True

    '''
    messages.add_message(
        request, messages.ERROR,
        '''
        You have not uploaded required files. Please do so below.
        ''',
        extra_tags='danger'
    )
    '''

    status = get_profile_status(user)
    return render_to_response(
        "dashboard/home.html", {
{'fraction_non_alphanumeric': 0.07037037037037037, 'fraction_numerical': 0.0021164021164021165, 'mean_word_length': 2.992608236536431, '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': '89669', 'n_tokens_mistral': 1075, 'n_tokens_neox': 1045, 'n_words': 304}