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

Use material form to render upload form

parent 5cad4d11
from django import forms
from django.core.validators import FileExtensionValidator
from django.utils import timezone
from material import Layout, Row
from .models import Menu
......@@ -15,12 +16,15 @@ class MenuUploadForm(forms.ModelForm):
year = forms.ChoiceField(, choices=options_for_year
pdf = forms.FileField(
layout = Layout(
Row("calendar_week", "year"),
class Meta:
model = Menu
fields = ("calendar_week", "year", "pdf")
{% extends "core/base.html" %}
{% load msg_box %}
{% load msg_box i18n material_form %}
{% block page_title %}{% trans "Upload menu" %}{% endblock %}
{% block content %}
<h5>Speiseplan hochladen</h5>
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{% msg_box form.non_field_errors "error" "error" %}
<div class="row">
<div class="input-field col s5">
{% msg_box form.calendar_week.errors "error" "error" %}
{{ form.calendar_week }}
<div class="col s2 center-align">
<div class="input-field col s5">
{% msg_box form.year.errors "error" "error" %}
{{ form.year }}
<div class="file-field input-field">
{% msg_box form.pdf.errors "error" "error" %}
<div class="btn">
<span><i class="material-icons center">cloud_upload</i></span>
<input type="file" name="{{ form.pdf.html_name }}">
<div class="file-path-wrapper">
<input class="file-path validate" type="text">
{% form form=form %}{% endform %}
<button class="waves-effect waves-light btn green" type="submit">
<i class="material-icons left">cloud_upload</i>
Speiseplan hochladen und veröffentlichen
{% trans "Upload and publish menu" %}
<a href="{% url 'menu_index' %}" class="waves-effect waves-teal btn-flat">Zurück zur Übersicht</a>
<a href="{% url 'menu_index' %}" class="waves-effect waves-teal btn-flat">{% trans "Back to overview" %}</a>
{% endblock %}
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