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 io
import os
from wsgiref.util import FileWrapper from wsgiref.util import FileWrapper
from django.http import StreamingHttpResponse, HttpResponse from django.http import StreamingHttpResponse
def WrapWithQuotes(text): def WrapWithQuotes(text):

View File

@ -145,8 +145,6 @@ class AjaxCreateView(AjaxMixin, CreateView):
return super(CreateView, self).post(request, *args, **kwargs) return super(CreateView, self).post(request, *args, **kwargs)
class AjaxUpdateView(AjaxMixin, UpdateView): class AjaxUpdateView(AjaxMixin, UpdateView):
""" An 'AJAXified' UpdateView for updating an object in the db """ 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) return super(UpdateView, self).post(request, *args, **kwargs)
class AjaxDeleteView(AjaxMixin, DeleteView): class AjaxDeleteView(AjaxMixin, DeleteView):
""" An 'AJAXified DeleteView for removing an object from the DB """ 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) - 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): 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 filters
from rest_framework import generics, permissions from rest_framework import generics, permissions
from django.conf.urls import url, include from django.conf.urls import url
from .models import Build from .models import Build
from .serializers import BuildSerializer from .serializers import BuildSerializer
@ -30,6 +30,7 @@ class BuildList(generics.ListAPIView):
'part', 'part',
] ]
build_api_urls = [ build_api_urls = [
url(r'^.*$', BuildList.as_view(), name='api-build-list') url(r'^.*$', BuildList.as_view(), name='api-build-list')
] ]

View File

@ -320,7 +320,6 @@ class Part(models.Model):
else: else:
return None return None
def export_bom_csv(self, **kwargs): def export_bom_csv(self, **kwargs):
# Construct header line # Construct header line
@ -336,26 +335,19 @@ class Part(models.Model):
return out return out
def export_bom_xls(self, **kwargs): def export_bom_xls(self, **kwargs):
return '' return ''
def export_bom_xml(self, **kwargs): def export_bom_xml(self, **kwargs):
return '' return ''
def export_bom_htm(self, **kwargs): def export_bom_htm(self, **kwargs):
return '' return ''
def export_bom_pdf(self, **kwargs): def export_bom_pdf(self, **kwargs):
return '' return ''
""" """
@property @property
def projects(self): def projects(self):
@ -412,12 +404,12 @@ class BomItem(models.Model):
# A link to the parent part # A link to the parent part
# Each part will get a reverse lookup field 'bom_items' # Each part will get a reverse lookup field 'bom_items'
part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='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) # A link to the child item (sub-part)
# Each part will get a reverse lookup field 'used_in' # Each part will get a reverse lookup field 'used_in'
sub_part = models.ForeignKey(Part, on_delete=models.CASCADE, related_name='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 required
quantity = models.PositiveIntegerField(default=1, validators=[MinValueValidator(0)]) 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.shortcuts import get_object_or_404
from django.template.loader import render_to_string from django.urls import reverse_lazy
from django.urls import reverse_lazy, reverse
from django.views.generic import DetailView, ListView from django.views.generic import DetailView, ListView
from company.models import Company from company.models import Company
@ -19,10 +18,11 @@ from .forms import BomExportForm
from .forms import EditSupplierPartForm 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 from InvenTree.helpers import DownloadFile
class PartIndex(ListView): class PartIndex(ListView):
model = Part model = Part
template_name = 'part/category.html' template_name = 'part/category.html'
@ -129,7 +129,6 @@ class BomExport(AjaxView):
model = Part model = Part
ajax_form_title = 'Export BOM' ajax_form_title = 'Export BOM'
ajax_template_name = 'part/bom_export.html' ajax_template_name = 'part/bom_export.html'
#template_name = 'modal_form.html'
context_object_name = 'part' context_object_name = 'part'
form_class = BomExportForm form_class = BomExportForm
@ -139,6 +138,7 @@ class BomExport(AjaxView):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
form = self.form_class() form = self.form_class()
"""
part = self.get_object() part = self.get_object()
context = { context = {
@ -146,26 +146,25 @@ class BomExport(AjaxView):
} }
if request.is_ajax(): if request.is_ajax():
pass passs
"""
return self.renderJsonResponse(request, form, context=context) return self.renderJsonResponse(request, form)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
""" """
User has now submitted the BOM export data User has now submitted the BOM export data
""" """
part = self.get_object() # part = self.get_object()
print("POSTED")
return super(AjaxView, self).post(request, *args, **kwargs) return super(AjaxView, self).post(request, *args, **kwargs)
def get_data(self): def get_data(self):
return { return {
#'form_valid': True, # 'form_valid': True,
#'redirect': '/' # 'redirect': '/'
#'redirect': reverse('bom-download', kwargs={'pk': self.request.GET.get('pk')}) # '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! # TODO - This should no longer extend an AjaxView!
model = Part model = Part
#form_class = BomExportForm # form_class = BomExportForm
#template_name = 'part/bom_export.html' # template_name = 'part/bom_export.html'
#ajax_form_title = 'Export Bill of Materials' # ajax_form_title = 'Export Bill of Materials'
#context_object_name = 'part' # context_object_name = 'part'
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):

View File

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