##// END OF EJS Templates
Localized a minor sticker message. Refactored sticker factory
neko259 -
r1942:412bb996 default
parent child Browse files
Show More
@@ -2,12 +2,12 b' from boards.abstracts.settingsmanager im'
2 from boards.models import Attachment
2 from boards.models import Attachment
3
3
4
4
5 class AttachmentAlias:
5 class StickerFactory:
6 def get_image(self, alias):
6 def get_image(self, alias):
7 pass
7 pass
8
8
9
9
10 class SessionAttachmentAlias(AttachmentAlias):
10 class SessionStickerFactory(StickerFactory):
11 def __init__(self, session):
11 def __init__(self, session):
12 self.session = session
12 self.session = session
13
13
@@ -16,14 +16,17 b' class SessionAttachmentAlias(AttachmentA'
16 return settings_manager.get_attachment_by_alias(alias)
16 return settings_manager.get_attachment_by_alias(alias)
17
17
18
18
19 class ModelAttachmentAlias(AttachmentAlias):
19 class ModelStickerFactory(StickerFactory):
20 def get_image(self, alias):
20 def get_image(self, alias):
21 return Attachment.objects.get_by_alias(alias)
21 return Attachment.objects.get_by_alias(alias)
22
22
23
23
24 def get_image_by_alias(alias, session):
24 def get_attachment_by_alias(alias, session):
25 image = SessionAttachmentAlias(session).get_image(alias)\
25 """Gets attachment from a source (local or server/global) using an alias."""
26 or ModelAttachmentAlias().get_image(alias)
26
27 factories = [SessionStickerFactory(session), ModelStickerFactory()]
28 for factory in factories:
29 image = factory.get_image(alias)
27
30
28 if image is not None:
31 if image is not None:
29 return image
32 return image
@@ -1,4 +1,4 b''
1 from boards.abstracts.attachment_alias import AttachmentAlias
1 from boards.abstracts.sticker_factory import StickerFactory
2 from boards.models.attachment import FILE_TYPES_IMAGE, AttachmentSticker
2 from boards.models.attachment import FILE_TYPES_IMAGE, AttachmentSticker
3 from django.contrib import admin
3 from django.contrib import admin
4 from django.utils.translation import ugettext_lazy as _
4 from django.utils.translation import ugettext_lazy as _
@@ -18,7 +18,7 b' from django.core.cache import cache'
18 import boards.settings as board_settings
18 import boards.settings as board_settings
19 import neboard
19 import neboard
20 from boards import utils
20 from boards import utils
21 from boards.abstracts.attachment_alias import get_image_by_alias
21 from boards.abstracts.sticker_factory import get_attachment_by_alias
22 from boards.abstracts.settingsmanager import get_settings_manager
22 from boards.abstracts.settingsmanager import get_settings_manager
23 from boards.forms.fields import UrlFileField
23 from boards.forms.fields import UrlFileField
24 from boards.mdx_neboard import formatters
24 from boards.mdx_neboard import formatters
@@ -360,7 +360,7 b' class PostForm(NeboardForm):'
360 return url
360 return url
361
361
362 try:
362 try:
363 image = get_image_by_alias(url, self.session)
363 image = get_attachment_by_alias(url, self.session)
364 if image is not None:
364 if image is not None:
365 if 'stickers' not in self.cleaned_data:
365 if 'stickers' not in self.cleaned_data:
366 self.cleaned_data['stickers'] = []
366 self.cleaned_data['stickers'] = []
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -61,3 +61,7 b' msgstr "\xd0\x9f\xd0\xbe\xd0\xb8\xd1\x81\xd0\xba \xd0\xb4\xd1\x83\xd0\xb1\xd0\xbb\xd0\xb8\xd0\xba\xd0\xb0\xd1\x82\xd0\xbe\xd0\xb2"'
61
61
62 msgid "Add local sticker"
62 msgid "Add local sticker"
63 msgstr "Добавить локальный стикер"
63 msgstr "Добавить локальный стикер"
64
65 msgid "Input sticker name"
66 msgstr "Введите название стикера"
67
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -61,3 +61,7 b' msgstr "\xd0\x9f\xd0\xbe\xd1\x88\xd1\x83\xd0\xba \xd0\xb4\xd1\x83\xd0\xb1\xd0\xbb\xd1\x96\xd0\xba\xd0\xb0\xd1\x82\xd1\x96\xd0\xb2"'
61
61
62 msgid "Add local sticker"
62 msgid "Add local sticker"
63 msgstr "Додати локальний стікер"
63 msgstr "Додати локальний стікер"
64
65 msgid "Input sticker name"
66 msgstr "Введіть назву стікера"
67
General Comments 0
You need to be logged in to leave comments. Login now