Commit 89c9928b authored by okhin's avatar okhin 🚴

Campaign admin is done

parent c721b074
from django.contrib import admin from django.contrib import admin
from modeltranslation.admin import TranslationAdmin, TranslationTabularInline from modeltranslation.admin import TranslationAdmin, TranslationStackedInline
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
...@@ -13,11 +13,14 @@ class InlineContact(admin.TabularInline): ...@@ -13,11 +13,14 @@ class InlineContact(admin.TabularInline):
class InlineImporter(admin.TabularInline): class InlineImporter(admin.TabularInline):
model = Importer model = Importer
class InlineTranslationArgumentary(TranslationTabularInline): class InlineTranslationArgumentary(TranslationStackedInline):
model = Argumentary model = Argumentary
class CampaignAdmin(TranslationAdmin): class CampaignAdmin(TranslationAdmin):
inlines = [InlineTranslationArgumentary, InlineContact, InlineImporter] inlines = [InlineTranslationArgumentary, InlineContact, InlineImporter]
list_display = ('title', 'organization', 'start_date', 'end_date', 'phone_filter',)
list_filter = ('organization', 'start_date', 'end_date',)
list_select_related = ('organization',)
def get_queryset(self, request): def get_queryset(self, request):
qs = super(CampaignAdmin, self).get_queryset(request) qs = super(CampaignAdmin, self).get_queryset(request)
...@@ -35,6 +38,10 @@ class CampaignAdmin(TranslationAdmin): ...@@ -35,6 +38,10 @@ class CampaignAdmin(TranslationAdmin):
request, request,
**kwargs) **kwargs)
class CampaignContactAdmin(admin.ModelAdmin): class CampaignContactAdmin(admin.ModelAdmin):
list_display = ('contact', 'campaign', 'weight')
list_select_related = ('contact', 'campaign',)
list_filter = ('campaign',)
def get_queryset(self, request): def get_queryset(self, request):
qs = super(CampaignContactAdmin, self).get_queryset(request) qs = super(CampaignContactAdmin, self).get_queryset(request)
if request.user.is_superuser: if request.user.is_superuser:
...@@ -44,6 +51,10 @@ class CampaignContactAdmin(admin.ModelAdmin): ...@@ -44,6 +51,10 @@ class CampaignContactAdmin(admin.ModelAdmin):
class ArgumentaryAdmin(TranslationAdmin): class ArgumentaryAdmin(TranslationAdmin):
list_display = ('title', 'campaign',)
list_select_related = ('campaign',)
list_filter = ('campaign',)
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