mirror of
https://github.com/SectorLabs/django-localized-fields.git
synced 2025-04-25 03:32:55 +03:00
added comments and deleted extra code
This commit is contained in:
parent
5b93c5ec8f
commit
0f4c74a9b2
@ -16,12 +16,6 @@ from ..forms import LocalizedFileFieldForm
|
||||
|
||||
|
||||
class LocalizedFieldFile(FieldFile):
|
||||
def __init__(self, instance, field, name):
|
||||
super(FieldFile, self).__init__(None, name)
|
||||
self.instance = instance
|
||||
self.field = field
|
||||
self.storage = field.storage
|
||||
self._committed = True
|
||||
|
||||
def save(self, name, content, lang, save=True):
|
||||
name = self.field.generate_filename(self.instance, name, lang)
|
||||
@ -96,7 +90,7 @@ class LocalizedFileField(LocalizedField):
|
||||
super().__init__(verbose_name, name, **kwargs)
|
||||
|
||||
def deconstruct(self):
|
||||
name, path, args, kwargs = super(LocalizedFileField, self).deconstruct()
|
||||
name, path, args, kwargs = super().deconstruct()
|
||||
kwargs['upload_to'] = self.upload_to
|
||||
if self.storage is not default_storage:
|
||||
kwargs['storage'] = self.storage
|
||||
|
@ -137,16 +137,19 @@ class LocalizedStingValue(LocalizedValue):
|
||||
|
||||
|
||||
class LocalizedFileValue(LocalizedValue):
|
||||
def __getattr__(self, name: str):
|
||||
"""Proxies access to attributes to attributes of LocalizedFile"""
|
||||
|
||||
def __getattr__(self, name):
|
||||
value = self.get(translation.get_language())
|
||||
if hasattr(value, name):
|
||||
return getattr(value, name)
|
||||
raise AttributeError("'{}' object has no attribute '{}'".
|
||||
format(self.__class__.__name__, name))
|
||||
|
||||
def __str__(self):
|
||||
def __str__(self) -> str:
|
||||
"""Returns string representation of value"""
|
||||
return str(super().__str__())
|
||||
|
||||
def localized(self):
|
||||
"""Returns value for current language"""
|
||||
return self.get(translation.get_language())
|
||||
|
Loading…
x
Reference in New Issue
Block a user