예제 #1
0
def contact(request):
    if request.user.is_authenticated():
        initial = {
            'name': request.user.full_name,
            'email': request.user.username,
        }
        form = ContactForm(initial=initial)
    else:
        form = ContactForm()
    if request.method == 'POST':
        form = ContactForm(data=request.POST)
        if form.is_valid():
            email = form.cleaned_data['email']
            name = form.cleaned_data['name']
            message = form.cleaned_data['message']
            body_context = {
                'email': email,
                'name': name,
                'message': message,
            }
            send_and_log(
                subject='CoinSafe Support Message From %s' % name,
                body_template='admin/contact_form.html',
                to_merchant=None,
                to_email='*****@*****.**',
                to_name='CoinSafe Support',
                body_context=body_context,
                replyto_name=name,
                replyto_email=email,
            )
            msg = _("Message Received! We'll get back to you soon.")
            messages.success(request, msg, extra_tags='safe')
            return HttpResponseRedirect(reverse_lazy('home'))

    return {'form': form}
예제 #2
0
    def send_shopper_receipt(self):
        assert self.credential
        fiat_amount_formatted = self.get_fiat_amount_formatted()
        if self.btc_transaction:
            tx_hash = self.btc_transaction.txn_hash
        else:
            tx_hash = None
        body_context = {
            'fiat_amount_formatted': fiat_amount_formatted,
            'satoshis_formatted': self.format_satoshis_amount(),
            'shopper_name': self.shopper.name,
            'shopper_email': self.shopper.email,
            'shopper_btc_address': self.b58_address,
            'business_name': self.merchant.business_name,
            'exchange_rate_formatted': self.get_exchange_rate_formatted(),
            'payment_method_formatted':
            self.credential.get_credential_to_display(),
            'payment_method': self.credential.get_credential_abbrev(),
            'tx_hash': tx_hash,
        }
        email = send_and_log(
            subject='%s Received' % fiat_amount_formatted,
            body_template='shopper/cashin.html',
            to_merchant=None,
            to_name=self.shopper.name,
            to_email=self.shopper.email,
            body_context=body_context,
        )

        self.shopper_email_sent_at = now()
        self.save()

        return email
예제 #3
0
파일: models.py 프로젝트: rebroad/explorer
 def send_unconfirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     context_dict = {
         'b58_address':
         b58_address,
         'coin_symbol':
         self.address_subscription.coin_symbol,
         'sent_in_btc':
         satoshis_to_btc_rounded(self.satoshis_sent),
         'fee_in_btc':
         satoshis_to_btc_rounded(self.fee_in_satoshis),
         'currency_display_name':
         self.address_subscription.get_currency_display_name(),
         'currency_abbrev':
         self.address_subscription.get_currency_abbrev(),
         'tx_hash':
         self.tx_hash,
         'num_confs':
         self.num_confs,
     }
     if self.address_subscription.address_forwarding_obj:
         context_dict[
             'destination_address'] = self.address_subscription.address_forwarding_obj.destination_address
         context_dict['satoshis_transacted'] = self.satoshis_sent
     fkey_objs = {
         'transaction_event': self,
         'address_subscription': self.address_subscription,
     }
     return send_and_log(
         subject='Unconfirmed Transaction for %s' % b58_address,
         body_template='new_tx.html',
         to_user=self.address_subscription.auth_user,
         body_context=context_dict,
         fkey_objs=fkey_objs,
     )
예제 #4
0
 def send_confirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     context_dict = {
         'b58_address':
         b58_address,
         'coin_symbol':
         self.address_subscription.coin_symbol,
         'tx_hash':
         self.tx_hash,
         'num_confs':
         self.num_confs,
         'currency_display_name':
         self.address_subscription.get_currency_display_name(),
     }
     fkey_objs = {
         'transaction_event': self,
         'address_subscription': self.address_subscription,
     }
     return send_and_log(
         subject='Transaction %s... Confirmed' % self.tx_hash[:10],
         body_template='confirmed_tx.html',
         to_user=self.address_subscription.auth_user,
         body_context=context_dict,
         fkey_objs=fkey_objs,
     )
예제 #5
0
 def send_unconfirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     sent_in_btc = format_crypto_units(
         input_quantity=self.satoshis_sent,
         input_type='satoshi',
         output_type='btc',
         coin_symbol=self.address_subscription.coin_symbol,
         print_cs=False,
         safe_trimming=False,
         round_digits=4,
     )
     fee_in_btc = format_crypto_units(
         input_quantity=self.fee_in_satoshis,
         input_type='satoshi',
         output_type='btc',
         coin_symbol=self.address_subscription.coin_symbol,
         print_cs=False,
         safe_trimming=False,
         round_digits=4,
     )
     context_dict = {
         'b58_address':
         b58_address,
         'coin_symbol':
         self.address_subscription.coin_symbol,
         'sent_in_btc':
         sent_in_btc,
         'fee_in_btc':
         fee_in_btc,
         'currency_display_name':
         self.address_subscription.get_currency_display_name(),
         'currency_abbrev':
         self.address_subscription.get_currency_abbrev(),
         'tx_hash':
         self.tx_hash,
         'num_confs':
         self.num_confs,
     }
     if self.address_subscription.address_forwarding_obj:
         context_dict[
             'destination_address'] = self.address_subscription.address_forwarding_obj.destination_address
         context_dict['satoshis_transacted'] = self.satoshis_sent
     fkey_objs = {
         'transaction_event': self,
         'address_subscription': self.address_subscription,
     }
     return send_and_log(
         subject='Unconfirmed Transaction for %s' % b58_address,
         body_template='new_tx.html',
         to_user=self.address_subscription.auth_user,
         body_context=context_dict,
         fkey_objs=fkey_objs,
     )
예제 #6
0
파일: models.py 프로젝트: 9kopb/explorer
 def send_pwreset_email(self):
     """
     Send password reset email to user.
     """
     # TODO: add some sort of throttling
     return send_and_log(
             subject='Blockcypher Password Reset',
             body_template='password_reset.html',
             to_user=self,
             body_context={},
             fkey_objs={'auth_user': self},
             )
예제 #7
0
 def send_pwreset_email(self):
     """
     Send password reset email to user.
     """
     # TODO: add some sort of throttling
     return send_and_log(
         subject='Blockcypher Password Reset',
         body_template='password_reset.html',
         to_user=self,
         body_context={},
         fkey_objs={'auth_user': self},
     )
예제 #8
0
 def send_pwreset_email(self):
     """
     Send password reset email to merchant.
     May require small changes for users generally.
     """
     auth_user = self.auth_user
     body_context = {'pw_reset_uri': self.get_reset_pw_uri()}
     return send_and_log(
         subject='CoinSafe Password Reset for %s' % auth_user.full_name,
         body_template='user/password_reset.html',
         to_merchant=auth_user.get_merchant(),
         body_context=body_context,
     )
예제 #9
0
파일: models.py 프로젝트: RIDHA12/explorer
 def send_notifications_welcome_email(self):
     # TODO: add abuse check so you can only send this email to an  unconfirmed user X times
     b58_address = self.b58_address
     context_dict = {
         "b58_address": b58_address,
         "cs_display": COIN_SYMBOL_MAPPINGS[self.coin_symbol]["display_name"],
     }
     return send_and_log(
         subject="Please Confirm Your Email Subscription to %s" % b58_address,
         body_template="new_user_confirmation.html",
         to_user=self.auth_user,
         body_context=context_dict,
         fkey_objs={"address_subscription": self},
     )
예제 #10
0
파일: models.py 프로젝트: rebroad/explorer
 def send_notifications_welcome_email(self):
     # TODO: add abuse check so you can only send this email to an  unconfirmed user X times
     b58_address = self.b58_address
     context_dict = {
             'b58_address': b58_address,
             'cs_display': COIN_SYMBOL_MAPPINGS[self.coin_symbol]['display_name']
             }
     return send_and_log(
             subject='Please Confirm Your Email Subscription to %s' % b58_address,
             body_template='new_user_confirmation.html',
             to_user=self.auth_user,
             body_context=context_dict,
             fkey_objs={'address_subscription': self},
             )
예제 #11
0
파일: models.py 프로젝트: 7788a/explorer
 def send_welcome_email(self):
     # TODO: add abuse check so you can only send this email to an  unconvirmed user X times
     b58_address = self.b58_address
     context_dict = {
             'b58_address': b58_address,
             'cs_display': COIN_SYMBOL_MAPPINGS[self.coin_symbol]['display_name']
             }
     return send_and_log(
             subject='Please Confirm Your Email Subscription to %s' % b58_address,
             body_template='new_user_confirmation.html',
             to_user=self.auth_user,
             body_context=context_dict,
             fkey_objs={'address_subscription': self},
             )
예제 #12
0
파일: models.py 프로젝트: Bithome/explorer
 def send_unconfirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     sent_in_btc = format_crypto_units(
             input_quantity=self.satoshis_sent,
             input_type='satoshi',
             output_type='btc',
             coin_symbol=self.address_subscription.coin_symbol,
             print_cs=False,
             safe_trimming=False,
             round_digits=4,
             )
     fee_in_btc = format_crypto_units(
             input_quantity=self.fee_in_satoshis,
             input_type='satoshi',
             output_type='btc',
             coin_symbol=self.address_subscription.coin_symbol,
             print_cs=False,
             safe_trimming=False,
             round_digits=4,
             )
     context_dict = {
             'b58_address': b58_address,
             'coin_symbol': self.address_subscription.coin_symbol,
             'sent_in_btc': sent_in_btc,
             'fee_in_btc': fee_in_btc,
             'currency_display_name': self.address_subscription.get_currency_display_name(),
             'currency_abbrev': self.address_subscription.get_currency_abbrev(),
             'tx_hash': self.tx_hash,
             'num_confs': self.num_confs,
             }
     if self.address_subscription.address_forwarding_obj:
             context_dict['destination_address'] = self.address_subscription.address_forwarding_obj.destination_address
             context_dict['satoshis_transacted'] = self.satoshis_sent
     fkey_objs = {
             'transaction_event': self,
             'address_subscription': self.address_subscription,
             }
     return send_and_log(
             subject='Unconfirmed Transaction for %s' % b58_address,
             body_template='new_tx.html',
             to_user=self.address_subscription.auth_user,
             body_context=context_dict,
             fkey_objs=fkey_objs,
             )
예제 #13
0
def send_nag_email(body_template, merchant, subject, context_dict={}):
    ''' Returns true if we should send and false otherwise '''

    # TODO: abstract this
    from_name = 'Michael Flaxman'
    from_email = '*****@*****.**'

    test_mail_merge(body_template=body_template, context_dict=context_dict)

    bt_clean = body_template.split('/')[-1]

    sent_email = get_object_or_None(SentEmail,
                                    body_template=body_template,
                                    to_merchant=merchant)

    if sent_email:
        dp("Did NOT send %s to %s (already sent on %s)" %
           (bt_clean, merchant, sent_email.sent_at))
        return

    recent_time = now() - timedelta(hours=48)
    num_recent_emails = SentEmail.objects.filter(sent_at__gt=recent_time,
                                                 to_merchant=merchant).count()
    if num_recent_emails > 0:
        dp("Did NOT send %s to %s (recently contacted about something else)" %
           (bt_clean, merchant))
        return

    if not custom_confirm(bt_clean, merchant):
        dp("Did NOT send %s to %s" % (bt_clean, merchant))
        return

    dp('Sending %s to %s...' % (bt_clean, merchant))
    return send_and_log(
        subject=subject,
        to_merchant=merchant,
        body_template=body_template,
        body_context=context_dict,
        from_name=from_name,
        from_email=from_email,
        #cc_name='CoinSafe Support',
        #cc_email='*****@*****.**',
        is_transactional=False,
    )
예제 #14
0
파일: models.py 프로젝트: RIDHA12/explorer
    def send_forwarding_welcome_email(self):
        # TODO: add abuse check so you can only send this email to an unconfirmed user X times

        if not self.auth_user:
            return

        context_dict = {
            "initial_address": self.initial_address,
            "destination_address": self.destination_address,
            "cs_display": COIN_SYMBOL_MAPPINGS[self.coin_symbol]["display_name"],
        }
        fkey_objs = {"address_forwarding": self}
        return send_and_log(
            subject="Please Confirm Your Email Subscription to %s" % self.initial_address,
            body_template="new_user_forwarding.html",
            to_user=self.auth_user,
            body_context=context_dict,
            fkey_objs=fkey_objs,
        )
예제 #15
0
파일: models.py 프로젝트: 7788a/explorer
 def send_confirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     context_dict = {
             'b58_address': b58_address,
             'coin_symbol': self.address_subscription.coin_symbol,
             'tx_hash': self.tx_hash,
             'num_confs': self.num_confs,
             'currency_display_name': self.address_subscription.get_currency_display_name(),
             }
     fkey_objs = {
             'transaction_event': self,
             'address_subscription': self.address_subscription,
             }
     return send_and_log(
             subject='Transaction %s... Confirmed' % self.tx_hash[:10],
             body_template='confirmed_tx.html',
             to_user=self.address_subscription.auth_user,
             body_context=context_dict,
             fkey_objs=fkey_objs,
             )
예제 #16
0
파일: models.py 프로젝트: rebroad/explorer
    def send_forwarding_welcome_email(self):
        # TODO: add abuse check so you can only send this email to an unconfirmed user X times

        if not self.auth_user:
            return

        context_dict = {
                'initial_address': self.initial_address,
                'destination_address': self.destination_address,
                'cs_display': COIN_SYMBOL_MAPPINGS[self.coin_symbol]['display_name']
                }
        fkey_objs = {
                'address_forwarding': self,
                }
        return send_and_log(
                subject='Please Confirm Your Email Subscription to %s' % self.initial_address,
                body_template='new_user_forwarding.html',
                to_user=self.auth_user,
                body_context=context_dict,
                fkey_objs=fkey_objs,
                )
예제 #17
0
파일: models.py 프로젝트: 7788a/explorer
 def send_unconfirmed_tx_email(self):
     b58_address = self.address_subscription.b58_address
     context_dict = {
             'b58_address': b58_address,
             'coin_symbol': self.address_subscription.coin_symbol,
             'sent_in_btc': satoshis_to_btc_rounded(self.satoshis_sent),
             'fee_in_btc': satoshis_to_btc_rounded(self.fee_in_satoshis),
             'currency_display_name': self.address_subscription.get_currency_display_name(),
             'currency_abbrev': self.address_subscription.get_currency_abbrev(),
             'tx_hash': self.tx_hash,
             'num_confs': self.num_confs,
             }
     fkey_objs = {
             'transaction_event': self,
             'address_subscription': self.address_subscription,
             }
     return send_and_log(
             subject='Unconfirmed Transaction for %s' % b58_address,
             body_template='new_tx.html',
             to_user=self.address_subscription.auth_user,
             body_context=context_dict,
             fkey_objs=fkey_objs,
             )
예제 #18
0
    def send_shopper_txconfirmed_email(self, force_resend=False):

        BODY_TEMPLATE = 'shopper/cashout_txconfirmed.html'
        if get_object_or_None(SentEmail,
                              btc_transaction=self,
                              body_template=BODY_TEMPLATE):
            if not force_resend:
                # Protection against double-sending
                return

        shopper = self.get_shopper()
        if shopper and shopper.email:
            merchant = self.get_merchant()
            satoshis_formatted = self.format_satoshis_amount()
            body_context = {
                'salutation': shopper.name,
                'satoshis_formatted': satoshis_formatted,
                'merchant_name': merchant.business_name,
                'exchange_rate_formatted': self.get_exchange_rate_formatted(),
                'fiat_amount_formatted': self.get_fiat_amount_formatted(),
                'tx_hash': self.txn_hash,
                # Verbose, but needed for future internationalizing of templates:
                'confirmed_via_blocks': bool(self.met_minimum_confirmation_at),
                'confirmed_via_confidence':
                bool(self.met_confidence_threshold_at),
                'confirmed_via_merchant':
                bool(self.min_confirmations_overrode_at),
            }
            return send_and_log(
                subject='%s Confirmed' % satoshis_formatted,
                body_template=BODY_TEMPLATE,
                to_merchant=None,
                to_email=shopper.email,
                to_name=shopper.name,
                body_context=body_context,
                btc_transaction=self,
            )
예제 #19
0
    def send_merchant_txconfirmed_email(self, force_resend=False):
        # TODO: allow for notification settings

        BODY_TEMPLATE = 'merchant/shopper_cashout.html'
        if get_object_or_None(SentEmail,
                              btc_transaction=self,
                              body_template=BODY_TEMPLATE):
            if not force_resend:
                # Protection against double-sending
                return

        merchant = self.get_merchant()
        shopper = self.get_shopper()
        satoshis_formatted = self.format_satoshis_amount()
        body_context = {
            'satoshis_formatted': satoshis_formatted,
            'exchange_rate_formatted': self.get_exchange_rate_formatted(),
            'fiat_amount_formatted': self.get_fiat_amount_formatted(),
            'tx_hash': self.txn_hash,
            'coinsafe_tx_uri': reverse('merchant_transactions'),
            # Verbose, but needed for future internationalizing of templates:
            'confirmed_via_blocks': bool(self.met_minimum_confirmation_at),
            'confirmed_via_confidence': bool(self.met_confidence_threshold_at),
            'confirmed_via_merchant': bool(self.min_confirmations_overrode_at),
        }
        subject = '%s Received' % satoshis_formatted
        if shopper and shopper.name:
            subject += 'from %s' % shopper.name
            body_context['shopper_name'] = shopper.name
        return send_and_log(
            body_template=BODY_TEMPLATE,
            subject='%s Received' % satoshis_formatted,
            to_merchant=merchant,
            body_context=body_context,
            btc_transaction=self,
        )