Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-newsbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WebU
shared
django-newsbox
Commits
a9867f53
Commit
a9867f53
authored
9 years ago
by
Olivier Le Brouster
Browse files
Options
Downloads
Patches
Plain Diff
add i18n queryset and view mixin
parent
f3c31784
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
newsbox_i18n/models.py
+8
-2
8 additions, 2 deletions
newsbox_i18n/models.py
newsbox_i18n/views.py
+8
-0
8 additions, 0 deletions
newsbox_i18n/views.py
with
16 additions
and
2 deletions
newsbox_i18n/models.py
+
8
−
2
View file @
a9867f53
...
...
@@ -5,14 +5,20 @@ from django.core.urlresolvers import reverse
from
django.utils.translation
import
ugettext_lazy
as
_
,
get_language
,
activate
from
django.utils
import
six
from
django.utils.encoding
import
python_2_unicode_compatible
from
parler.managers
import
TranslatableManager
from
parler.managers
import
TranslatableManager
,
TranslatableQuerySet
from
parler.models
import
TranslatableModel
,
TranslatedFields
from
newsbox.models
import
NewsboxModelBase
,
NewsboxManager
class
NewsboxI18N
Manager
(
Translatable
Manager
,
NewsboxManager
):
class
NewsboxI18N
Queryset
(
Translatable
QuerySet
):
pass
class
NewsboxI18NManager
(
TranslatableManager
,
NewsboxManager
):
queryset_class
=
NewsboxI18NQueryset
def
newsboxi18n_mcls_processor
(
mcls
,
class_name
,
class_bases
,
class_attrs
,
base
,
newsbox_opts
):
translatedFields
=
{}
for
trans_field
in
newsbox_opts
[
'
trans_fieldnames
'
]:
...
...
This diff is collapsed.
Click to expand it.
newsbox_i18n/views.py
+
8
−
0
View file @
a9867f53
...
...
@@ -5,6 +5,14 @@ from newsbox.views import NewsboxDetailView
from
django.utils.translation
import
get_language
class
NewsboxI18NListMixin
(
object
):
def
get_queryset
(
self
):
queryset
=
super
(
NewsboxI18NListMixin
,
self
).
get_queryset
()
queryset
=
queryset
.
active_translations
()
return
queryset
class
NewsboxI18NDetailView
(
NewsboxDetailView
):
slug_field
=
"
translations__newsbox_slug
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment