def send_problem_email(self,fromName,email,msg,air_id='',domain_override=''): _current_site_ = domain_override if (domain_override and len(domain_override) > 0) else settings.CURRENT_SITE _current_site = _current_site_.replace('.appspot','').replace('.com','').capitalize() subject = django_utils.render_from_string(__registration_problem_email_subject__,context=Context({ 'fromName': fromName, 'site': _current_site },autoescape=False)) subject = ''.join(subject.splitlines()) # Email subject *must not* contain newlines c = { 'msg': msg, 'fromName': fromName, 'site': _current_site_, 'site_name': _current_site } message = django_utils.render_from_string(__problem_report_email__,context=c) message_html = django_utils.render_from_string(__problem_report_email_html__,context=c) try: queue_email(email,air_sender(air_id),subject,message,message_html,air_id,is_html=True) except Exception, e: info_string = _utils.formattedException(details=e) logging.error('RegistrationManager.create_inactive_user.ERROR --> %s' % (info_string))
def send_activation_email(self,new_user,password,registration_profile,air_id='',domain_override='',prefix='',reason='',data={},error_symbol=None): from vyperlogix.products import keys _current_site_ = domain_override if (domain_override and len(domain_override) > 0) else settings.CURRENT_SITE _current_site = '.'.join([t.capitalize() for t in _current_site_.split('.')]) subject = django_utils.render_from_string(__registration_activation_email_subject__,context=Context({ 'site': _current_site },autoescape=False)) subject = ''.join(subject.splitlines()) # Email subject *must not* contain newlines c = { 'activation_key': keys.encode('%s;%s;%s'%(registration_profile.user.email,password,registration_profile.activation_key)), 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS, 'site': _current_site if (settings.IS_PRODUCTION_WEB_SERVER) else settings.LOCALHOST, 'site_name': _current_site, 'ssl':'s' if (settings.IS_PRODUCTION_SERVER) else '', } c['activation_symbol'] = '%sactivation/' % ('' if _current_site.endswith('/') else '/') message = django_utils.render_from_string(__registration_activation_email__,context=c) message_html = django_utils.render_from_string(__registration_activation_email_html__,context=c) try: logging.log(logging.INFO,'sender="%s Support <%s>"' % (air_sender(air_id),air_sender(air_id))) queue_email(air_sender(air_id),new_user.email,"Your User Account %sActivation%s for %s" % (prefix,' (%s)'%(reason) if (reason and misc.isString(reason) and (len(reason) > 0)) else '',air_site(air_id)),message,message_html,air_id,is_html=True,data=data,error_symbol=error_symbol) except Exception, e: info_string = _utils.formattedException(details=e) logging.error('RegistrationManager.create_inactive_user.ERROR --> %s' % (info_string))
def send_passwordChg_email(self,user,old_password,password,air_id='',domain_override=''): _current_site_ = domain_override if (domain_override and len(domain_override) > 0) else settings.CURRENT_SITE _current_site = _current_site_.replace('.appspot','').replace('.com','').capitalize() subject = django_utils.render_from_string(__registration_activation_email_subject__,context=Context({ 'site': _current_site },autoescape=False)) subject = ''.join(subject.splitlines()) # Email subject *must not* contain newlines c = { 'key': user.id, 'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS, 'site': _current_site_, 'site_name': _current_site, 'ssl':'s' if (settings.IS_PRODUCTION_SERVER) else '', 'air_id':air_id, 'old_password':old_password, 'password':password, } message = django_utils.render_from_string(__password_change_email__,context=c) message_html = django_utils.render_from_string(__password_change_email_html__,context=c) try: queue_email(air_sender(air_id),user.email,"Password Change Request for %s" % (air_site(air_id)),message,message_html,air_id,is_html=True) except Exception, e: info_string = _utils.formattedException(details=e) logging.error('RegistrationManager.changePassword.ERROR --> %s' % (info_string))
def as_html(self, request=None, width='100%', max_length=40, context={}): h = oohtml.Html() _no_show_fields = [] _action = self.action.split('/') for k, v in self.__hidden_fields__.iteritems(): if (str(v).isdigit()) and (int(v) > -1): _action.insert( len(_action) - (1 if (_action[-1] == '') else 0), '%s' % (v)) else: _no_show_fields.append(k) form = h.tag(oohtml.oohtml.FORM, name=self.form_name, id="%sForm" % (self.form_name), target=self.target, action='/'.join(_action), enctype="application/x-www-form-urlencoded", method="post") _remaining_fields = list( set(self.fields.keyOrder) - set(self.__field_ordering__) - set(_no_show_fields)) for k in self.__field_ordering__ + _remaining_fields: _k = "VALUE_%s" % (k.upper()) v = self.fields[k] _is_BooleanField = self.is_BooleanField(v) _is_DateTimeField = self.is_DateTimeField(v) _tr = form.tag(oohtml.oohtml.TR) _th = _tr.tag(oohtml.oohtml.TH, width="*", align="right") _nobr = _th.tagNOBR() _nobr.tagLABEL('id_%s' % k, '%s: ' % (v.label)) _td = _tr.tag(oohtml.oohtml.TD, align="left") ds = self.get_datasource_for_field_by_name(k) if (self.is_ModelChoiceField(v)) or (_is_BooleanField): _value_id = 'value' _text_id = 'text' choice_model = self.get_choice_model_for_field_by_name(k) if (choice_model is not None): _value_id = choice_model.value_id _text_id = choice_model.text_id else: try: keys = [ kk for kk in v.queryset[0].__dict__.keys() if (kk != 'version') ] for kk, vv in v.queryset[0].__dict__.iteritems(): if (kk in keys): if (misc.isString(vv)): _text_id = kk else: _value_id = kk if (len(_value_id) > 0) and (len(_text_id) > 0): break except: # possibly there is no data to populate so we do nothing here... pass _selected = self.get_choice_model_default_for_field_by_name(k) _selected = _selected if ( not context.has_key(_k)) else context[_k] _selected = _selected if (_selected is not None) else '' if (len(_selected) == 0) and (request is not None): _selected = request.POST[k] oohtml.render_select_content( v.queryset if (not _is_BooleanField) else [{ 'value': 'True', 'text': 'True' }, { 'value': 'False', 'text': 'False' }], tag=_td, id='id_%s' % (k), name=k, text_id=_text_id, value_id=_value_id, defaultChoose=True, selected=_selected) elif (_is_DateTimeField): _td.tagDIV( django_utils.render_from_string( self.datetime_field_content, context=context) + ' * Required' if ( v.required) else '') v.required = False elif (callable(ds)): oohtml.render_select_content( ds(), tag=_td, id='id_%s' % (k), name=k, text_id=_text_id, value_id=_value_id, defaultChoose=True, selected=self.get_choice_model_default_for_field_by_name( k)) else: _max_length = max_length try: _max_length = min(v.max_length, max_length) except: # Account for differences between various Django releases in this regard. pass _td.tagOp(oohtml.oohtml.INPUT, type=oohtml.oohtml.TEXT, name=k, size=_max_length, maxlength=_max_length, value="{{ %s }}" % (_k)) l = [] if (v.required): l.append('* Required') try: if (v.min_length) and (not self.is_ModelChoiceField(v)): l.append(' minimum %d chars' % (v.min_length)) except: pass _td.tagSPAN(' %s%s{{ ERROR_%s }}%s' % ('(' if (len(l) > 0) else '', ','.join(l), k.upper(), ')' if (len(l) > 0) else '')) tr = form.tag(oohtml.oohtml.TR) td = tr.tag(oohtml.oohtml.TD, align="left", colspan="2") if (misc.isString(self.captcha_form_name)) and (misc.isString( self.captcha_font_name)): td.tagDIV( captcha.render_captcha_form(self.request, form_name=self.captcha_form_name, font_name=self.captcha_font_name, font_size=self.captcha_font_size, choices=self.captcha_choices, fill=self.captcha_fill, bgImage=self.captcha_bgImage)) tr = form.tag(oohtml.oohtml.TR) td = tr.tag(oohtml.oohtml.TD, align="center", colspan="2") td.tagSUBMIT(self.submit_button_title, value=self.submit_button_value, onclick="this.disabled=true;") return h.toHtml()