84a39ccb62
For Motion poll: - Overworked how motion poll chart displays the legend - Added the vote counter to the motion detail - Added a progress bar to the vote counter - Fixed some perm errors with the chart - Show a "Singe Votes" link as button for published named polls - Replace the edit-button with a dot-menu - Having project, Edit, PDF and Delete For Motion Poll detail: - enhance search panel - Remove the breadcrumbs - Remove the vote counter - Enhanced the single-vote grid, table and filter bar - Enhance how the poll state enum was checkend For the Motion Poll Create/Update Form: - Remove the selection of poll-methode (whenever possible) - only show "publish imediately" during creation
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
# Generated by Finn Stutzenstein on 2019-11-22 11:42
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
def calculate_aspect_ratios(apps, schema_editor):
|
|
"""
|
|
Assignes every projector one aspect ratio of the ones, that OS
|
|
supported until this migration. If no matching ratio was found, the
|
|
default of 16:9 is assigned.
|
|
"""
|
|
Projector = apps.get_model("core", "Projector")
|
|
ratio_environment = 0.05
|
|
aspect_ratios = {
|
|
4 / 3: (4, 3),
|
|
16 / 9: (16, 9),
|
|
16 / 10: (16, 10),
|
|
30 / 9: (30, 9),
|
|
}
|
|
|
|
for projector in Projector.objects.all():
|
|
projector_ratio = projector.width / projector.height
|
|
ratio = (16, 9) # default, if no matching aspect ratio was found.
|
|
# Search ratio, that fits to the projector_ratio. Take first one found.
|
|
for value, _ratio in aspect_ratios.items():
|
|
if (
|
|
value >= projector_ratio - ratio_environment
|
|
and value <= projector_ratio + ratio_environment
|
|
):
|
|
ratio = _ratio
|
|
break
|
|
projector.aspect_ratio_numerator = ratio[0]
|
|
projector.aspect_ratio_denominator = ratio[1]
|
|
projector.save(skip_autoupdate=True)
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
("core", "0026_projector_size_1"),
|
|
]
|
|
|
|
operations = [
|
|
migrations.RunPython(calculate_aspect_ratios),
|
|
]
|