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