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, ))
def get_contact_model(): """Returns the Contact model that is active in this project.""" return get_concrete_model('PERSONS_CONTACT_MODEL')
def get_task_model(): """Returns the ProjectTask model that is active in this django software.""" return get_concrete_model('PROJECTS_TASK_MODEL')
def get_folder_model(): """Returns the Folder model that is active in this project.""" return get_concrete_model('DOCUMENTS_FOLDER_MODEL')
def get_mailinglist_model(): """Returns the MailingList model that is active in this project.""" return get_concrete_model('EMAILS_MLIST_MODEL')
def get_emailtemplate_model(): """Returns the EmailTemplate model that is active in this project.""" return get_concrete_model('EMAILS_TEMPLATE_MODEL')
def get_rgenerator_model(): """Returns the RecurrentGenerator model that is active in this project.""" return get_concrete_model('RECURRENTS_RGENERATOR_MODEL')
def get_product_model(): """Returns the Product model that is active in this project.""" return get_concrete_model('PRODUCTS_PRODUCT_MODEL')
def get_pollreply_model(): """Returns the PollReply model that is active in this project.""" return get_concrete_model('POLLS_REPLY_MODEL')
def get_pollform_model(): """Returns the PollForm model that is active in this project.""" return get_concrete_model('POLLS_FORM_MODEL')
def get_pollcampaign_model(): """Returns the PollCampaign model that is active in this project.""" return get_concrete_model('POLLS_CAMPAIGN_MODEL')
def get_rgraph_model(): "Returns the ReportGraph model that is active in this project." return get_concrete_model('REPORTS_GRAPH_MODEL')
def get_report_model(): "Returns the Report model that is active in this project." return get_concrete_model('REPORTS_REPORT_MODEL')
def get_event_model(): """Returns the Event model that is active in this project.""" return get_concrete_model('EVENTS_EVENT_MODEL')
def get_organisation_model(): """Returns the Organisation model that is active in this project.""" return get_concrete_model('PERSONS_ORGANISATION_MODEL')
def get_messagetemplate_model(): """Returns the MessageTemplate model that is active in this project.""" return get_concrete_model('SMS_TEMPLATE_MODEL')
def get_graph_model(): """Returns the Graph model that is active in this project.""" return get_concrete_model('GRAPHS_GRAPH_MODEL')
def get_act_model(): """Returns the Act model that is active in this project.""" return get_concrete_model('COMMERCIAL_ACT_MODEL')
def get_service_model(): """Returns the Service model that is active in this project.""" return get_concrete_model('PRODUCTS_SERVICE_MODEL')
def get_pattern_model(): """Returns the ActObjectivePattern model that is active in this project.""" return get_concrete_model('COMMERCIAL_PATTERN_MODEL')
def get_emailcampaign_model(): """Returns the EmailCampaign model that is active in this project.""" return get_concrete_model('EMAILS_CAMPAIGN_MODEL')
def get_strategy_model(): """Returns the Strategy model that is active in this project.""" return get_concrete_model('COMMERCIAL_STRATEGY_MODEL')
def get_entityemail_model(): """Returns the EntityEmail model that is active in this project.""" return get_concrete_model('EMAILS_EMAIL_MODEL')
def get_activity_model(): """Returns the Activity model that is active in this project.""" return get_concrete_model('ACTIVITIES_ACTIVITY_MODEL')
def get_document_model(): """Returns the Document model that is active in this project.""" return get_concrete_model('DOCUMENTS_DOCUMENT_MODEL')
def get_smscampaign_model(): """Returns the SMSCampaign model that is active in this project.""" return get_concrete_model('SMS_CAMPAIGN_MODEL')
def get_project_model(): """Returns the Project model that is active in this django software.""" return get_concrete_model('PROJECTS_PROJECT_MODEL')
def get_messaginglist_model(): """Returns the MessagingList model that is active in this project.""" return get_concrete_model('SMS_MLIST_MODEL')
def get_opportunity_model(): """Returns the Opportunity model that is active in this project.""" return get_concrete_model('OPPORTUNITIES_OPPORTUNITY_MODEL')
def get_address_model(): """Returns the Address model that is active in this project.""" return get_concrete_model('PERSONS_ADDRESS_MODEL')