Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Django-parler translations #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions decisions/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@
from django.contrib import admin
from easy_select2 import select2_modelform

from parler.admin import TranslatableAdmin, TranslatableTabularInline

from decisions.models import Action, Content, Event, Membership, Organization, Person, Post


class PersonMembershipInline(admin.TabularInline):
class PersonMembershipInline(TranslatableTabularInline):
fields = ('organization', 'role', 'start_date', 'end_date')
raw_id_fields = ('organization',)
model = Membership
extra = 0


class OrganizationMembershipInline(admin.TabularInline):
class OrganizationMembershipInline(TranslatableTabularInline):
fields = ('person', 'role', 'start_date', 'end_date')
raw_id_fields = ('person',)
model = Membership
extra = 0


@admin.register(Person)
class PersonAdmin(admin.ModelAdmin):
ordering = ('name',)
class PersonAdmin(TranslatableAdmin):
inlines = (PersonMembershipInline,)
search_fields = ('name',)


@admin.register(Organization)
class OrganizationAdmin(admin.ModelAdmin):
ordering = ('name',)
class OrganizationAdmin(TranslatableAdmin):
inlines = (OrganizationMembershipInline,)
search_fields = ('name',)

Expand All @@ -37,25 +37,25 @@ class OrganizationAdmin(admin.ModelAdmin):


@admin.register(Event)
class EventAdmin(admin.ModelAdmin):
class EventAdmin(TranslatableAdmin):
form = EventForm
ordering = ('-start_date',)


class ContentInline(admin.TabularInline):
class ContentInline(TranslatableTabularInline):
model = Content
ordering = ('ordering',)
fields = ('type', 'hypertext')
extra = 0


@admin.register(Action)
class ActionAdmin(admin.ModelAdmin):
class ActionAdmin(TranslatableAdmin):
inlines = (ContentInline,)


@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
class PostAdmin(TranslatableAdmin):
model = Post
raw_id_fields = ('organization',)

Expand Down
3 changes: 2 additions & 1 deletion decisions/api/organization.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from rest_framework import serializers, viewsets
from parler_rest.serializers import TranslatableModelSerializer # , TranslatedFieldsField

from decisions.models import Event, OrganizationClass, Organization, Post

from .base import DataModelSerializer


class OrganizationClassSerializer(serializers.ModelSerializer):
class OrganizationClassSerializer(TranslatableModelSerializer):
class Meta:
model = OrganizationClass
fields = '__all__'
Expand Down
Loading