<commit_before>from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User

from metabotnik.models import DropBoxInfo, Project, File, Task

# Define an inline admin descriptor for Employee model
# which acts a bit like a singleton
class DropBoxInfoInline(admin.StackedInline):
    model = DropBoxInfo
    can_delete = False
    verbose_name_plural = 'DropBoxInfos'

# Define a new User admin
class UserAdmin(UserAdmin):
    inlines = (DropBoxInfoInline, )

# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)

class FileInline(admin.StackedInline):
    model = File

class ProjectAdmin(admin.ModelAdmin):
    list_display = ('show', 'status', 'user_full_name', 'created')
    list_filter = ('status',)
#    inlines = (FileInline, )
    
admin.site.register(Project, ProjectAdmin)

class FileAdmin(admin.ModelAdmin):
    list_display = ('project', 'filename', 'pretty_size', 'width', 'height')
admin.site.register(File, FileAdmin)<commit_msg>Add admin action to make users active and mail them<commit_after>from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core.mail import send_mail
from django.conf import settings

from metabotnik.models import DropBoxInfo, Project, File, Task

# Define an inline admin descriptor for Employee model
# which acts a bit like a singleton
class DropBoxInfoInline(admin.StackedInline):
    model = DropBoxInfo
    can_delete = False
    verbose_name_plural = 'DropBoxInfos'

# Define a new User admin
class UserAdmin(UserAdmin):
    inlines = (DropBoxInfoInline, )
    actions = ['make_active'] 

    def make_active(self, request, queryset): 
        for user in queryset:
            user.is_active = True
            send_mail('Hooray! Your Metabotnik login has been activated', 
                      'Welcome %s,\nYou can now start making some gigantic zoomable images.\nHave fun at https://metabotnik.com/\nIf you have any questions or comments feel free to mail us at <EMAIL>' % user.get_full_name(), 
                      '<EMAIL>', 
                      [address for name, address in settings.ADMINS]+[user.email], 
                      fail_silently=True)

# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)

class FileInline(admin.StackedInline):
    model = File

class ProjectAdmin(admin.ModelAdmin):
    list_display = ('show', 'status', 'user_full_name', 'created')
    list_filter = ('status',)
#    inlines = (FileInline, )
    
admin.site.register(Project, ProjectAdmin)

class FileAdmin(admin.ModelAdmin):
    list_display = ('project', 'filename', 'pretty_size', 'width', 'height')
admin.site.register(File, FileAdmin)
{'fraction_non_alphanumeric': 0.09821428571428571, 'fraction_numerical': 0.0, 'mean_word_length': 4.028725314183124, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '6165801', 'n_tokens_mistral': 815, 'n_tokens_neox': 806, 'n_words': 236}