diff --git a/devel/TODO b/devel/TODO index 02ed08d..49b7482 100644 --- a/devel/TODO +++ b/devel/TODO @@ -23,7 +23,7 @@ Todo bis release: - einkaufsseite - alle items, sortierung nach preis/alphabet - suchfeld fixen (konrad?) - - image aspect ration checking und/oder irgendwo hinschreiben (seba) +[x] image aspect ration checking und/oder irgendwo hinschreiben (seba) - transaktionsseite schöner machen - pluginseite (einstellungen) schöner machen - history: items durch bilder ersetzen, pfand drunterschreiben wenn pfand... diff --git a/k4ever/main/admin.py b/k4ever/main/admin.py index 94d0a4c..d8ab549 100644 --- a/k4ever/main/admin.py +++ b/k4ever/main/admin.py @@ -1,7 +1,24 @@ from models import UserProfile, Plugin, PluginPermission from django.contrib import admin +from django import forms +from django.contrib.auth.models import User, Group + +class PluginAdminForm(forms.ModelForm): + """ Form made to require that the user of a plugin is in the plugin group """ + class Meta: + model = Plugin + + def clean_user(self): + user = self.cleaned_data['user'] + group = Group.objects.get(name="Plugin") + if not group in user.groups.all(): + raise forms.ValidationError("The user for a plugin has to be a member of the 'Plugin' group") + return self.cleaned_data['user'] + +class PluginAdmin(admin.ModelAdmin): + form = PluginAdminForm admin.site.register(UserProfile) -admin.site.register(Plugin) +admin.site.register(Plugin, PluginAdmin) admin.site.register(PluginPermission)