Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support for hvad and placeholers

  • Loading branch information...
commit 47b9df6bc0622baeb070f22667c97a0b30ef524a 1 parent 6ba4ae8
Patrick Lauber digi604 authored
7 cms/admin/placeholderadmin.py
View
@@ -9,15 +9,12 @@
from cms.utils.permissions import has_plugin_permission
from cms.plugins.utils import has_reached_plugin_limit
from copy import deepcopy
-from django.conf import settings
from django.contrib.admin import ModelAdmin
-from django.http import (HttpResponse, Http404, HttpResponseBadRequest,
- HttpResponseForbidden)
+from django.http import HttpResponse, Http404, HttpResponseBadRequest, HttpResponseForbidden
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
from django.template.defaultfilters import force_escape, escapejs
from django.utils.translation import ugettext as _
-from cms.templatetags.cms_admin import admin_static_url
class PlaceholderAdmin(ModelAdmin):
@@ -100,6 +97,8 @@ def formfield_for_dbfield(self, db_field, **kwargs):
return super(PlaceholderAdmin, self).formfield_for_dbfield(db_field, **kwargs)
def placeholder_plugin_filter(self, request, queryset):
+ if 'language' in request.GET:
+ queryset = queryset.filter(language=request.GET['language'])
return queryset
def _get_placeholder_fields(self, form):
1  cms/test_utils/cli.py
View
@@ -99,6 +99,7 @@ def configure(db_url, **extra):
'south',
'reversion',
'sekizai',
+ 'hvad',
],
LANGUAGE_CODE="en",
LANGUAGES=(
15 cms/test_utils/project/placeholderapp/admin.py
View
@@ -1,7 +1,8 @@
from cms.admin.placeholderadmin import PlaceholderAdmin
-from cms.test_utils.project.placeholderapp.models import (Example1, Example2,
- Example3, Example4, Example5)
+from cms.test_utils.project.placeholderapp.models import (Example1, Example2,
+ Example3, Example4, Example5, MultilingualExample1)
from django.contrib import admin
+from hvad.admin import TranslatableAdmin
class MixinAdmin(admin.ModelAdmin):
@@ -20,6 +21,7 @@ def formfield_for_dbfield(self, db_field, **kwargs):
class Example1Admin(PlaceholderAdmin, MixinAdmin):
pass
+
class Example2Admin(PlaceholderAdmin):
fieldsets = (
('Placeholder + more fields', {
@@ -32,6 +34,7 @@ class Example2Admin(PlaceholderAdmin):
}),
)
+
class Example3Admin(PlaceholderAdmin):
fieldsets = (
('Only chars', {
@@ -48,6 +51,7 @@ class Example3Admin(PlaceholderAdmin):
}),
)
+
class Example4Admin(PlaceholderAdmin):
fieldsets = (
('Only chars', {
@@ -64,6 +68,7 @@ class Example4Admin(PlaceholderAdmin):
}),
)
+
class Example5Admin(PlaceholderAdmin):
fieldsets = (
('Only chars', {
@@ -80,8 +85,14 @@ class Example5Admin(PlaceholderAdmin):
}),
)
+
+class MultilingualAdmin(TranslatableAdmin, PlaceholderAdmin):
+ pass
+
+
admin.site.register(Example1, Example1Admin)
admin.site.register(Example2, Example2Admin)
admin.site.register(Example3, Example3Admin)
admin.site.register(Example4, Example4Admin)
admin.site.register(Example5, Example5Admin)
+admin.site.register(MultilingualExample1, MultilingualAdmin)
17 cms/test_utils/project/placeholderapp/models.py
View
@@ -1,5 +1,7 @@
from django.db import models
from cms.models.fields import PlaceholderField
+from hvad.models import TranslatableModel, TranslatedFields
+
class Example1(models.Model):
char_1 = models.CharField(u'char_1', max_length=255)
@@ -8,6 +10,7 @@ class Example1(models.Model):
char_4 = models.CharField(u'char_4', max_length=255)
placeholder = PlaceholderField('placeholder')
+
class Example2(models.Model):
char_1 = models.CharField(u'char_1', max_length=255)
char_2 = models.CharField(u'char_2', max_length=255)
@@ -15,6 +18,7 @@ class Example2(models.Model):
char_4 = models.CharField(u'char_4', max_length=255)
placeholder = PlaceholderField('placeholder')
+
class Example3(models.Model):
char_1 = models.CharField(u'char_1', max_length=255)
char_2 = models.CharField(u'char_2', max_length=255)
@@ -22,6 +26,7 @@ class Example3(models.Model):
char_4 = models.CharField(u'char_4', max_length=255)
placeholder = PlaceholderField('placeholder')
+
class Example4(models.Model):
char_1 = models.CharField(u'char_1', max_length=255)
char_2 = models.CharField(u'char_2', max_length=255)
@@ -29,6 +34,7 @@ class Example4(models.Model):
char_4 = models.CharField(u'char_4', max_length=255)
placeholder = PlaceholderField('placeholder')
+
class Example5(models.Model):
char_1 = models.CharField(u'char_1', max_length=255)
char_2 = models.CharField(u'char_2', max_length=255)
@@ -36,3 +42,14 @@ class Example5(models.Model):
char_4 = models.CharField(u'char_4', max_length=255)
placeholder_1 = PlaceholderField('placeholder_1', related_name='p1')
placeholder_2 = PlaceholderField('placeholder_2', related_name='p2')
+
+
+class MultilingualExample1(TranslatableModel):
+ translations = TranslatedFields(
+ char_1=models.CharField(u'char_1', max_length=255),
+ char_2=models.CharField(u'char_2', max_length=255),
+ )
+ placeholder_1 = PlaceholderField('placeholder_1')
+
+ def __unicode__(self):
+ return self.char_1
1  test_requirements/requirements_base.txt
View
@@ -10,3 +10,4 @@ django-sekizai>=0.7
argparse
dj-database-url
transifex-client
+-e git+git://github.com/KristianOellegaard/django-hvad.git#egg=hvad
Please sign in to comment.
Something went wrong with that request. Please try again.