supplier package

supplier.fields module

class supplier.fields.ContentTypeRestrictedFileField(*args, **kwargs)

Bases: django.db.models.fields.files.FileField

Same as FileField, but you can specify:
  • content_types - list containing allowed content_types. Example: [‘application/pdf’, ‘image/jpeg’]

  • max_upload_size - a number indicating the maximum file size allowed for upload.

    2.5MB - 2621440 5MB - 5242880 10MB - 10485760 20MB - 20971520 50MB - 5242880 100MB 104857600 250MB - 214958080 500MB - 429916160

clean(*args, **kwargs)

Convert the value’s type and run validation. Validation errors from to_python() and validate() are propagated. Return the correct value if no error is raised.

deconstruct()

Return enough information to recreate the field as a 4-tuple:

  • The name of the field on the model, if contribute_to_class() has been run.

  • The import path of the field, including the class:e.g. django.db.models.IntegerField This should be the most portable version, so less specific may be better.

  • A list of positional arguments.

  • A dict of keyword arguments.

Note that the positional or keyword arguments must contain values of the following types (including inner values of collection types):

  • None, bool, str, int, float, complex, set, frozenset, list, tuple, dict

  • UUID

  • datetime.datetime (naive), datetime.date

  • top-level classes, top-level functions - will be referenced by their full import path

  • Storage instances - these have their own deconstruct() method

This is because the values here must be serialized into a text format (possibly new Python code, possibly JSON) and these are the only types with encoding handlers defined.

There’s no need to return the exact way the field was instantiated this time, just ensure that the resulting field is the same - prefer keyword arguments over positional ones, and omit parameters with their default values.

supplier.forms module

class supplier.forms.CodeRequestForm(*args, **kwargs)

Bases: coolfarmtool.forms.ConditionalForm

clean()

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

property media

Return all media required to render the widgets on this form.

class supplier.forms.SupplierCodeForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, field_order=None, use_required_attribute=None, renderer=None)

Bases: floppyforms.forms.Form

property media

Return all media required to render the widgets on this form.

supplier.models module

class supplier.models.CodeProvider(id, name, email)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class supplier.models.Document(*args, **kwargs)

Bases: django.db.models.base.Model

Document associated with a particular supplier

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class supplier.models.Supplier(id, name, code, provider, description, has_custom_fertiliser_production, has_export, has_supplier_section, has_batch_import, has_multiple_farms, footprint_limit, dataset)

Bases: django.db.models.base.Model

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

supplier.views module

class supplier.views.AddCodeView(**kwargs)

Bases: braces.views._access.LoginRequiredMixin, braces.views._ajax.JSONResponseMixin, farm.views.AjaxResponseMixin, django.views.generic.edit.FormView

form_class

alias of supplier.forms.SupplierCodeForm

form_valid(form)

If the form is valid, redirect to the supplied URL.

get(request, *args, **kwargs)

Handle GET requests: instantiate a blank version of the form.

class supplier.views.CodeRequestView(**kwargs)

Bases: farm.views.AjaxResponseMixin, braces.views._ajax.JSONResponseMixin, django.views.generic.edit.FormView

form_class

alias of supplier.forms.CodeRequestForm

form_valid(form)

If the form is valid, redirect to the supplied URL.

class supplier.views.ProjectsView(**kwargs)

Bases: braces.views._access.LoginRequiredMixin, braces.views._ajax.JSONResponseMixin, farm.views.AjaxResponseMixin, django.views.generic.base.TemplateView

class supplier.views.RemoveCodeView(**kwargs)

Bases: supplier.views.AddCodeView

form_valid(form)

If the form is valid, redirect to the supplied URL.

class supplier.views.SupplierView(**kwargs)

Bases: farm.views.FarmMixin, django.views.generic.detail.DetailView

get_object(queryset=None)

Return the object the view is displaying.

Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.

model

alias of supplier.models.Supplier