added check for admin plugin user group membership

This commit is contained in:
seba 2011-10-08 18:11:45 +02:00
parent 0bd4f3b4e0
commit 252010544d
2 changed files with 19 additions and 2 deletions

View File

@ -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...

View File

@ -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)