PEP fixes

This commit is contained in:
Oliver Walters 2019-04-16 22:32:43 +10:00
parent 7eea9d1a20
commit 01bdf2f19b
6 changed files with 26 additions and 38 deletions

View File

@ -1,7 +1,7 @@
import io
import os
from wsgiref.util import FileWrapper
from django.http import StreamingHttpResponse, HttpResponse
from django.http import StreamingHttpResponse
def WrapWithQuotes(text):

View File

@ -145,8 +145,6 @@ class AjaxCreateView(AjaxMixin, CreateView):
return super(CreateView, self).post(request, *args, **kwargs)
class AjaxUpdateView(AjaxMixin, UpdateView):
""" An 'AJAXified' UpdateView for updating an object in the db
@ -187,13 +185,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
return super(UpdateView, self).post(request, *args, **kwargs)
class AjaxDeleteView(AjaxMixin, DeleteView):
""" An 'AJAXified DeleteView for removing an object from the DB
- Returns a HTML object (not a form!) in JSON format (for delivery to a modal window)
- Handles deletion
- Handles deletion
"""
def get(self, request, *args, **kwargs):

View File

@ -5,7 +5,7 @@ from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import filters
from rest_framework import generics, permissions
from django.conf.urls import url, include
from django.conf.urls import url
from .models import Build
from .serializers import BuildSerializer
@ -30,6 +30,7 @@ class BuildList(generics.ListAPIView):
'part',
]
build_api_urls = [
url(r'^.*$', BuildList.as_view(), name='api-build-list')
]
]

View File

@ -320,7 +320,6 @@ class Part(models.Model):
else:
return None
def export_bom_csv(self, **kwargs):
# Construct header line
@ -336,26 +335,19 @@ class Part(models.Model):
return out
def export_bom_xls(self, **kwargs):
return ''
def export_bom_xml(self, **kwargs):
return ''
def export_bom_htm(self, **kwargs):
return ''
def export_bom_pdf(self, **kwargs):
return ''
"""
@property
def projects(self):
@ -412,12 +404,12 @@ class BomItem(models.Model):
# A link to the parent part
# Each part will get a reverse lookup field 'bom_items'
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='bom_items',
limit_choices_to={'buildable': True})
limit_choices_to={'buildable': True})
# A link to the child item (sub-part)
# Each part will get a reverse lookup field 'used_in'
sub_part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='used_in',
limit_choices_to={'consumable': True})
limit_choices_to={'consumable': True})
# Quantity required
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(0)])

View File

@ -3,8 +3,7 @@ from __future__ import unicode_literals
from django.shortcuts import get_object_or_404
from django.template.loader import render_to_string
from django.urls import reverse_lazy, reverse
from django.urls import reverse_lazy
from django.views.generic import DetailView, ListView
from company.models import Company
@ -19,10 +18,11 @@ from .forms import BomExportForm
from .forms import EditSupplierPartForm
from InvenTree.views import AjaxMixin, AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
from InvenTree.views import AjaxView, AjaxCreateView, AjaxUpdateView, AjaxDeleteView
from InvenTree.helpers import DownloadFile
class PartIndex(ListView):
model = Part
template_name = 'part/category.html'
@ -129,7 +129,6 @@ class BomExport(AjaxView):
model = Part
ajax_form_title = 'Export BOM'
ajax_template_name = 'part/bom_export.html'
#template_name = 'modal_form.html'
context_object_name = 'part'
form_class = BomExportForm
@ -139,6 +138,7 @@ class BomExport(AjaxView):
def get(self, request, *args, **kwargs):
form = self.form_class()
"""
part = self.get_object()
context = {
@ -146,26 +146,25 @@ class BomExport(AjaxView):
}
if request.is_ajax():
pass
passs
"""
return self.renderJsonResponse(request, form, context=context)
return self.renderJsonResponse(request, form)
def post(self, request, *args, **kwargs):
"""
User has now submitted the BOM export data
"""
"""
part = self.get_object()
print("POSTED")
# part = self.get_object()
return super(AjaxView, self).post(request, *args, **kwargs)
def get_data(self):
return {
#'form_valid': True,
#'redirect': '/'
#'redirect': reverse('bom-download', kwargs={'pk': self.request.GET.get('pk')})
# 'form_valid': True,
# 'redirect': '/'
# 'redirect': reverse('bom-download', kwargs={'pk': self.request.GET.get('pk')})
}
@ -178,10 +177,10 @@ class BomDownload(AjaxView):
# TODO - This should no longer extend an AjaxView!
model = Part
#form_class = BomExportForm
#template_name = 'part/bom_export.html'
#ajax_form_title = 'Export Bill of Materials'
#context_object_name = 'part'
# form_class = BomExportForm
# template_name = 'part/bom_export.html'
# ajax_form_title = 'Export Bill of Materials'
# context_object_name = 'part'
def get(self, request, *args, **kwargs):

View File

@ -80,9 +80,9 @@ class StockItemEdit(AjaxUpdateView):
model = StockItem
form_class = EditStockItemForm
template_name = 'stock/item_edit.html'
# template_name = 'stock/item_edit.html'
context_object_name = 'item'
#ajax_template_name = 'modal_form.html'
ajax_template_name = 'modal_form.html'
ajax_form_title = 'Edit Stock Item'