uncloud-mravi/uncloud_v3/app/views.py
Nico Schottelius 1e69722f4b in between commit: html bug
- "range" is great in theory, but does not show actual nummber
- "number" does not allow float

Need to go back to text
2022-01-15 23:57:55 +01:00

52 lines
1.5 KiB
Python

from django.shortcuts import render, get_object_or_404
from django.urls import reverse
from django.views.generic.edit import CreateView
from django.views.generic.base import TemplateView
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from .models import *
class ProductOrderView(CreateView):
model = ProductOrder
fields = ['resources']
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['product'] = get_object_or_404(Product, slug=self.kwargs['product'])
context['timeframe'] = get_object_or_404(TimeFrame, slug=self.kwargs['timeframe'])
print(context)
print(self.kwargs)
return context
class ProductDetailView(DetailView):
model = Product
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['productorder'] = reverse('product-order', kwargs={'product': self.object.slug })
context['timeframes'] = context['product'].valid_timeframes()
print(context)
return context
class ProductListView(ListView):
model = Product
class ProductSelectView(CreateView):
model = ProductOrder
fields = ['product' ]
class Yearly(TemplateView):
template_name = "app/config_product.html"
def get_context_data(self, **kwargs):
context = super(Yearly, self).get_context_data(**kwargs)
context['current_year'] = self.current_year
context['current_month'] = self.current_month
return context