Exemple #1
0
    def test_create_if_needed03(self):
        "No overriding."
        desc = CustomFormDescriptor(
            id='creme_core-fakecontact',
            model=FakeContact,
            verbose_name='Creation form for FakeContact',
        )

        mngr = CustomFormConfigItemManager()
        self.assertIsNone(mngr.model)
        mngr.model = CustomFormConfigItem

        group_name = 'General'
        groups_desc = [{
            'name':
            group_name,
            'cells': [
                (EntityCellRegularField, {
                    'name': 'last_name'
                }),
                (EntityCellRegularField, {
                    'name': 'first_name'
                }),
            ],
        }]

        mngr.create_if_needed(
            descriptor=desc,
            groups_desc=groups_desc,
        )

        groups_desc[0]['cells'] = [(EntityCellRegularField, {
            'name': 'last_name'
        })]
        cfci = mngr.create_if_needed(descriptor=desc, groups_desc=groups_desc)
        self.assertListEqual(
            [
                {
                    'name':
                    group_name,
                    'layout':
                    LAYOUT_REGULAR,
                    'cells': [
                        {
                            'type': 'regular_field',
                            'value': 'last_name'
                        },
                        {
                            'type': 'regular_field',
                            'value': 'first_name'
                        },
                    ],
                },
            ],
            self.refresh(cfci).groups_as_dicts(),
        )
Exemple #2
0
    def test_create_if_needed01(self):
        desc = CustomFormDescriptor(
            id='creme_core-fakecontact',
            model=FakeContact,
            verbose_name='Creation form for FakeContact',
        )

        mngr = CustomFormConfigItemManager()
        self.assertIsNone(mngr.model)
        mngr.model = CustomFormConfigItem

        group_name = 'General'
        cfci = mngr.create_if_needed(
            descriptor=desc,
            groups_desc=[{
                'name':
                group_name,
                'cells': [
                    EntityCellRegularField.build(model=FakeContact,
                                                 name='first_name'),
                    (EntityCellRegularField, {
                        'name': 'last_name'
                    }),
                ],
            }],
        )
        self.assertIsInstance(cfci, CustomFormConfigItem)
        self.assertEqual(desc.id, cfci.cform_id)
        self.assertEqual(desc.id, cfci.pk)
        self.assertListEqual(
            [
                {
                    'name':
                    group_name,
                    'layout':
                    LAYOUT_REGULAR,
                    'cells': [
                        {
                            'type': 'regular_field',
                            'value': 'first_name'
                        },
                        {
                            'type': 'regular_field',
                            'value': 'last_name'
                        },
                    ],
                },
            ],
            self.refresh(cfci).groups_as_dicts(),
        )
Exemple #3
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import tickets
from creme.creme_core.gui.custom_form import CustomFormDescriptor

from .forms.template import BaseTemplateCustomForm

Ticket = tickets.get_ticket_model()
TicketTemplate = tickets.get_tickettemplate_model()


TICKET_CREATION_CFORM = CustomFormDescriptor(
    id='tickets-ticket_creation',
    model=Ticket,
    verbose_name=_('Creation form for ticket'),
    excluded_fields=('status',),
)
TICKET_EDITION_CFORM = CustomFormDescriptor(
    id='tickets-ticket_edition',
    model=Ticket,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for ticket'),
)

TTEMPLATE_CREATION_CFORM = CustomFormDescriptor(
    id='tickets-template_creation',
    model=TicketTemplate,
    verbose_name=_('Creation form for ticket template'),
    base_form_class=BaseTemplateCustomForm,
)
Exemple #4
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import opportunities
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.opportunities.forms import opportunity as opp_forms

Opportunity = opportunities.get_opportunity_model()

OPPORTUNITY_CREATION_CFORM = CustomFormDescriptor(
    id='opportunities-opportunity_creation',
    model=Opportunity,
    verbose_name=_('Creation form for opportunity'),
    base_form_class=opp_forms.BaseCustomForm,
    extra_sub_cells=[
        opp_forms.OppEmitterSubCell(),
        opp_forms.OppTargetSubCell(),
    ],
)
OPPORTUNITY_EDITION_CFORM = CustomFormDescriptor(
    id='opportunities-opportunity_edition',
    model=Opportunity,
    verbose_name=_('Edition form for opportunity'),
    base_form_class=opp_forms.BaseCustomForm,
    extra_sub_cells=[opp_forms.OppTargetSubCell()],
)

del Opportunity
Exemple #5
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy

from creme import polls
from creme.creme_core.gui.custom_form import CustomFormDescriptor

PollCampaign = polls.get_pollcampaign_model()
PollForm = polls.get_pollform_model()

CAMPAIGN_CREATION_CFORM = CustomFormDescriptor(
    id='polls-campaign_creation',
    model=PollCampaign,
    verbose_name=pgettext_lazy('polls', 'Creation form for campaign'),
)
CAMPAIGN_EDITION_CFORM = CustomFormDescriptor(
    id='polls-campaign_edition',
    model=PollCampaign,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=pgettext_lazy('polls', 'Edition form for campaign'),
)
PFORM_CREATION_CFORM = CustomFormDescriptor(
    id='polls-pform_creation',
    model=PollForm,
    verbose_name=_('Creation form for poll-form'),
)
PFORM_EDITION_CFORM = CustomFormDescriptor(
    id='polls-pform_edition',
    model=PollForm,
    form_type=CustomFormDescriptor.EDITION_FORM,
Exemple #6
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import reports
from creme.creme_core.gui.custom_form import CustomFormDescriptor

from .forms import report as r_froms

Report = reports.get_report_model()

REPORT_CREATION_CFORM = CustomFormDescriptor(
    id='reports-report_creation',
    model=Report,
    verbose_name=_('Creation form for report (step 1)'),
    excluded_fields=('ct', 'filter'),
    extra_sub_cells=[r_froms.FilteredCTypeSubCell(model=Report)],
)
REPORT_EDITION_CFORM = CustomFormDescriptor(
    id='reports-report_edition',
    model=Report,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for report'),
    excluded_fields=('ct', 'filter'),
    extra_sub_cells=[r_froms.FilterSubCell(model=Report)])

del Report
Exemple #7
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import events
from creme.creme_core.gui.custom_form import CustomFormDescriptor

Event = events.get_event_model()

EVENT_CREATION_CFORM = CustomFormDescriptor(
    id='events-event_creation',
    model=Event,
    verbose_name=_('Creation form for event'),
)
EVENT_EDITION_CFORM = CustomFormDescriptor(
    id='events-event_edition',
    model=Event,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for event'),
)

del Event
Exemple #8
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import persons
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.persons.forms.address import AddressesGroup
from creme.persons.forms.contact import BaseContactCustomForm

Contact = persons.get_contact_model()
Organisation = persons.get_organisation_model()

CONTACT_CREATION_CFORM = CustomFormDescriptor(
    id='persons-contact_creation',
    model=Contact,
    verbose_name=_('Creation form for contact'),
    base_form_class=BaseContactCustomForm,
    extra_group_classes=[AddressesGroup],
)
CONTACT_EDITION_CFORM = CustomFormDescriptor(
    id='persons-contact_edition',
    model=Contact,
    verbose_name=_('Edition form for contact'),
    base_form_class=BaseContactCustomForm,
    extra_group_classes=[AddressesGroup],
)
ORGANISATION_CREATION_CFORM = CustomFormDescriptor(
    id='persons-organisation_creation',
    model=Organisation,
    verbose_name=_('Creation form for organisation'),
    extra_group_classes=[AddressesGroup],
Exemple #9
0
# -*- coding: utf-8 -*-

from django.utils.translation import pgettext_lazy

from creme import graphs
from creme.creme_core.gui.custom_form import CustomFormDescriptor

Graph = graphs.get_graph_model()

GRAPH_CREATION_CFORM = CustomFormDescriptor(
    id='graphs-graph_creation',
    model=Graph,
    verbose_name=pgettext_lazy('graphs', 'Creation form for graph'),
)
GRAPH_EDITION_CFORM = CustomFormDescriptor(
    id='graphs-graph_edition',
    model=Graph,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=pgettext_lazy('graphs', 'Edition form for graph'),
)

del Graph
Exemple #10
0
    def test_create_if_needed02(self):
        "Other model, other fields, layout."
        customfield = CustomField.objects.create(
            name='Rate',
            field_type=CustomField.INT,
            content_type=FakeOrganisation,
        )

        desc = CustomFormDescriptor(
            id='creme_core-tests_fakeorga',
            model=FakeOrganisation,
            verbose_name='Creation form for FakeOrganisation',
        )

        mngr = CustomFormConfigItemManager()
        mngr.model = CustomFormConfigItem

        group_name1 = 'Regular fields'
        group_name2 = 'Custom fields'

        cfci = mngr.create_if_needed(
            descriptor=desc,
            groups_desc=[
                {
                    'name': group_name1,
                    'layout': LAYOUT_DUAL_FIRST,
                    'cells': [
                        (EntityCellRegularField, {
                            'name': 'name'
                        }),
                    ],
                },
                {
                    'name': group_name2,
                    'layout': LAYOUT_DUAL_SECOND,
                    'cells': [
                        EntityCellCustomField(customfield=customfield),
                    ],
                },
            ],
        )
        self.assertEqual(desc.id, cfci.cform_id)
        self.assertListEqual(
            [
                {
                    'name': group_name1,
                    'layout': LAYOUT_DUAL_FIRST,
                    'cells': [{
                        'type': 'regular_field',
                        'value': 'name'
                    }],
                },
                {
                    'name':
                    group_name2,
                    'layout':
                    LAYOUT_DUAL_SECOND,
                    'cells': [{
                        'type': 'custom_field',
                        'value': str(customfield.id)
                    }],
                },
            ],
            self.refresh(cfci).groups_as_dicts(),
        )
Exemple #11
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import commercial
from creme.creme_core.gui.custom_form import CustomFormDescriptor

Act = commercial.get_act_model()
Pattern = commercial.get_pattern_model()
Strategy = commercial.get_strategy_model()

ACT_CREATION_CFORM = CustomFormDescriptor(
    id='commercial-act_creation',
    model=Act,
    verbose_name=_('Creation form for commercial action'),
)
ACT_EDITION_CFORM = CustomFormDescriptor(
    id='commercial-act_edition',
    model=Act,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for commercial action'),
)
PATTERN_CREATION_CFORM = CustomFormDescriptor(
    id='commercial-objective_pattern_creation',
    model=Pattern,
    verbose_name=_('Creation Form for objective pattern'),
)
PATTERN_EDITION_CFORM = CustomFormDescriptor(
    id='commercial-objective_pattern_edition',
    model=Pattern,
    form_type=CustomFormDescriptor.EDITION_FORM,
Exemple #12
0
from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy

from creme import projects
from creme.creme_core.gui.custom_form import CustomFormDescriptor

from .forms import project, task

Project = projects.get_project_model()
ProjectTask = projects.get_task_model()

PROJECT_CREATION_CFORM = CustomFormDescriptor(
    id='projects-project_creation',
    model=Project,
    verbose_name=_('Creation form for project'),
    base_form_class=project.BaseProjectCreationCustomForm,
    extra_sub_cells=[project.ProjectLeadersSubCell(model=Project)],
)
PROJECT_EDITION_CFORM = CustomFormDescriptor(
    id='projects-project_edition',
    model=Project,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for project'),
)

TASK_CREATION_CFORM = CustomFormDescriptor(
    id='projects-task_creation',
    model=ProjectTask,
    verbose_name=pgettext_lazy('projects', 'Creation form for task'),
    base_form_class=task.BaseTaskCreationCustomForm,
Exemple #13
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import recurrents
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.recurrents.forms import recurrentgenerator as base

RecurrentGenerator = recurrents.get_rgenerator_model()

GENERATOR_CREATION_CFORM = CustomFormDescriptor(
    id='recurrents-generator_creation',
    model=RecurrentGenerator,
    verbose_name=_('Creation form for generator'),
    base_form_class=base.BaseRecurrentGeneratorCustomForm,
    extra_sub_cells=[base.GeneratorCTypeSubCell(model=RecurrentGenerator)],
)
GENERATOR_EDITION_CFORM = CustomFormDescriptor(
    id='recurrents-generator_edition',
    model=RecurrentGenerator,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for generator'),
    base_form_class=base.BaseRecurrentGeneratorCustomForm,
)

del RecurrentGenerator
Exemple #14
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy

from creme import sms
from creme.creme_core.gui.custom_form import CustomFormDescriptor

Campaign = sms.get_smscampaign_model()
MessageTemplate = sms.get_messagetemplate_model()
MessagingList = sms.get_messaginglist_model()

CAMPAIGN_CREATION_CFORM = CustomFormDescriptor(
    id='sms-campaign_creation',
    model=Campaign,
    verbose_name=pgettext_lazy('sms', 'Creation form for campaign'),
)
CAMPAIGN_EDITION_CFORM = CustomFormDescriptor(
    id='sms-campaign_edition',
    model=Campaign,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=pgettext_lazy('sms', 'Edition form for campaign'),
    excluded_fields=('lists', ),
)
TEMPLATE_CREATION_CFORM = CustomFormDescriptor(
    id='sms-template_creation',
    model=MessageTemplate,
    verbose_name=pgettext_lazy('emails', 'Creation form for template'),
)
TEMPLATE_EDITION_CFORM = CustomFormDescriptor(
    id='sms-template_edition',
Exemple #15
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import documents
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.documents.forms.document import BaseDocumentCustomForm
from creme.documents.forms.folder import BaseFolderCustomForm

Folder = documents.get_folder_model()
Document = documents.get_document_model()

FOLDER_CREATION_CFORM = CustomFormDescriptor(
    id='documents-folder_creation',
    model=Folder,
    verbose_name=_('Creation form for folder'),
    base_form_class=BaseFolderCustomForm,  # NB: not necessary indeed
)
FOLDER_EDITION_CFORM = CustomFormDescriptor(
    id='documents-folder_edition',
    model=Folder,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for folder'),
    base_form_class=BaseFolderCustomForm,
)
DOCUMENT_CREATION_CFORM = CustomFormDescriptor(
    id='documents-document_creation',
    model=Document,
    verbose_name=_('Creation form for document'),
    base_form_class=BaseDocumentCustomForm,
)
Exemple #16
0
from creme import billing
from creme.creme_core.gui.custom_form import CustomFormDescriptor

from .forms import base, templatebase

Invoice = billing.get_invoice_model()
Quote = billing.get_quote_model()
SalesOrder = billing.get_sales_order_model()
CreditNote = billing.get_credit_note_model()
TemplateBase = billing.get_template_base_model()

INVOICE_CREATION_CFORM = CustomFormDescriptor(
    id='billing-invoice_creation',
    model=Invoice,
    verbose_name=_('Creation form for invoice'),
    base_form_class=base.BaseCustomForm,
    extra_sub_cells=[
        base.BillingSourceSubCell(model=Invoice),
        base.BillingTargetSubCell(model=Invoice),
    ],
)
INVOICE_EDITION_CFORM = CustomFormDescriptor(
    id='billing-invoice_edition',
    model=Invoice,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for invoice'),
    base_form_class=base.BaseCustomForm,
    extra_sub_cells=[
        base.BillingSourceSubCell(model=Invoice),
        base.BillingTargetSubCell(model=Invoice),
    ],
)
Exemple #17
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _

from creme import products
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.products.forms.base import SubCategorySubCell

Product = products.get_product_model()
Service = products.get_service_model()

PRODUCT_CREATION_CFORM = CustomFormDescriptor(
    id='products-product_creation',
    model=Product,
    verbose_name=_('Creation form for product'),
    excluded_fields=('category', 'sub_category'),
    extra_sub_cells=[SubCategorySubCell(model=Product)],
)
PRODUCT_EDITION_CFORM = CustomFormDescriptor(
    id='products-product_edition',
    model=Product,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=_('Edition form for product'),
    excluded_fields=('category', 'sub_category', 'images'),
    extra_sub_cells=[SubCategorySubCell(model=Product)],
)
SERVICE_CREATION_CFORM = CustomFormDescriptor(
    id='products-service_creation',
    model=Service,
    verbose_name=_('Creation form for service'),
    excluded_fields=('category', 'sub_category'),
Exemple #18
0
# -*- coding: utf-8 -*-

from django.utils.translation import gettext_lazy as _
from django.utils.translation import pgettext_lazy

from creme import emails
from creme.creme_core.gui.custom_form import CustomFormDescriptor
from creme.emails.forms.template import EmailTemplateBaseCustomForm

Campaign = emails.get_emailcampaign_model()
EmailTemplate = emails.get_emailtemplate_model()
MailingList = emails.get_mailinglist_model()

CAMPAIGN_CREATION_CFORM = CustomFormDescriptor(
    id='emails-campaign_creation',
    model=Campaign,
    verbose_name=pgettext_lazy('emails', 'Creation form for campaign'),
)
CAMPAIGN_EDITION_CFORM = CustomFormDescriptor(
    id='emails-campaign_edition',
    model=Campaign,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name=pgettext_lazy('emails', 'Edition form for campaign'),
    excluded_fields=('mailing_lists',),
)
TEMPLATE_CREATION_CFORM = CustomFormDescriptor(
    id='emails-template_creation',
    model=EmailTemplate,
    verbose_name=pgettext_lazy('emails', 'Creation form for template'),
    base_form_class=EmailTemplateBaseCustomForm,
)
Exemple #19
0
from creme import activities
from creme.activities.forms import activity
from creme.creme_core.gui.custom_form import CustomFormDescriptor

Activity = activities.get_activity_model()

ACTIVITY_CREATION_CFORM = CustomFormDescriptor(
    id='activities-activity_creation',
    model=Activity,
    verbose_name=_('Creation form for activity'),
    base_form_class=activity.BaseCreationCustomForm,
    excluded_fields=('start', 'end', 'type', 'sub_type'),
    extra_sub_cells=[
        activity.ActivitySubTypeSubCell(model=Activity),
        activity.NormalStartSubCell(model=Activity),
        activity.NormalEndSubCell(model=Activity),
        activity.MyParticipationSubCell(model=Activity),
        activity.ParticipatingUsersSubCell(model=Activity),
        activity.OtherParticipantsSubCell(model=Activity),
        activity.ActivitySubjectsSubCell(model=Activity),
        activity.LinkedEntitiesSubCell(model=Activity),
        activity.DatetimeAlertSubCell(model=Activity),
        activity.PeriodAlertSubCell(model=Activity),
        activity.UserMessagesSubCell(model=Activity),
    ],
)
ACTIVITY_CREATION_FROM_CALENDAR_CFORM = CustomFormDescriptor(
    id='activities-activity_creation_from_calendar',
    model=Activity,
    verbose_name=_('Creation form for activity from the Calendar'),
    base_form_class=activity.BaseCreationCustomForm,
    excluded_fields=[*ACTIVITY_CREATION_CFORM.excluded_fields],
Exemple #20
0
# -*- coding: utf-8 -*-

from creme.creme_core import models
from creme.creme_core.gui.custom_form import CustomFormDescriptor

from . import fake_forms

FAKEORGANISATION_CREATION_CFORM = CustomFormDescriptor(
    id='creme_core-fakeorganisation_creation',
    model=models.FakeOrganisation,
    verbose_name='Creation form for FakeOrganisation',
    extra_group_classes=[fake_forms.FakeAddressGroup],
)

FAKEACTIVITY_CREATION_CFORM = CustomFormDescriptor(
    id='creme_core-fakeactivity_creation',
    model=models.FakeActivity,
    verbose_name='Creation form for FakeActivity',
    base_form_class=fake_forms.BaseFakeActivityCustomForm,
    excluded_fields=['description', 'start', 'end'],
    extra_sub_cells=[
        fake_forms.FakeActivityStartSubCell(),
        fake_forms.FakeActivityEndSubCell(),
    ],
)
FAKEACTIVITY_EDITION_CFORM = CustomFormDescriptor(
    id='creme_core-fakeactivity_edition',
    model=models.FakeActivity,
    form_type=CustomFormDescriptor.EDITION_FORM,
    verbose_name='Edition form for FakeActivity',
    base_form_class=fake_forms.BaseFakeActivityCustomForm,