equal
deleted
inserted
replaced
1 from django.conf import settings |
1 from django.conf import settings |
2 from django.contrib.contenttypes.models import ContentType |
2 #from django.contrib.contenttypes.models import ContentType |
3 from django.db import models |
3 from django.db import models |
4 from django.db.models import signals |
4 from django.db.models import signals |
5 from django.db.models.base import ModelBase |
5 from django.db.models.base import ModelBase |
6 from django.utils.functional import curry |
6 from django.utils.functional import curry |
7 |
7 |
23 |
23 |
24 It caches the content type of the translated model for faster lookup later |
24 It caches the content type of the translated model for faster lookup later |
25 on. |
25 on. |
26 """ |
26 """ |
27 def __init__(self, *args, **kwargs): |
27 def __init__(self, *args, **kwargs): |
28 # self.translation_model = None |
28 # self.translation_model = None |
29 self.model_ct = None |
29 #self.model_ct = None |
30 self.localized_fieldnames = list() |
30 self.localized_fieldnames = list() |
31 |
31 |
32 #def get_localized_fieldnames(model): |
32 #def get_localized_fieldnames(model): |
33 |
33 |
34 def add_localized_fields(model): |
34 def add_localized_fields(model): |
121 |
121 |
122 # Validate (which might be a no-op) |
122 # Validate (which might be a no-op) |
123 #validate(translation_opts, model) |
123 #validate(translation_opts, model) |
124 |
124 |
125 # Store the translation class associated to the model |
125 # Store the translation class associated to the model |
126 self._registry[model] = translation_opts |
126 self._registry[model] = translation_opts |
127 |
127 |
128 # Get the content type of the original model and store it on the |
128 # Get the content type of the original model and store it on the |
129 # translation options for faster lookup later on. |
129 # translation options for faster lookup later on. |
130 translation_opts.model_ct = ContentType.objects.get_for_model(model) |
130 #translation_opts.model_ct = ContentType.objects.get_for_model(model) |
131 |
131 |
132 # Add the localized fields to the model and store the names of these |
132 # Add the localized fields to the model and store the names of these |
133 # fields in the model's translation options for faster lookup later |
133 # fields in the model's translation options for faster lookup later |
134 # on. |
134 # on. |
135 translation_opts.localized_fieldnames = add_localized_fields(model) |
135 translation_opts.localized_fieldnames = add_localized_fields(model) |