Commit 508eab39 authored by okhin's avatar okhin

Adding the translations to the admin

parent 1681bea2
from django.contrib import admin from django.contrib import admin
from modeltranslation.admin import TranslationAdmin, TranslationTabularInline
from picampaign.campaign.models import Campaign, CampaignContact, Argumentary from picampaign.campaign.models import Campaign, CampaignContact, Argumentary
from picampaign.organization.models import Organization from picampaign.organization.models import Organization
from picampaign.importer.models import Importer from picampaign.importer.models import Importer
...@@ -10,8 +12,11 @@ class InlineContact(admin.TabularInline): ...@@ -10,8 +12,11 @@ class InlineContact(admin.TabularInline):
class InlineImporter(admin.TabularInline): class InlineImporter(admin.TabularInline):
model = Importer model = Importer
class CampaignAdmin(admin.ModelAdmin): class InlineTranslationArgumentary(TranslationTabularInline):
inlines = [InlineContact, InlineImporter] model = Argumentary
class CampaignAdmin(TranslationAdmin):
inlines = [InlineTranslationArgumentary, InlineContact, InlineImporter]
def get_queryset(self, request): def get_queryset(self, request):
qs = super(CampaignAdmin, self).get_queryset(request) qs = super(CampaignAdmin, self).get_queryset(request)
...@@ -37,7 +42,7 @@ class CampaignContactAdmin(admin.ModelAdmin): ...@@ -37,7 +42,7 @@ class CampaignContactAdmin(admin.ModelAdmin):
return qs.filter(campaign__organization__in=user_orgs) return qs.filter(campaign__organization__in=user_orgs)
class ArgumentaryAdmin(admin.ModelAdmin): class ArgumentaryAdmin(TranslationAdmin):
def get_queryset(self, request): def get_queryset(self, request):
qs = super(ArgumentaryAdmin, self).get_queryset(request) qs = super(ArgumentaryAdmin, self).get_queryset(request)
if request.user.is_superuser: if request.user.is_superuser:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment