Verified Commit 2709b6d4 authored by Jonathan Weth's avatar Jonathan Weth

Add support for new path_and_rename from core_helpers

parent f28b8f38
from django.db import models
# Create your models here.
from aleksis.core.util.helper import path_and_rename
from aleksis.core.util.core_helpers import path_and_rename
from django.utils.translation import gettext_lazy as _
class Menu(models.Model):
calendar_week = models.IntegerField(verbose_name=_("CW"))
year = models.IntegerField(verbose_name=_("Year"))
pdf = models.FileField(upload_to=path_and_rename, verbose_name=_("PDF"))
pdf = models.FileField(upload_to=lambda a, b: path_and_rename(a, b, upload_to="menu"), verbose_name=_("PDF"))
class Meta:
unique_together = ("calendar_week", "year")
......@@ -10,6 +10,8 @@ from django.utils import timezone
from .models import Menu
from .settings import BASE_DIR
from .forms import MenuUploadForm
from aleksis.core.util import messages
from django.utils.translation import gettext_lazy as _
......@@ -20,7 +22,8 @@ def upload(request):
if form.is_valid():
return redirect('menu_index_msg', msg="success")
messages.success(request, _("The menu was uploaded successfully."))
return redirect('menu_index')
form = MenuUploadForm()
return render(request, 'mensa/upload.html', {
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