Verified Commit 00200533 authored by Jonathan Weth's avatar Jonathan Weth

Add migrations and add wrapper func for path_and_rename

parent 2709b6d4
# Generated by Django 3.0.2 on 2020-01-18 13:05
import aleksis.apps.mensa.models
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
operations = [
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('calendar_week', models.IntegerField(verbose_name='CW')),
('year', models.IntegerField(verbose_name='Year')),
('pdf', models.FileField(upload_to=aleksis.apps.mensa.models.path_and_rename_menu, verbose_name='PDF')),
'verbose_name': 'Menu',
'verbose_name_plural': 'Menus',
'unique_together': {('calendar_week', 'year')},
......@@ -5,10 +5,14 @@ from aleksis.core.util.core_helpers import path_and_rename
from django.utils.translation import gettext_lazy as _
def path_and_rename_menu(instance, filename: str) -> str:
return path_and_rename(instance, filename, upload_to="menu")
class Menu(models.Model):
calendar_week = models.IntegerField(verbose_name=_("CW"))
year = models.IntegerField(verbose_name=_("Year"))
pdf = models.FileField(upload_to=lambda a, b: path_and_rename(a, b, upload_to="menu"), verbose_name=_("PDF"))
pdf = models.FileField(upload_to=path_and_rename_menu, verbose_name=_("PDF"))
class Meta:
unique_together = ("calendar_week", "year")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment