<commit_before>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4

from django.views.decorators.http import require_GET, require_http_methods
from django.shortcuts import get_object_or_404
from django.db import transaction

from rapidsms.webui.utils import *
from apps.reporters.models import *
from apps.reporters.utils import *


def message(req, msg, link=None):
    return render_to_response(req,
        "message.html", {
            "message": msg,
            "link": link
    })


@require_GET
def index(req):
    return render_to_response(req,
        "reporters/index.html", {
        "reporters": paginated(req, Reporter.objects.all()),
        "groups": paginated(req, ReporterGroup.objects.flatten()),
    })


def check_reporter_form(req):
    
    # verify that all non-blank
    # fields were provided
    missing = [
        field.verbose_name
        for field in Reporter._meta.fields
        if req.POST.get(field.name, "") == ""
           and field.blank == False]
    
    # TODO: add other validation checks,
    # or integrate proper django forms
    return {
        "missing": missing }


def update_reporter(req, rep):
    
    # as default, we will delete all of the connections
    # and groups from this reporter. the loops will drop
    # objects that we SHOULD NOT DELETE from these lists
    del_conns = list(rep.connections.values_list("pk", flat=True))
    del_grps = list(rep.groups.values_list("pk", flat=True))<commit_msg>updated reporters app with new pagination prefixes<commit_after>#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4

from django.views.decorators.http import require_GET, require_http_methods
from django.shortcuts import get_object_or_404
from django.db import transaction

from rapidsms.webui.utils import *
from apps.reporters.models import *
from apps.reporters.utils import *


def message(req, msg, link=None):
    return render_to_response(req,
        "message.html", {
            "message": msg,
            "link": link
    })


@require_GET
def index(req):
    return render_to_response(req,
        "reporters/index.html", {
        "reporters": paginated(req, Reporter.objects.all(), prefix="rep"),
        "groups":    paginated(req, ReporterGroup.objects.flatten(), prefix="grp"),
    })


def check_reporter_form(req):
    
    # verify that all non-blank
    # fields were provided
    missing = [
        field.verbose_name
        for field in Reporter._meta.fields
        if req.POST.get(field.name, "") == ""
           and field.blank == False]
    
    # TODO: add other validation checks,
    # or integrate proper django forms
    return {
        "missing": missing }


def update_reporter(req, rep):
    
    # as default, we will delete all of the connections
    # and groups from this reporter. the loops will drop
    # objects that we SHOULD NOT DELETE from these lists
    del_conns = list(rep.connections.values_list("pk", flat=True))
    del_grps = list(rep.groups.values_list("pk", flat=True))
{'fraction_non_alphanumeric': 0.10501672240802676, 'fraction_numerical': 0.004013377926421404, 'mean_word_length': 3.041891891891892, 'pattern_counts': {'":': 10, '<': 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': '2803578', 'n_tokens_mistral': 924, 'n_tokens_neox': 888, 'n_words': 251}