mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 13:05:42 +00:00
Documentation for Part app
This commit is contained in:
@ -1,9 +1,14 @@
|
||||
"""
|
||||
JSON serializers for Company app
|
||||
"""
|
||||
|
||||
from rest_framework import serializers
|
||||
|
||||
from .models import Company
|
||||
|
||||
|
||||
class CompanyBriefSerializer(serializers.ModelSerializer):
|
||||
""" Serializer for Company object (limited detail) """
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
|
||||
@ -17,6 +22,7 @@ class CompanyBriefSerializer(serializers.ModelSerializer):
|
||||
|
||||
|
||||
class CompanySerializer(serializers.ModelSerializer):
|
||||
""" Serializer for Company object (full detail) """
|
||||
|
||||
url = serializers.CharField(source='get_absolute_url', read_only=True)
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
"""
|
||||
Django views for interacting with Company app
|
||||
"""
|
||||
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
@ -12,12 +17,20 @@ from .forms import CompanyImageForm
|
||||
|
||||
|
||||
class CompanyIndex(ListView):
|
||||
""" View for displaying list of companies
|
||||
"""
|
||||
|
||||
model = Company
|
||||
template_name = 'company/index.html'
|
||||
context_object_name = 'companies'
|
||||
paginate_by = 50
|
||||
|
||||
def get_queryset(self):
|
||||
""" Retrieve the Company queryset based on HTTP request parameters.
|
||||
|
||||
- supplier: Filter by supplier
|
||||
- customer: Filter by customer
|
||||
"""
|
||||
queryset = Company.objects.all().order_by('name')
|
||||
|
||||
if self.request.GET.get('supplier', None):
|
||||
@ -30,6 +43,7 @@ class CompanyIndex(ListView):
|
||||
|
||||
|
||||
class CompanyDetail(DetailView):
|
||||
""" Detail view for Company object """
|
||||
context_obect_name = 'company'
|
||||
template_name = 'company/detail.html'
|
||||
queryset = Company.objects.all()
|
||||
@ -37,6 +51,7 @@ class CompanyDetail(DetailView):
|
||||
|
||||
|
||||
class CompanyImage(AjaxUpdateView):
|
||||
""" View for uploading an image for the Company """
|
||||
model = Company
|
||||
ajax_template_name = 'modal_form.html'
|
||||
ajax_form_title = 'Update Company Image'
|
||||
@ -49,6 +64,7 @@ class CompanyImage(AjaxUpdateView):
|
||||
|
||||
|
||||
class CompanyEdit(AjaxUpdateView):
|
||||
""" View for editing a Company object """
|
||||
model = Company
|
||||
form_class = EditCompanyForm
|
||||
context_object_name = 'company'
|
||||
@ -62,6 +78,7 @@ class CompanyEdit(AjaxUpdateView):
|
||||
|
||||
|
||||
class CompanyCreate(AjaxCreateView):
|
||||
""" View for creating a new Company object """
|
||||
model = Company
|
||||
context_object_name = 'company'
|
||||
form_class = EditCompanyForm
|
||||
@ -75,6 +92,7 @@ class CompanyCreate(AjaxCreateView):
|
||||
|
||||
|
||||
class CompanyDelete(AjaxDeleteView):
|
||||
""" View for deleting a Company object """
|
||||
model = Company
|
||||
success_url = '/company/'
|
||||
ajax_template_name = 'company/delete.html'
|
||||
|
Reference in New Issue
Block a user