<commit_before>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.forms.models import ModelChoiceField

from bluebottle.members.models import Member
from bluebottle.tasks.models import TaskMember, TaskFile, Task, Skill
from bluebottle.clients import properties

from bluebottle.utils.admin import export_as_csv_action

# Bulk actions for Task
def mark_as_open(modeladmin, request, queryset):
    queryset.update(status='open')
mark_as_open.short_description = _("Mark selected Tasks as Open")

def mark_as_in_progress(modeladmin, request, queryset):
    queryset.update(status='in progress')
mark_as_in_progress.short_description = _("Mark selected Tasks as In Progress")

def mark_as_closed(modeladmin, request, queryset):
    queryset.update(status='closed')
mark_as_closed.short_description = _("Mark selected Tasks as Closed")

def mark_as_realized(modeladmin, request, queryset):
    queryset.update(status='realized')
mark_as_realized.short_description = _("Mark selected Tasks as Realized")

#Bulk actions for Task Member

def mark_as_applied(modeladmin, request, queryset):
    queryset.update(status='applied')
mark_as_applied.short_description = _("Mark selected Task Members as Applied")

def mark_as_accepted(modeladmin, request, queryset):
    queryset.update(status='accepted')
mark_as_accepted.short_description = _("Mark selected Task Members as Accepted")

def mark_as_rejected(modeladmin, request, queryset):
    queryset.update(status='rejected')
mark_as_rejected.short_description = _("Mark selected Task Members as Rejected")

def mark_as_stopped(modeladmin, request, queryset):
    queryset.update(status='stopped')
mark_as_stopped.short_description = _("Mark selected Task Members as Stopped")

def mark_as_tm_realized(modeladmin, request, queryset):
    queryset.update(status='realized')
mark_as_tm_realized.short_description = _("Mark selected Task Members as Realized")


class TaskMemberAdminInline(admin.StackedInline):
    model = TaskMember
    extra = 0
    raw_id_fields = ('member',)
    readonly_fields = ('created',)
    fields = readonly_fields + ('member', 'status', 'motivation',
                                'time_spent', 'externals')


class TaskFileAdminInline(admin.StackedInline):
    model = TaskFile

    raw_id_fields = ('author',)
    readonly_fields = ('created',)
    fields = readonly_fields + ('author', 'file')
    extra = 0


class TaskAdmin(admin.ModelAdmin):
    date_hierarchy = 'created'

    inlines = (TaskMemberAdminInline, TaskFileAdminInline,)

    raw_id_fields = ('author', 'project')
    list_filter = ('status',)
    list_display = ('title', 'project', 'status', 'deadline')

    readonly_fields = ('date_status_change',)

    search_fields = (
        'title', 'description',
        'author__first_name', 'author__last_name'
    )
    export_fields = (
        ('title', 'title'),
        ('project', 'project'),
        ('status', 'status'),
        ('deadline', 'deadline'),
        ('skill', 'skill'),
        ('people_needed', 'people needed'),
        ('time_needed', 'time needed'),
        ('author', 'author'),
        ('author__remote_id', 'remote id')
    )

    actions = [mark_as_open, mark_as_in_progress, mark_as_closed,
               mark_as_realized, export_as_csv_action(fields=export_fields)]

    fields = ('title', 'description', 'skill', 'time_needed', 'status',
              'date_status_change', 'people_needed', 'project', 'author',
              'type', 'deadline')<commit_msg>Add type filter to task admin<commit_after>from django.contrib import admin
from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse
from django.forms import ModelForm
from django.forms.models import ModelChoiceField

from bluebottle.members.models import Member
from bluebottle.tasks.models import TaskMember, TaskFile, Task, Skill
from bluebottle.clients import properties

from bluebottle.utils.admin import export_as_csv_action

# Bulk actions for Task
def mark_as_open(modeladmin, request, queryset):
    queryset.update(status='open')
mark_as_open.short_description = _("Mark selected Tasks as Open")

def mark_as_in_progress(modeladmin, request, queryset):
    queryset.update(status='in progress')
mark_as_in_progress.short_description = _("Mark selected Tasks as In Progress")

def mark_as_closed(modeladmin, request, queryset):
    queryset.update(status='closed')
mark_as_closed.short_description = _("Mark selected Tasks as Closed")

def mark_as_realized(modeladmin, request, queryset):
    queryset.update(status='realized')
mark_as_realized.short_description = _("Mark selected Tasks as Realized")

#Bulk actions for Task Member

def mark_as_applied(modeladmin, request, queryset):
    queryset.update(status='applied')
mark_as_applied.short_description = _("Mark selected Task Members as Applied")

def mark_as_accepted(modeladmin, request, queryset):
    queryset.update(status='accepted')
mark_as_accepted.short_description = _("Mark selected Task Members as Accepted")

def mark_as_rejected(modeladmin, request, queryset):
    queryset.update(status='rejected')
mark_as_rejected.short_description = _("Mark selected Task Members as Rejected")

def mark_as_stopped(modeladmin, request, queryset):
    queryset.update(status='stopped')
mark_as_stopped.short_description = _("Mark selected Task Members as Stopped")

def mark_as_tm_realized(modeladmin, request, queryset):
    queryset.update(status='realized')
mark_as_tm_realized.short_description = _("Mark selected Task Members as Realized")


class TaskMemberAdminInline(admin.StackedInline):
    model = TaskMember
    extra = 0
    raw_id_fields = ('member',)
    readonly_fields = ('created',)
    fields = readonly_fields + ('member', 'status', 'motivation',
                                'time_spent', 'externals')


class TaskFileAdminInline(admin.StackedInline):
    model = TaskFile

    raw_id_fields = ('author',)
    readonly_fields = ('created',)
    fields = readonly_fields + ('author', 'file')
    extra = 0


class TaskAdmin(admin.ModelAdmin):
    date_hierarchy = 'created'

    inlines = (TaskMemberAdminInline, TaskFileAdminInline,)

    raw_id_fields = ('author', 'project')
    list_filter = ('status', 'type')
    list_display = ('title', 'project', 'status', 'deadline')

    readonly_fields = ('date_status_change',)

    search_fields = (
        'title', 'description',
        'author__first_name', 'author__last_name'
    )
    export_fields = (
        ('title', 'title'),
        ('project', 'project'),
        ('status', 'status'),
        ('deadline', 'deadline'),
        ('skill', 'skill'),
        ('people_needed', 'people needed'),
        ('time_needed', 'time needed'),
        ('author', 'author'),
        ('author__remote_id', 'remote id')
    )

    actions = [mark_as_open, mark_as_in_progress, mark_as_closed,
               mark_as_realized, export_as_csv_action(fields=export_fields)]

    fields = ('title', 'description', 'skill', 'time_needed', 'status',
              'date_status_change', 'people_needed', 'project', 'author',
              'type', 'deadline')
{'fraction_non_alphanumeric': 0.11582584657912923, 'fraction_numerical': 0.0005528680027643401, 'mean_word_length': 4.675294117647059, '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': '740156', 'n_tokens_mistral': 2188, 'n_tokens_neox': 2155, 'n_words': 505}