Admin: Akce na synchronizaci duplicit informací v databázi
This commit is contained in:
parent
a420a6bc98
commit
e86c090ab8
1 changed files with 24 additions and 1 deletions
|
@ -8,7 +8,6 @@ from django_reverse_admin import ReverseModelAdmin
|
|||
|
||||
import seminar.models as m
|
||||
|
||||
admin.site.register(m.Osoba)
|
||||
admin.site.register(m.Skola)
|
||||
admin.site.register(m.Prijemce)
|
||||
admin.site.register(m.Rocnik)
|
||||
|
@ -16,6 +15,19 @@ admin.site.register(m.Cislo)
|
|||
admin.site.register(m.Organizator)
|
||||
admin.site.register(m.Soustredeni)
|
||||
|
||||
@admin.register(m.Osoba)
|
||||
class OsobaAdmin(admin.ModelAdmin):
|
||||
actions = ['synchronizuj_maily']
|
||||
|
||||
def synchronizuj_maily(self, request, queryset):
|
||||
for o in queryset:
|
||||
if o.user is not None:
|
||||
u = o.user
|
||||
u.email = o.email
|
||||
u.save()
|
||||
self.message_user(request, "E-maily synchronizovány.")
|
||||
synchronizuj_maily.short_description = "Synchronizuj vybraným osobám e-maily do uživatelů"
|
||||
|
||||
@admin.register(m.Problem)
|
||||
class ProblemAdmin(PolymorphicParentModelAdmin):
|
||||
base_model = m.Problem
|
||||
|
@ -93,6 +105,17 @@ class TreeNodeAdmin(PolymorphicParentModelAdmin):
|
|||
m.TextNode,
|
||||
]
|
||||
|
||||
actions = ['aktualizuj_nazvy']
|
||||
|
||||
# XXX: nejspíš je to totální DB HOG, nechcete to použít moc často.
|
||||
def aktualizuj_nazvy(self, request, queryset):
|
||||
newqs = queryset.get_real_instances()
|
||||
for tn in newqs:
|
||||
tn.aktualizuj_nazev()
|
||||
tn.save()
|
||||
self.message_user(request, "Názvy aktualizovány.")
|
||||
aktualizuj_nazvy.short_description = "Aktualizuj vybraným TreeNodům názvy"
|
||||
|
||||
@admin.register(m.RocnikNode)
|
||||
class RocnikNodeAdmin(PolymorphicChildModelAdmin):
|
||||
base_model = m.RocnikNode
|
||||
|
|
Loading…
Reference in a new issue