Compare commits

..

No commits in common. "5ce7d99db27ba76b0fc266f01d3b0b5752fd4b2f" and "b3f8041f086fdc7363bda42b3db5d40e78da55ce" have entirely different histories.

4 changed files with 89 additions and 51 deletions

View File

@ -1,12 +1,20 @@
import uuid from django.shortcuts import render, redirect
from django.shortcuts import redirect from django.urls import reverse
from django.contrib.auth.forms import AuthenticationForm as AuthForm
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
import django.forms as forms
from django.views.generic import TemplateView, DetailView from django.views.generic import TemplateView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from ..models import Distributor from ..models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, DistributorNum
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import ProtectedError from django.db.models import ProtectedError
from ..forms import * from ..forms import *
from django.db.models import Q from django.db.models import Q
from django.db.models.functions import Lower
import uuid
from .generic_views import BaseTemplateMixin from .generic_views import BaseTemplateMixin
class DistributorView(LoginRequiredMixin, BaseTemplateMixin, TemplateView): class DistributorView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):

View File

@ -1,11 +1,20 @@
from django.shortcuts import redirect from django.shortcuts import render, redirect
from django.urls import reverse
from django.contrib.auth.forms import AuthenticationForm as AuthForm
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
import django.forms as forms
from django.views.generic import TemplateView, DetailView from django.views.generic import TemplateView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from ..models import Manufacturer from ..models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, DistributorNum
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import ProtectedError from django.db.models import ProtectedError
from ..forms import * from ..forms import *
from django.db.models import Q from django.db.models import Q
from django.db.models.functions import Lower
import uuid
from .generic_views import BaseTemplateMixin from .generic_views import BaseTemplateMixin
class ManufacturersView(LoginRequiredMixin, BaseTemplateMixin, TemplateView): class ManufacturersView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):

View File

@ -1,11 +1,20 @@
from django.shortcuts import redirect from django.shortcuts import render, redirect
from django.urls import reverse
from django.contrib.auth.forms import AuthenticationForm as AuthForm
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
import django.forms as forms
from django.views.generic import TemplateView, DetailView from django.views.generic import TemplateView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from ..models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, DistributorNum
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import ProtectedError from django.db.models import ProtectedError
from django.db.models import Q
from ..forms import * from ..forms import *
from ..models import Package from django.db.models import Q
from django.db.models.functions import Lower
import uuid
from .generic_views import BaseTemplateMixin from .generic_views import BaseTemplateMixin
class PackageView(LoginRequiredMixin, BaseTemplateMixin, TemplateView): class PackageView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):

View File

@ -1,14 +1,24 @@
import uuid from django.shortcuts import render, redirect
from django.shortcuts import redirect
from django.urls import reverse from django.urls import reverse
from django.contrib.auth import logout, login
from django.contrib.auth.forms import AuthenticationForm as AuthForm
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth import update_session_auth_hash
import django.forms as forms
from django.views.generic import TemplateView, DetailView from django.views.generic import TemplateView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin
from ..models import Storage, Stock, Component, Distributor, Manufacturer, Package, ComponentParameter, DistributorNum
from django.core.paginator import Paginator from django.core.paginator import Paginator
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db import IntegrityError
from django.db.models import ProtectedError
from ..forms import *
from .component_import import import_components_from_csv
from django.db.models import Q from django.db.models import Q
from django.db.models.functions import Lower from django.db.models.functions import Lower
from ..models import Storage, Stock from django.forms import formset_factory
from ..forms import * from django.http import HttpResponse
import uuid
from .generic_views import BaseTemplateMixin from .generic_views import BaseTemplateMixin
class StockView(LoginRequiredMixin, BaseTemplateMixin, TemplateView): class StockView(LoginRequiredMixin, BaseTemplateMixin, TemplateView):
@ -150,6 +160,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
def handle_change_storage_post(self, request, **kwargs): def handle_change_storage_post(self, request, **kwargs):
f = ChangeStorageForm(data=request.POST) f = ChangeStorageForm(data=request.POST)
if f.is_valid(): if f.is_valid():
sub_name = f.cleaned_data['storage_name']
try: try:
self.object.name = f.cleaned_data['storage_name'] self.object.name = f.cleaned_data['storage_name']
self.object.verbose_name = f.cleaned_data.get('verbose_name') self.object.verbose_name = f.cleaned_data.get('verbose_name')
@ -177,7 +188,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
return redirect(reverse('parts-stocks-detail', kwargs={'uuid':parent.id})) return redirect(reverse('parts-stocks-detail', kwargs={'uuid':parent.id}))
def handle_del_stock_post(self, request, **kwargs): def handle_del_stock_post(self, request, **kwargs):
del_error = None # TODO: Check error handling. This is clearly not working as intended :P del_error = None
if 'stock_uuid' in request.POST: if 'stock_uuid' in request.POST:
f = DeleteStockForm(data=request.POST) f = DeleteStockForm(data=request.POST)
if f.is_valid(): if f.is_valid():
@ -197,6 +208,7 @@ class StockViewDetail(LoginRequiredMixin, BaseTemplateMixin, DetailView):
def handle_update_watermark(self, request, **kwargs): def handle_update_watermark(self, request, **kwargs):
edit_form = EditWatermarkForm(data=request.POST) edit_form = EditWatermarkForm(data=request.POST)
update_watermark_error = None
if edit_form.is_valid(): if edit_form.is_valid():
edit_form.save() edit_form.save()
else: else: