def _select_csv_parameters(self): model_select = XferCompSelect('modelname') if self.model is not None: model_select.set_value(self.model.get_long_name()) model_select.set_select(self.get_select_models()) model_select.set_location(1, 0, 3) model_select.description = _('model') self.add_component(model_select) upld = XferCompUpLoad('csvcontent') upld.http_file = True upld.add_filter(".csv") upld.set_location(1, 1, 2) upld.description = _('CSV file') self.add_component(upld) lbl = XferCompEdit('encoding') lbl.set_value(self.encoding) lbl.set_location(1, 2) lbl.description = _('encoding') self.add_component(lbl) lbl = XferCompEdit('dateformat') lbl.set_value(self.dateformat) lbl.set_location(2, 2) lbl.description = _('date format') self.add_component(lbl) lbl = XferCompEdit('delimiter') lbl.set_value(self.delimiter) lbl.set_location(1, 3) lbl.description = _('delimiter') self.add_component(lbl) lbl = XferCompEdit('quotechar') lbl.set_value(self.quotechar) lbl.set_location(2, 3) lbl.description = _('quotechar') self.add_component(lbl) return lbl
def fillresponse(self, legal_entity=0, name_filter=''): self.item.legal_entity = LegalEntity.objects.get(id=legal_entity) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) self.fill_from_model(1, 0, True, ['legal_entity']) comp = XferCompEdit('filter') comp.set_value(name_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 2) comp.description = _('Filtrer by name') comp.is_default = True self.add_component(comp) identfilter = [] if name_filter != "": identfilter = [ Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)] items = Individual.objects.filter( *identfilter) grid = XferCompGrid('individual') grid.set_model(items, None, self) grid.set_location(1, 3) grid.description = _('individual') grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"), modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"}) grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE) grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO) self.add_component(grid)
def fillresponse(self): if not will_mail_send(): raise LucteriosException(IMPORTANT, _('Bad email parameter!')) legal = LegalEntity.objects.get(id=1) if self.getparam('CONFIRME') is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('lbl_title') lbl.set_location(1, 0, 2) lbl.set_value_as_header(self.caption) dlg.add_component(lbl) email = XferCompEdit('recipient') email.set_location(1, 1) email.set_value(legal.email) email.mask = r"[^@]+@[^@]+\.[^@]+" email.description = _("email") dlg.add_component(email) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: address = [] address.append("") address.append("") address.append(six.text_type(legal)) address.append(legal.address) address.append("%s %s" % (legal.postal_code, legal.city)) message = _('EMail sent to check configuration') message += "{[br/]}".join(address).replace('{[newline]}', "{[br/]}").replace("\n", '{[br/]}') bad_sended = send_email(self.getparam('recipient'), _("EMail try"), "<html><body>%s</body></html>" % message.replace('{[', '<').replace(']}', '>')) if len(bad_sended) != 0: raise EmailException(bad_sended) self.message(_("EMail send, check it."))
def fillresponse(self): legal = LegalEntity.objects.get(id=1) if self.getparam('CONFIRME') is None: dlg = self.create_custom() img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) dlg.add_component(img) lbl = XferCompLabelForm('lbl_title') lbl.set_location(1, 0, 2) lbl.set_value_as_header(self.caption) dlg.add_component(lbl) email = XferCompEdit('recipient') email.set_location(1, 1) email.set_value(legal.email) email.mask = r"[^@]+@[^@]+\.[^@]+" email.description = _("email") dlg.add_component(email) dlg.add_action(self.get_action(TITLE_OK, "images/ok.png"), close=CLOSE_YES, params={'CONFIRME': 'YES'}) dlg.add_action(WrapAction(TITLE_CANCEL, 'images/cancel.png')) else: abs_url = self.request.META.get( 'HTTP_REFERER', self.request.build_absolute_uri()).split('/') self.item.http_root_address = '/'.join(abs_url[:-2]) send_email([self.getparam('recipient')], self.item.subject, self.item.email_content, files=self.item.attach_files) self.message(_("EMail send, check it."))
def fillresponse(self, legal_entity=0, name_filter=''): self.item.legal_entity = LegalEntity.objects.get(id=legal_entity) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) self.fill_from_model(1, 0, True, ['legal_entity']) comp = XferCompEdit('filter') comp.set_value(name_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 2) comp.description = _('Filtrer by name') comp.is_default = True self.add_component(comp) identfilter = [] if name_filter != "": identfilter = [Q(firstname__icontains=name_filter) | Q(lastname__icontains=name_filter)] items = Individual.objects.filter(*identfilter).distinct() grid = XferCompGrid('individual') grid.set_model(items, None, self) grid.set_location(1, 3) grid.description = _('individual') grid.add_action(self.request, ResponsabilityModify.get_action(_("Select"), "images/ok.png"), modal=FORMTYPE_MODAL, close=CLOSE_YES, unique=SELECT_SINGLE, params={"SAVE": "YES"}) grid.add_action(self.request, IndividualShow.get_action(_("Show"), "images/edit.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO, unique=SELECT_SINGLE) grid.add_action(self.request, IndividualAddModify.get_action(TITLE_ADD, "images/add.png"), modal=FORMTYPE_MODAL, close=CLOSE_NO) self.add_component(grid)
def create_dlg(self, username, legalentity): dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) dlg.fill_from_model(1, 0, False, ['genre', 'lastname', 'firstname', 'email']) dlg.get_components( 'email' ).mask = r'^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$' row = dlg.get_max_row() + 1 edt = XferCompEdit("username") edt.set_location(1, row) edt.set_needed(True) edt.set_value(username) edt.description = _('username') dlg.add_component(edt) if Params.getvalue("contacts-createaccount") == 2: row = dlg.get_max_row() + 1 edt = XferCompEdit("legalentity") edt.set_location(1, row) edt.set_needed(True) edt.set_value(legalentity) edt.description = _("your structure name") dlg.add_component(edt) row = dlg.get_max_row() + 1 edt = XferCompCaptcha("captcha") edt.set_location(1, row) edt.description = _("captcha") dlg.add_component(edt) lbl = XferCompLabelForm("error_lbl") lbl.set_location(1, row + 1, 2) lbl.set_color('red') lbl.set_value(self.getparam('error', '')) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
def fillresponse_header(self): name_filter = self.getparam('filter') if name_filter is None: name_filter = "" comp = XferCompEdit('filter') comp.set_value(name_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(0, 2) comp.is_default = True comp.description = _('Filtrer by name') self.add_component(comp) if name_filter != "": self.filter = Q(firstname__icontains=name_filter) | Q( lastname__icontains=name_filter)
def fillresponse_header(self): name_filter = self.getparam('filter') if name_filter is None: name_filter = "" comp = XferCompEdit('filter') comp.set_value(name_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(0, 2) comp.is_default = True comp.description = _('Filtrer by name') self.add_component(comp) if name_filter != "": self.filter = Q(firstname__icontains=name_filter) | Q( lastname__icontains=name_filter)
def create_dlg(self, username, legalentity): dlg = self.create_custom(self.model) img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 6) dlg.add_component(img) dlg.fill_from_model(1, 0, False, ['genre', 'lastname', 'firstname', 'email']) dlg.get_components('email').mask = '^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-_])+\.)+([a-zA-Z0-9]{2,4})+$' row = dlg.get_max_row() + 1 edt = XferCompEdit("username") edt.set_location(1, row) edt.set_needed(True) edt.set_value(username) edt.description = _('username') dlg.add_component(edt) if Params.getvalue("contacts-createaccount") == 2: row = dlg.get_max_row() + 1 edt = XferCompEdit("legalentity") edt.set_location(1, row) edt.set_needed(True) edt.set_value(legalentity) edt.description = _("your structure name") dlg.add_component(edt) row = dlg.get_max_row() + 1 edt = XferCompCaptcha("captcha") edt.set_location(1, row) edt.description = _("captcha") dlg.add_component(edt) lbl = XferCompLabelForm("error_lbl") lbl.set_location(1, row + 1, 2) lbl.set_color('red') lbl.set_value(self.getparam('error', '')) dlg.add_component(lbl) dlg.add_action(self.get_action(_('Ok'), 'images/ok.png'), params={"SAVE": "YES"}) dlg.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
def fillresponse_header(self): self.new_tab(_("Owners")) contact_filter = self.getparam('filter', '') comp = XferCompEdit('filter') comp.set_value(contact_filter) comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(0, 0, 2) comp.is_default = True comp.description = _('Filtrer by owner') self.add_component(comp) self.filter = Q() if contact_filter != "": q_legalentity = Q(third__contact__legalentity__name__icontains=contact_filter) q_individual = Q(completename__icontains=contact_filter) self.filter &= (q_legalentity | q_individual)
def fillresponse_header(self): filter_postal_code = self.getparam('filter_postal_code') if filter_postal_code is None: local_struct = LegalEntity.objects.get(id=1) filter_postal_code = six.text_type(local_struct.postal_code) comp = XferCompEdit('filter_postal_code') comp.set_value(filter_postal_code) comp.is_default = True comp.set_action(self.request, self.get_action(), modal=FORMTYPE_REFRESH, close=CLOSE_NO) comp.set_location(1, 1) comp.description = _('Filtrer by postal code') self.add_component(comp) self.filter = Q(postal_code__startswith=filter_postal_code)
def fillresponse(self): img = XferCompImage('img') img.set_value(self.icon_path()) img.set_location(0, 0, 1, 3) self.add_component(img) lbl = XferCompLabelForm('lbl_title') lbl.set_location(1, 0, 2) lbl.set_value_as_header(_("To receive by email your login and a new password.")) self.add_component(lbl) email = XferCompEdit('email') email.set_location(1, 1) email.mask = r"[^@]+@[^@]+\.[^@]+" email.description = _("email") self.add_component(email) self.add_action(AskPasswordAct.get_action(_('Ok'), 'images/ok.png')) self.add_action(WrapAction(_('Cancel'), 'images/cancel.png'))
def show(self, xfer): destination_file = join("documents", "document_%s" % six.text_type(self.item.id)) if not isfile(join(get_user_dir(), destination_file)): raise LucteriosException(IMPORTANT, _("File not found!")) obj_cmt = xfer.get_components('creator') down = XferCompDownLoad('filename') down.compress = True down.http_file = True down.maxsize = 0 down.set_value(self.item.name) down.set_download(destination_file) down.set_action(xfer.request, ActionsManage.get_action_url('documents.Document', 'AddModify', xfer), modal=FORMTYPE_MODAL, close=CLOSE_NO) down.set_location(obj_cmt.col, obj_cmt.row + 1, 4) xfer.add_component(down) link = self.item.shared_link if link is not None: shared_link = XferCompEdit('shared_link') shared_link.description = _('shared link') shared_link.set_value(link) shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4) xfer.add_component(shared_link)
def show(self, xfer): if not isfile(self.item.file_path): raise LucteriosException(IMPORTANT, _("File not found!")) obj_cmt = xfer.get_components('creator') down = XferCompDownLoad('filename') down.compress = True down.http_file = True down.maxsize = 0 down.set_value(self.item.name) down.set_download(self.item.file_path) down.set_action(xfer.request, ActionsManage.get_action_url( 'documents.DocumentContainer', 'AddModify', xfer), modal=FORMTYPE_MODAL, close=CLOSE_NO) down.set_location(obj_cmt.col, obj_cmt.row + 1, 4) xfer.add_component(down) link = self.item.shared_link if link is not None: shared_link = XferCompEdit('shared_link') shared_link.description = _('shared link') shared_link.set_value(link) shared_link.set_location(obj_cmt.col, obj_cmt.row + 2, 4) xfer.add_component(shared_link)