|
@ -1,4 +1,5 @@ |
|
|
from django.contrib import admin |
|
|
from django.contrib import admin |
|
|
|
|
|
from django.contrib.auth.models import Permission |
|
|
|
|
|
|
|
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter |
|
|
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter |
|
|
from reversion.admin import VersionAdmin |
|
|
from reversion.admin import VersionAdmin |
|
@ -18,7 +19,7 @@ admin.site.register(m.Soustredeni) |
|
|
|
|
|
|
|
|
@admin.register(m.Osoba) |
|
|
@admin.register(m.Osoba) |
|
|
class OsobaAdmin(admin.ModelAdmin): |
|
|
class OsobaAdmin(admin.ModelAdmin): |
|
|
actions = ['synchronizuj_maily'] |
|
|
actions = ['synchronizuj_maily', 'udelej_orgem'] |
|
|
|
|
|
|
|
|
def synchronizuj_maily(self, request, queryset): |
|
|
def synchronizuj_maily(self, request, queryset): |
|
|
for o in queryset: |
|
|
for o in queryset: |
|
@ -29,6 +30,20 @@ class OsobaAdmin(admin.ModelAdmin): |
|
|
self.message_user(request, "E-maily synchronizovány.") |
|
|
self.message_user(request, "E-maily synchronizovány.") |
|
|
synchronizuj_maily.short_description = "Synchronizuj vybraným osobám e-maily do uživatelů" |
|
|
synchronizuj_maily.short_description = "Synchronizuj vybraným osobám e-maily do uživatelů" |
|
|
|
|
|
|
|
|
|
|
|
def udelej_orgem(self,request,queryset): |
|
|
|
|
|
org_perm = Permission.objects.filter(codename__exact='org').first() |
|
|
|
|
|
print(queryset) |
|
|
|
|
|
for o in queryset: |
|
|
|
|
|
user = o.user |
|
|
|
|
|
user.user_permissions.add(org_perm) |
|
|
|
|
|
user.is_staff = True |
|
|
|
|
|
user.save() |
|
|
|
|
|
org = m.Organizator.objects.create(osoba=o) |
|
|
|
|
|
org.save() |
|
|
|
|
|
udelej_orgem.short_description = "Udělej vybraných osob organizátory" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@admin.register(m.Problem) |
|
|
@admin.register(m.Problem) |
|
|
class ProblemAdmin(PolymorphicParentModelAdmin): |
|
|
class ProblemAdmin(PolymorphicParentModelAdmin): |
|
|
base_model = m.Problem |
|
|
base_model = m.Problem |
|
|