2013-10-02 16:02:08 +00:00
|
|
|
from . import models
|
|
|
|
|
|
|
|
from selectable.forms import AutoCompleteSelectWidget,AutoCompleteSelectField
|
|
|
|
from selectable.base import ModelLookup
|
|
|
|
from selectable.registry import registry
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.contrib.admin import ModelAdmin
|
2013-10-10 06:41:50 +00:00
|
|
|
from django.contrib.auth.models import User, Group
|
2013-10-02 16:02:08 +00:00
|
|
|
|
|
|
|
class UserLookup(ModelLookup):
|
|
|
|
model = User
|
|
|
|
search_fields = ('username__icontains',)
|
|
|
|
|
|
|
|
registry.register(UserLookup)
|
|
|
|
|
|
|
|
class LibraryAdminForm(forms.ModelForm):
|
|
|
|
user = AutoCompleteSelectField(
|
|
|
|
UserLookup,
|
|
|
|
widget=AutoCompleteSelectWidget(UserLookup),
|
|
|
|
required=True,
|
|
|
|
)
|
|
|
|
class Meta(object):
|
|
|
|
model = models.Library
|
2013-10-10 06:41:50 +00:00
|
|
|
widgets= {'group':forms.HiddenInput}
|
|
|
|
exclude = ('group', )
|
|
|
|
|
|
|
|
|
2013-10-02 16:02:08 +00:00
|
|
|
class LibraryAdmin(ModelAdmin):
|
|
|
|
list_display = ('user', )
|
|
|
|
form = LibraryAdminForm
|
|
|
|
search_fields = ['user__username']
|
|
|
|
|
2013-10-08 19:37:22 +00:00
|
|
|
class BlockAdmin(ModelAdmin):
|
|
|
|
list_display = ('library', 'lower', 'upper',)
|
|
|
|
search_fields = ('library__user__username', 'lower', 'upper',)
|
2013-10-02 16:02:08 +00:00
|
|
|
|
2013-10-10 06:41:50 +00:00
|
|
|
class CardPatternAdmin(ModelAdmin):
|
|
|
|
list_display = ('library', 'pattern', 'checksum',)
|
2013-10-11 02:31:07 +00:00
|
|
|
search_fields = ('library__user__username', )
|