<commit_before>import csv
import io
import json
import uuid
from couchdbkit import ResourceNotFound
from django.contrib import messages
from django.core.cache import cache
from corehq import privileges, toggles
from corehq.apps.accounting.decorators import requires_privilege_with_fallback
from corehq.apps.app_manager.util import all_case_properties_by_domain
from corehq.apps.casegroups.dbaccessors import get_case_groups_in_domain, \
    get_number_of_case_groups_in_domain
from corehq.apps.casegroups.models import CommCareCaseGroup
from corehq.apps.hqwebapp.templatetags.hq_shared_tags import static
from corehq.apps.hqwebapp.utils import get_bulk_upload_form
from corehq.util.spreadsheets.excel import JSONReaderError, WorkbookJSONReader
from corehq.util.timezones.conversions import ServerTime
from corehq.util.timezones.utils import get_timezone_for_user
from django.utils.decorators import method_decorator
from openpyxl.utils.exceptions import InvalidFileException
from corehq.apps.data_interfaces.tasks import (
    bulk_upload_cases_to_group, bulk_archive_forms, bulk_form_management_async)
from corehq.apps.data_interfaces.forms import (
    AddCaseGroupForm, UpdateCaseGroupForm, AddCaseToGroupForm,
    AddAutomaticCaseUpdateRuleForm)
from corehq.apps.data_interfaces.models import (AutomaticUpdateRule,
    AutomaticUpdateRuleCriteria, AutomaticUpdateAction)
from corehq.apps.domain.decorators import login_and_domain_required
from corehq.apps.domain.views import BaseDomainView
from corehq.apps.hqcase.utils import get_case_by_identifier
from corehq.apps.hqwebapp.views import CRUDPaginatedViewMixin, PaginatedItemException
from corehq.apps.data_interfaces.dispatcher import (
    EditDataInterfaceDispatcher,
    require_can_edit_data,
)
from corehq.apps.style.decorators import use_typeahead, use_angular_js
from corehq.const import SERVER_DATETIME_FORMAT
from .dispatcher import require_form_management_privilege
from .interfaces import FormManagementMode, BulkFormManagementInterface
from django.db import transaction
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404, HttpResponseServerError
from django.shortcuts import render
from djangular.views.mixins import JSONResponseMixin, allow_remote_invocation
from dimagi.utils.decorators.memoized import memoized
from django.utils.translation import ugettext as _, ugettext_noop, ugettext_lazy
from soil.exceptions import TaskFailedError
from soil.util import expose_cached_download, get_download_context
from zipfile import BadZipfile


@login_and_domain_required
def default(request, domain):
    if not request.project or request.project.is_snapshot:
        raise Http404()

    return HttpResponseRedirect(default_data_view_url(request, domain))


def default_data_view_url(request, domain):
    if request.couch_user.can_view_reports():
        from corehq.apps.export.views import FormExportListView
        return reverse(FormExportListView.urlname, args=[domain])

    from corehq.apps.export.views import DeIdFormExportListView, user_can_view_deid_exports
    if user_can_view_deid_exports(domain, request.couch_user):
        return reverse(DeIdFormExportListView.urlname, args=[domain])

    raise Http404()

<commit_msg>proper default data view<commit_after>import csv
import io
import json
import uuid
from couchdbkit import ResourceNotFound
from django.contrib import messages
from django.core.cache import cache
from corehq import privileges, toggles
from corehq.apps.accounting.decorators import requires_privilege_with_fallback
from corehq.apps.app_manager.util import all_case_properties_by_domain
from corehq.apps.casegroups.dbaccessors import get_case_groups_in_domain, \
    get_number_of_case_groups_in_domain
from corehq.apps.casegroups.models import CommCareCaseGroup
from corehq.apps.hqwebapp.templatetags.hq_shared_tags import static
from corehq.apps.hqwebapp.utils import get_bulk_upload_form
from corehq.apps.users.permissions import can_view_form_exports, can_view_case_exports
from corehq.util.spreadsheets.excel import JSONReaderError, WorkbookJSONReader
from corehq.util.timezones.conversions import ServerTime
from corehq.util.timezones.utils import get_timezone_for_user
from django.utils.decorators import method_decorator
from openpyxl.utils.exceptions import InvalidFileException
from corehq.apps.data_interfaces.tasks import (
    bulk_upload_cases_to_group, bulk_archive_forms, bulk_form_management_async)
from corehq.apps.data_interfaces.forms import (
    AddCaseGroupForm, UpdateCaseGroupForm, AddCaseToGroupForm,
    AddAutomaticCaseUpdateRuleForm)
from corehq.apps.data_interfaces.models import (AutomaticUpdateRule,
    AutomaticUpdateRuleCriteria, AutomaticUpdateAction)
from corehq.apps.domain.decorators import login_and_domain_required
from corehq.apps.domain.views import BaseDomainView
from corehq.apps.hqcase.utils import get_case_by_identifier
from corehq.apps.hqwebapp.views import CRUDPaginatedViewMixin, PaginatedItemException
from corehq.apps.data_interfaces.dispatcher import (
    EditDataInterfaceDispatcher,
    require_can_edit_data,
)
from corehq.apps.style.decorators import use_typeahead, use_angular_js
from corehq.const import SERVER_DATETIME_FORMAT
from .dispatcher import require_form_management_privilege
from .interfaces import FormManagementMode, BulkFormManagementInterface
from django.db import transaction
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404, HttpResponseServerError
from django.shortcuts import render
from djangular.views.mixins import JSONResponseMixin, allow_remote_invocation
from dimagi.utils.decorators.memoized import memoized
from django.utils.translation import ugettext as _, ugettext_noop, ugettext_lazy
from soil.exceptions import TaskFailedError
from soil.util import expose_cached_download, get_download_context
from zipfile import BadZipfile


@login_and_domain_required
def default(request, domain):
    if not request.project or request.project.is_snapshot:
        raise Http404()

    return HttpResponseRedirect(default_data_view_url(request, domain))


def default_data_view_url(request, domain):
    from corehq.apps.export.views import (
        FormExportListView, CaseExportListView,
        DeIdFormExportListView, user_can_view_deid_exports
    )
    if can_view_form_exports(request.couch_user, domain):
        return reverse(FormExportListView.urlname, args=[domain])
    elif can_view_case_exports(request.couch_user, domain):
        return reverse(CaseExportListView.urlname, args=[domain])

    if user_can_view_deid_exports(domain, request.couch_user):
        return reverse(DeIdFormExportListView.urlname, args=[domain])

    raise Http404()


{'fraction_non_alphanumeric': 0.05149896111605818, 'fraction_numerical': 0.0026714158504007124, 'mean_word_length': 6.863477246207701, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4106497', 'n_tokens_mistral': 2020, 'n_tokens_neox': 1972, 'n_words': 445}