<commit_before>from corehq.apps.receiverwrapper.util import get_meta_appversion_text, get_build_version
from couchdbkit import ResourceNotFound
from corehq.apps.app_manager.models import get_app
from corehq.apps.reports import util
from corehq.apps.reports.filters.select import SelectApplicationFilter
from corehq.apps.reports.standard import ProjectReportParametersMixin, ProjectReport
from corehq.apps.reports.datatables import DataTablesHeader, DataTablesColumn, DTSortType
from corehq.apps.reports.generic import GenericTabularReport
from corehq.apps.reports.util import make_form_couch_key
from couchforms.models import XFormInstance
from django.utils.translation import ugettext_noop
from django.utils.translation import ugettext as _

class DeploymentsReport(GenericTabularReport, ProjectReport, ProjectReportParametersMixin):
    """
        Base class for all deployments reports
    """
   
    @classmethod
    def show_in_navigation(cls, domain=None, project=None, user=None):
        return not (project.commtrack_enabled or project.commconnect_enabled)


class ApplicationStatusReport(DeploymentsReport):
    name = ugettext_noop("Application Status")
    slug = "app_status"
    fields = ['corehq.apps.reports.filters.users.UserTypeFilter',
              'corehq.apps.reports.filters.select.GroupFilter',
              'corehq.apps.reports.filters.select.SelectApplicationFilter']

    @property
    def headers(self):
        return DataTablesHeader(DataTablesColumn(_("Username")),
            DataTablesColumn(_("Last Seen (UTC)"),sort_type=DTSortType.NUMERIC),
            DataTablesColumn(_("Application (Deployed Build)")))

    @property
    def rows(self):
        rows = []
        selected_app = self.request_params.get(SelectApplicationFilter.slug, '')
        UNKNOWN = _("unknown")

        for user in self.users:
            last_seen = self.table_cell(-1, _("Never"))
            app_name = None
<commit_msg>expose manage deployments reports to app editors in commtrack/connect<commit_after>from corehq.apps.receiverwrapper.util import get_meta_appversion_text, get_build_version
from couchdbkit import ResourceNotFound
from corehq.apps.app_manager.models import get_app
from corehq.apps.reports import util
from corehq.apps.reports.filters.select import SelectApplicationFilter
from corehq.apps.reports.standard import ProjectReportParametersMixin, ProjectReport
from corehq.apps.reports.datatables import DataTablesHeader, DataTablesColumn, DTSortType
from corehq.apps.reports.generic import GenericTabularReport
from corehq.apps.reports.util import make_form_couch_key
from couchforms.models import XFormInstance
from django.utils.translation import ugettext_noop
from django.utils.translation import ugettext as _


class DeploymentsReport(GenericTabularReport, ProjectReport, ProjectReportParametersMixin):
    """
        Base class for all deployments reports
    """
   
    @classmethod
    def show_in_navigation(cls, domain=None, project=None, user=None):
        # for commtrack/connect projects - only show if the user can view apps
        if project.commtrack_enabled or project.commconnect_enabled:
            return user and (user.is_superuser or user.has_permission(domain, 'edit_apps'))
        return super(DeploymentsReport, cls).show_in_navigation(domain, project, user)

class ApplicationStatusReport(DeploymentsReport):
    name = ugettext_noop("Application Status")
    slug = "app_status"
    fields = ['corehq.apps.reports.filters.users.UserTypeFilter',
              'corehq.apps.reports.filters.select.GroupFilter',
              'corehq.apps.reports.filters.select.SelectApplicationFilter']

    @property
    def headers(self):
        return DataTablesHeader(DataTablesColumn(_("Username")),
            DataTablesColumn(_("Last Seen (UTC)"),sort_type=DTSortType.NUMERIC),
            DataTablesColumn(_("Application (Deployed Build)")))

    @property
    def rows(self):
        rows = []
        selected_app = self.request_params.get(SelectApplicationFilter.slug, '')
        UNKNOWN = _("unknown")

        for user in self.users:
            last_seen = self.table_cell(-1, _("Never"))
            app_name = None

{'fraction_non_alphanumeric': 0.08363201911589008, 'fraction_numerical': 0.00047789725209080046, 'mean_word_length': 4.25219573400251, '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': '2968489', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1150, 'n_words': 256}