##// END OF EJS Templates
Don't allow modifying post's images list from admin page
Don't allow modifying post's images list from admin page

File last commit:

r1500:9178427e default
r1540:f9fa8d7e default
Show More
attachment_alias.py
27 lines | 769 B | text/x-python | PythonLexer
from boards.abstracts.settingsmanager import SessionSettingsManager
from boards.models import PostImage
class AttachmentAlias:
def get_image(alias):
pass
class SessionAttachmentAlias(AttachmentAlias):
def __init__(self, session):
self.session = session
def get_image(self, alias):
settings_manager = SessionSettingsManager(self.session)
return settings_manager.get_image_by_alias(alias)
class ModelAttachmentAlias(AttachmentAlias):
def get_image(self, alias):
return PostImage.objects.filter(alias=alias).first()
def get_image_by_alias(alias, session):
image = SessionAttachmentAlias(session).get_image(alias) or ModelAttachmentAlias().get_image(alias)
if image is not None:
return image