Exemple #1
0
        if not auto and not ref:
            self.errors['reference'] = [
                _("You did not check the Auto box: the reference is required.")
            ]
        if ECR.objects.filter(reference=ref).exists():
            if not auto:
                raise ValidationError(
                    _("An object with the same type, reference and revision already exists"
                      ))
            else:
                cleaned_data["reference"] = get_new_reference(start, inbulk)
        return cleaned_data


ECRForm.base_fields["reference"].required = False
enhance_fields(ECRForm, ECR)


def get_creation_form(user, data=None, start=0, inbulk_cache=None, **kwargs):
    u"""
    Returns a creation form suitable to create an ECR.

    The returned form can be used, if it is valid, with the function
    :meth:`~plmapp.controllers.ECRController.create_from_form`
    to create a :class:`~plmapp.models.ECR` and its associated
    :class:`~plmapp.controllers.ECRController`.

    If *data* is provided, it will be used to fill the form.

    *start* is used if *data* is ``None``, it's usefull if you need to show
    several initial creation forms at once and you want different references.
Exemple #2
0
from django import forms

from openPLM.plmapp.forms import enhance_fields
from .models import Page


class PageForm(forms.Form):
    page_content = forms.CharField(widget=forms.Textarea())


enhance_fields(PageForm, Page)
Exemple #3
0
        inbulk = getattr(self, "inbulk_cache")
        start = getattr(self, "start", 0)
        if auto and not ref:
            cleaned_data["reference"] = ref = get_new_reference(start, inbulk)
        if not auto and not ref:
            self.errors["reference"] = [_("You did not check the Auto box: the reference is required.")]
        if ECR.objects.filter(reference=ref).exists():
            if not auto:
                raise ValidationError(_("An object with the same type, reference and revision already exists"))
            else:
                cleaned_data["reference"] = get_new_reference(start, inbulk)
        return cleaned_data


ECRForm.base_fields["reference"].required = False
enhance_fields(ECRForm, ECR)


def get_creation_form(user, data=None, start=0, inbulk_cache=None, **kwargs):
    u"""
    Returns a creation form suitable to create an ECR.

    The returned form can be used, if it is valid, with the function
    :meth:`~plmapp.controllers.ECRController.create_from_form`
    to create a :class:`~plmapp.models.ECR` and its associated
    :class:`~plmapp.controllers.ECRController`.

    If *data* is provided, it will be used to fill the form.

    *start* is used if *data* is ``None``, it's usefull if you need to show
    several initial creation forms at once and you want different references.
Exemple #4
0
from django import forms

from openPLM.plmapp.forms import enhance_fields
from .models import Page


class PageForm(forms.Form):
    page_content = forms.CharField(widget=forms.Textarea())

enhance_fields(PageForm, Page)