Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion image_assets/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from bitfield import BitField
from bitfield.forms import BitFieldCheckboxSelectMultiple
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline

Expand All @@ -6,7 +8,9 @@

@admin.register(models.get_asset_type_model())
class AssetTypeAdmin(admin.ModelAdmin):
pass
formfield_overrides = {
BitField: {'widget': BitFieldCheckboxSelectMultiple},
}


class AssetsInline(GenericTabularInline):
Expand Down
68 changes: 35 additions & 33 deletions image_assets/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-02 09:43+0000\n"
"POT-Creation-Date: 2020-04-06 13:24+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -24,8 +24,8 @@ msgstr ""
msgid "Image assets"
msgstr "Ассеты"

#: image_assets/forms.py:13 image_assets/models.py:71
#: image_assets/models.py:161 image_assets/models.py:178
#: image_assets/forms.py:13 image_assets/models.py:70
#: image_assets/models.py:155 image_assets/models.py:191
msgid "Asset Type"
msgstr "Тип ассета"

Expand All @@ -39,54 +39,56 @@ msgstr "Отсутствуют обязательные типы ассетов:
msgid "Duplicate active assets for types: %s"
msgstr "Дублируются активные ассеты следующих типов: %s"

#: image_assets/models.py:46
#: image_assets/models.py:45
msgid "Slug"
msgstr "Слаг"

#: image_assets/models.py:48
msgid "Image Format"
#: image_assets/models.py:46
#, fuzzy
#| msgid "Image Format"
msgid "Formats"
msgstr "Формат изображения"

#: image_assets/models.py:50
#: image_assets/models.py:49
msgid "Min Width"
msgstr "Минимальная ширина"

#: image_assets/models.py:52
#: image_assets/models.py:51
msgid "Min Height"
msgstr "Минимальная высота"

#: image_assets/models.py:54
#: image_assets/models.py:53
msgid "Aspect"
msgstr "Аспект"

#: image_assets/models.py:56
#: image_assets/models.py:55
msgid "Aspect accuracy"
msgstr "Погрешность аспекта"

#: image_assets/models.py:58
#: image_assets/models.py:57
msgid "Max file size"
msgstr "Максимальный размер файла"

#: image_assets/models.py:61
#: image_assets/models.py:60
msgid "Required for"
msgstr "Обязателен для"

#: image_assets/models.py:65
#: image_assets/models.py:64
msgid "Allowed for"
msgstr "Допустим для"

#: image_assets/models.py:72
#: image_assets/models.py:71
msgid "Asset Types"
msgstr "Типы ассетов"

#: image_assets/models.py:91
#: image_assets/models.py:97
#, python-format
msgid "File size must be not greater than %s"
msgstr "Размер файла должен быть не более %s"

#: image_assets/models.py:113
#: image_assets/models.py:106
#, python-format
msgid "Image format must be %s"
msgid "Image format must be one of %s"
msgstr "Формат изображения должен быть %s"

#: image_assets/models.py:117
Expand All @@ -99,44 +101,44 @@ msgstr "Ширина изображения должна быть не мень
msgid "Image height must be not less than %s"
msgstr "Высота изображения должна быть не меньше %s"

#: image_assets/models.py:128
#: image_assets/models.py:133
#, python-format
msgid "Image aspect must be %s"
msgstr "Аспект изображения должен быть %s"

#: image_assets/models.py:132
#: image_assets/models.py:137
#, python-format
msgid "Image aspect must be %(aspect)s ± %(accuracy)s"
msgstr "Аспект изображения должен быть %(aspect)s ± %(accuracy)s"

#: image_assets/models.py:149
msgid "Asset"
msgstr "Ассет"

#: image_assets/models.py:150
msgid "Assets"
msgstr "Ассеты"

#: image_assets/models.py:159 image_assets/models.py:176
#: image_assets/models.py:153 image_assets/models.py:189
msgid "Image"
msgstr "Изображение"

#: image_assets/models.py:162
#: image_assets/models.py:156
msgid "Active"
msgstr "Активен"

#: image_assets/models.py:165 image_assets/models.py:181
#: image_assets/models.py:159 image_assets/models.py:194
msgid "Content Type"
msgstr "Тип объекта"

#: image_assets/models.py:166 image_assets/models.py:182
#: image_assets/models.py:160 image_assets/models.py:195
msgid "Object ID"
msgstr "ID объекта"

#: image_assets/models.py:187
#: image_assets/models.py:165
msgid "Asset"
msgstr "Ассет"

#: image_assets/models.py:166
msgid "Assets"
msgstr "Ассеты"

#: image_assets/models.py:200
msgid "Deleted Asset"
msgstr "Удаленный ассет"

#: image_assets/models.py:188
#: image_assets/models.py:201
msgid "Deleted Assets"
msgstr "Удаленные ассеты"
2 changes: 1 addition & 1 deletion image_assets/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Migration(migrations.Migration):
name='Asset',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='', validators=[image_assets.models.AssetType.validate_asset])),
('image', models.ImageField(upload_to='', validators=[])),
('active', models.BooleanField(default=True)),
('object_id', models.IntegerField()),
('asset_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=defaults.ASSET_TYPE_MODEL)),
Expand Down
3 changes: 1 addition & 2 deletions image_assets/migrations/0002_models_localization.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='asset',
name='image',
field=models.ImageField(upload_to='', validators=[
image_assets.models.AssetType.validate_asset],
field=models.ImageField(upload_to='', validators=[],
verbose_name='Image'),
),
migrations.AlterField(
Expand Down
25 changes: 25 additions & 0 deletions image_assets/migrations/0005_assettype_formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.0.5 on 2020-04-06 12:10

import bitfield.models
from django.db import migrations

from image_assets import defaults


class Migration(migrations.Migration):
dependencies = [
('image_assets', '0004_auto_20200402_0942'),
]

operations = []
if defaults.ASSET_TYPE_MODEL == 'image_assets.AssetType':
operations.extend([
migrations.AddField(
model_name='assettype',
name='formats',
field=bitfield.models.BitField(
(('jpeg', 'JPEG'), ('png', 'PNG')),
default=0),
),

])
27 changes: 27 additions & 0 deletions image_assets/migrations/0006_migrate_formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.0.5 on 2020-04-06 13:02

from django.db import migrations
from image_assets import defaults


# noinspection PyUnusedLocal
def migrate_formats(apps, schema_editor):
app_label, model_name = defaults.ASSET_TYPE_MODEL.split('.')
# noinspection PyPep8Naming
AssetType = apps.get_model(app_label, model_name)

for at in AssetType.objects.all():
flag = getattr(AssetType.formats, at.format)
at.formats = flag
at.save()


class Migration(migrations.Migration):

dependencies = [
('image_assets', '0005_assettype_formats'),
]

operations = [
migrations.RunPython(migrate_formats, migrations.RunPython.noop),
]
33 changes: 33 additions & 0 deletions image_assets/migrations/0007_auto_20200406_1313.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.0.5 on 2020-04-06 13:13

import bitfield.models
from django.db import migrations, models
import image_assets.validators
from image_assets import defaults


class Migration(migrations.Migration):
dependencies = [
('image_assets', '0006_migrate_formats'),
]
operations = []
if defaults.ASSET_TYPE_MODEL == 'image_assets.AssetType':
operations.extend([
migrations.RemoveField(
model_name='assettype',
name='format',
),
migrations.AlterField(
model_name='asset',
name='image',
field=models.ImageField(upload_to='', validators=[
image_assets.validators.AssetValidator()],
verbose_name='Image'),
),
migrations.AlterField(
model_name='assettype',
name='formats',
field=bitfield.models.BitField(
(('jpeg', 'JPEG'), ('png', 'PNG')), default=0),
),
])
Loading