<commit_before>"""
reviewview.py

Contains administrative views for working with reviews.
"""
from admin_helpers import *

from flask import flash
from flask.ext.admin.actions import action
from flask.ext.admin.contrib.sqla import ModelView
from wtforms import IntegerField, validators

import remedy.rad.reviewservice
from remedy.rad.models import Review


class ReviewView(AdminAuthMixin, ModelView):
    """
    An administrative view for working with resource reviews.
    """
    # Disable model creation
    can_create = False

    column_select_related_list = (Review.resource, Review.user)

    column_default_sort = 'date_created'

    column_list = ('rating', 'resource.name', 'user.username', 'visible', 'date_created')

    column_labels = {
        'rating': 'Rating', 
        'resource.name': 'Resource',
        'user.username': 'User',
        'visible': 'Visible', 
        'date_created': 'Date Created'
    }

    column_searchable_list = ('text',)

    column_filters = ('visible','rating',)

    form_excluded_columns = ('date_created','is_old_review','old_reviews',
        'new_review_id','new_review')

    def scaffold_form(self):
        """
        Sets up the review form to ensure that the rating field
        behaves on a 1-5 scale.<commit_msg>resolving ambiguous date_created column<commit_after>"""
reviewview.py

Contains administrative views for working with reviews.
"""
from admin_helpers import *

from flask import flash
from flask.ext.admin.actions import action
from flask.ext.admin.contrib.sqla import ModelView
from wtforms import IntegerField, validators

import remedy.rad.reviewservice
from remedy.rad.models import Review


class ReviewView(AdminAuthMixin, ModelView):
    """
    An administrative view for working with resource reviews.
    """
    # Disable model creation
    can_create = False

    column_select_related_list = (Review.resource, Review.user)

    column_default_sort = (Review.date_created, True)

    column_sortable_list = ('rating', 'visible', ('date_created', Review.date_created))

    column_list = ('rating', 'resource.name', 'user.username', 'visible', 'date_created')

    column_labels = {
        'rating': 'Rating', 
        'resource.name': 'Resource',
        'user.username': 'User',
        'visible': 'Visible', 
        'date_created': 'Date Created'
    }

    column_searchable_list = ('text',)

    column_filters = ('visible','rating',)

    form_excluded_columns = ('date_created','is_old_review','old_reviews',
        'new_review_id','new_review')

    def scaffold_form(self):
        """
        Sets up the review form to ensure that the rating field
        behaves on a 1-5 scale.
{'fraction_non_alphanumeric': 0.11007462686567164, 'fraction_numerical': 0.0014925373134328358, 'mean_word_length': 3.654513888888889, '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': '6179611', 'n_tokens_mistral': 786, 'n_tokens_neox': 743, 'n_words': 206}