def action(self, resource, context, form): m_values = {'crm_m_contact': context.query['crm_m_contact']} mission = resource.add_mission(**m_values) Mission_EditForm.action(self, mission, context, form) if is_thingy(context.message, ERROR): return goto = context.get_link(mission) return context.come_back(MSG_NEW_RESOURCE, goto=goto)
def action(self, resource, context, form): company = resource.add_company() Company_EditForm.action(self, company, context, form) if is_thingy(context.message, ERROR): return crm = get_crm(resource) goto = "%s/contacts/;new_contact?crm_p_company=%s" % (context.get_link(crm), company.name) return context.come_back(MSG_NEW_COMPANY, goto)
def encode(cls, value): """Encode to a unicode or a Python value compatible with str(). """ # TODO in 0.70 read datatype from class_schema datatype = cls.datatype # Replace enumerate name by value if issubclass(datatype, Enumerate): value = datatype.get_value(value) if value is None: return '' # Default encoders value_type = type(value) if value_type is XMLParser or value_type is list: return xml_to_text(value) if is_thingy(value, MSG): value = value.gettext() return value
def action(self, resource, context, form, new=False): # First compute differences changes = get_changes(resource, context, form, new=new) # Save changes super(Mission_EditForm, self).action(resource, context, form) if is_thingy(context.message, ERROR): return # Reindex contacts to update Opp/Proj/NoGo, p_assured and p_probable crm = get_crm(resource) contacts = crm.get_resource('contacts') for contact_id in resource.get_property('crm_m_contact'): contact = contacts.get_resource(contact_id) context.database.change_resource(contact) # Send notification to CC send_notification(resource, context, form, changes, new=new)
def get_csv_table_name(self, resource, context): table_name = self.csv_table_name if is_thingy(table_name, MSG): table_name = table_name.gettext() return table_name