Skip to content

Commit 7c81541

Browse files
committed
cleaned migrations
1 parent 57fa640 commit 7c81541

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

Diff for: home/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ class ManifestSettingsAdmin(ModelAdmin):
1818

1919
@admin.register(SVGToPNGMap)
2020
class SVGToPNGMapAdmin(admin.ModelAdmin):
21-
list_display = ('id', 'svg_path', 'color', 'png_image_file')
21+
list_display = ('id', 'svg_path', 'fill_color', 'stroke_color', 'png_image_file')
2222

2323

Diff for: home/migrations/0013_merge_20210920_1202.py renamed to home/migrations/0013_merge_20211004_0940.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# Generated by Django 3.1.13 on 2021-09-20 12:02
1+
# Generated by Django 3.1.13 on 2021-10-04 09:40
22

33
from django.db import migrations
44

55

66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('home', '0012_sitesettings_opt_in_to_google_web_light'),
109
('home', '0011_v1tov2objectmap_extra'),
10+
('home', '0012_sitesettings_opt_in_to_google_web_light'),
1111
]
1212

1313
operations = [

Diff for: home/migrations/0014_merge_20211001_1117.py

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Generated by Django 3.1.13 on 2021-09-22 12:00
1+
# Generated by Django 3.1.13 on 2021-10-04 09:41
22

33
from django.db import migrations, models
44

55

66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('home', '0012_sitesettings_opt_in_to_google_web_light'),
9+
('home', '0013_merge_20211004_0940'),
1010
]
1111

1212
operations = [
@@ -15,11 +15,12 @@ class Migration(migrations.Migration):
1515
fields=[
1616
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
1717
('svg_path', models.TextField()),
18-
('color', models.TextField()),
18+
('fill_color', models.TextField(null=True)),
19+
('stroke_color', models.TextField(null=True)),
1920
('png_image_file', models.ImageField(upload_to='svg-to-png-maps/')),
2021
],
2122
options={
22-
'unique_together': {('svg_path', 'color')},
23+
'unique_together': {('svg_path', 'fill_color', 'stroke_color')},
2324
},
2425
),
2526
]

Diff for: home/models.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -880,21 +880,22 @@ def create_map(cls, content_object, v1_object_id, extra=None):
880880

881881
class SVGToPNGMap(models.Model):
882882
svg_path = models.TextField()
883-
color = models.TextField()
883+
fill_color = models.TextField(null=True)
884+
stroke_color = models.TextField(null=True)
884885
png_image_file = models.ImageField(upload_to='svg-to-png-maps/')
885886

886887
@classmethod
887-
def get_png_image(cls, svg_path, color):
888+
def get_png_image(cls, svg_path, fill_color, stroke_color=None):
888889
try:
889-
obj = cls.objects.get(svg_path=svg_path, color=color)
890+
obj = cls.objects.get(svg_path=svg_path, fill_color=fill_color, stroke_color=stroke_color)
890891
except cls.DoesNotExist:
891-
png_image = convert_svg_to_png_bytes(svg_path, fill_color=color)
892-
893-
obj = cls.objects.create(svg_path=svg_path, color=color, png_image_file=png_image)
892+
png_image = convert_svg_to_png_bytes(svg_path, fill_color=fill_color, stroke_color=stroke_color, scale=10)
893+
obj = cls.objects.create(
894+
svg_path=svg_path, fill_color=fill_color, stroke_color=stroke_color, png_image_file=png_image)
894895
return obj.png_image_file
895896

896897
def __str__(self):
897-
return f'{self.svg_path} ({self.color}) -> {self.png_image_file}'
898+
return f'{self.svg_path} (F={self.fill_color}) (S={self.stroke_color}) -> {self.png_image_file}'
898899

899900
class Meta:
900-
unique_together = ('svg_path', 'color')
901+
unique_together = ('svg_path', 'fill_color', 'stroke_color')

0 commit comments

Comments
 (0)