示例#1
0
 def save(self, invoice):
     with transaction():
         self.invoice_issueing_signal.send(invoice)
         save_model(invoice)
     self.invoice_issued_signal.send(invoice)
     if invoice.email and self.options["send_email"]:
         self.send_email(invoice.email, invoice)
示例#2
0
 def update_model_vat_rates(self):
     with transaction():
         query = current_app.features.models.query(self.model)
         for country_code in EU_COUNTRIES:
             rate = self.service.get_vat_rate(country_code)
             for obj in query.filter(eu_vat_country=country_code, eu_vat_rate__ne=rate).all():
                 obj.eu_vat_rate = rate
                 self.model_rate_updated_signal.send(obj)
                 save_model(obj)
         self.rates_updated_signal.send(self)
示例#3
0
    def login_callback():
        resp = feature.api.authorized_response()
        if resp is None:
            flash(feature.options["user_denied_login_message"], "error")
            return redirect(url_for("users.login"))

        with transaction():
            users.current.slack_access_token = resp['access_token']
            users.current.slack_team_name = resp['team_name']
            users.current.slack_team_id = resp['team_id']
            if 'incoming_webhook' in resp:
                users.current.slack_incoming_webhook_url = resp['incoming_webhook']['url']
                users.current.slack_incoming_webhook_channel = resp['incoming_webhook']['channel']

        return redirect(request.args.get('next') or feature.options['default_redirect'])