Пример #1
0
    def handle(self, **options):
        types_map = {
            get_concrete_model(type_str): factory_builder
            for type_str, factory_builder in self.TYPES
        }

        get_opt = options.get

        if get_opt('list_types'):
            self.stdout.write('\n'.join(' - {}'.format(m) for m in types_map))
            return

        number = get_opt('number')
        verbosity = get_opt('verbosity')

        locale = entity_factory.get_best_locale(get_opt('language_code'))
        backend_count = 0
        action_count = 0

        from creme.crudity.registry import crudity_registry  # lazy loading

        for fetcher_name, fetcher in crudity_registry._fetchers.items():
            for crud_inputs in fetcher.get_inputs():
                for method, input in crud_inputs.items():
                    for backend in input.get_backends():
                        _get_model_n_factory = types_map.get(backend.model)

                        if _get_model_n_factory is None:
                            self.stderr.write(
                                '"{}" is not managed ; use the -l option to get the managed types.'
                                .format(backend.model))
                            continue

                        backend_count += 1
                        factory = _get_model_n_factory(locale)[1]

                        for i in range(number):
                            try:
                                WaitingAction.objects.create(
                                    action=method,
                                    source='{} - {}'.format(
                                        fetcher_name, input.name),
                                    ct=backend.model,
                                    subject=backend.subject,
                                    # user=owner,  TODO ?
                                    data=_entity_2_dict(factory.build()),
                                )
                            except Exception as e:
                                self.stderr.write(
                                    'A error occurred when saving action: {}.'.
                                    format(e))
                            else:
                                action_count += 1

        if verbosity:
            self.stdout.write('Number of backend used: {backends}\n'
                              'Number of actions created: {actions}'.format(
                                  backends=backend_count,
                                  actions=action_count,
                              ))
Пример #2
0
def get_contact_model():
    """Returns the Contact model that is active in this project."""
    return get_concrete_model('PERSONS_CONTACT_MODEL')
Пример #3
0
def get_task_model():
    """Returns the ProjectTask model that is active in this django software."""
    return get_concrete_model('PROJECTS_TASK_MODEL')
Пример #4
0
def get_folder_model():
    """Returns the Folder model that is active in this project."""
    return get_concrete_model('DOCUMENTS_FOLDER_MODEL')
Пример #5
0
def get_mailinglist_model():
    """Returns the MailingList model that is active in this project."""
    return get_concrete_model('EMAILS_MLIST_MODEL')
Пример #6
0
def get_emailtemplate_model():
    """Returns the EmailTemplate model that is active in this project."""
    return get_concrete_model('EMAILS_TEMPLATE_MODEL')
Пример #7
0
def get_rgenerator_model():
    """Returns the RecurrentGenerator model that is active in this project."""
    return get_concrete_model('RECURRENTS_RGENERATOR_MODEL')
Пример #8
0
def get_product_model():
    """Returns the Product model that is active in this project."""
    return get_concrete_model('PRODUCTS_PRODUCT_MODEL')
Пример #9
0
def get_pollreply_model():
    """Returns the PollReply model that is active in this project."""
    return get_concrete_model('POLLS_REPLY_MODEL')
Пример #10
0
def get_pollform_model():
    """Returns the PollForm model that is active in this project."""
    return get_concrete_model('POLLS_FORM_MODEL')
Пример #11
0
def get_pollcampaign_model():
    """Returns the PollCampaign model that is active in this project."""
    return get_concrete_model('POLLS_CAMPAIGN_MODEL')
Пример #12
0
def get_rgraph_model():
    "Returns the ReportGraph model that is active in this project."
    return get_concrete_model('REPORTS_GRAPH_MODEL')
Пример #13
0
def get_report_model():
    "Returns the Report model that is active in this project."
    return get_concrete_model('REPORTS_REPORT_MODEL')
Пример #14
0
def get_event_model():
    """Returns the Event model that is active in this project."""
    return get_concrete_model('EVENTS_EVENT_MODEL')
Пример #15
0
def get_organisation_model():
    """Returns the Organisation model that is active in this project."""
    return get_concrete_model('PERSONS_ORGANISATION_MODEL')
Пример #16
0
def get_messagetemplate_model():
    """Returns the MessageTemplate model that is active in this project."""
    return get_concrete_model('SMS_TEMPLATE_MODEL')
Пример #17
0
def get_graph_model():
    """Returns the Graph model that is active in this project."""
    return get_concrete_model('GRAPHS_GRAPH_MODEL')
Пример #18
0
def get_act_model():
    """Returns the Act model that is active in this project."""
    return get_concrete_model('COMMERCIAL_ACT_MODEL')
Пример #19
0
def get_service_model():
    """Returns the Service model that is active in this project."""
    return get_concrete_model('PRODUCTS_SERVICE_MODEL')
Пример #20
0
def get_pattern_model():
    """Returns the ActObjectivePattern model that is active in this project."""
    return get_concrete_model('COMMERCIAL_PATTERN_MODEL')
Пример #21
0
def get_emailcampaign_model():
    """Returns the EmailCampaign model that is active in this project."""
    return get_concrete_model('EMAILS_CAMPAIGN_MODEL')
Пример #22
0
def get_strategy_model():
    """Returns the Strategy model that is active in this project."""
    return get_concrete_model('COMMERCIAL_STRATEGY_MODEL')
Пример #23
0
def get_entityemail_model():
    """Returns the EntityEmail model that is active in this project."""
    return get_concrete_model('EMAILS_EMAIL_MODEL')
Пример #24
0
def get_activity_model():
    """Returns the Activity model that is active in this project."""
    return get_concrete_model('ACTIVITIES_ACTIVITY_MODEL')
Пример #25
0
def get_document_model():
    """Returns the Document model that is active in this project."""
    return get_concrete_model('DOCUMENTS_DOCUMENT_MODEL')
Пример #26
0
def get_smscampaign_model():
    """Returns the SMSCampaign model that is active in this project."""
    return get_concrete_model('SMS_CAMPAIGN_MODEL')
Пример #27
0
def get_project_model():
    """Returns the Project model that is active in this django software."""
    return get_concrete_model('PROJECTS_PROJECT_MODEL')
Пример #28
0
def get_messaginglist_model():
    """Returns the MessagingList model that is active in this project."""
    return get_concrete_model('SMS_MLIST_MODEL')
Пример #29
0
def get_opportunity_model():
    """Returns the Opportunity model that is active in this project."""
    return get_concrete_model('OPPORTUNITIES_OPPORTUNITY_MODEL')
Пример #30
0
def get_address_model():
    """Returns the Address model that is active in this project."""
    return get_concrete_model('PERSONS_ADDRESS_MODEL')