Projet

Général

Profil

0001-lingo-notify-wcs-about-local-items-payment-9351.patch

Serghei Mihai (congés, retour 15/05), 10 janvier 2016 16:06

Télécharger (1,89 ko)

Voir les différences:

Subject: [PATCH] lingo: notify wcs about local items payment (#9351)

 combo/apps/lingo/models.py | 12 ++++++++----
 combo/apps/lingo/views.py  |  2 +-
 2 files changed, 9 insertions(+), 5 deletions(-)
combo/apps/lingo/models.py
173 173
    payment_date = models.DateTimeField(null=True)
174 174
    notification_date = models.DateTimeField(null=True)
175 175

  
176
    def notify(self):
177
        # TODO: sign with real values
178
        url = self.source_url + 'jump/trigger/paid?email=trigger@localhost&orig=combo'
179
        url = sign_url(url, key='xxx')
176
    def notify(self, request):
177
        for service in settings.KNOWN_SERVICES['combo']:
178
            if service['orig'] == request.get_host():
179
                this = service
180
                break
181
        params = urllib.urlencode({'email': self.user.email, 'orig': this['orig']})
182
        url = self.source_url + 'jump/trigger/paid?' + params
183
        url = sign_url(url, key=this['secret'])
180 184
        message = {'result': 'ok'}
181 185
        r = requests.post(url, data=json.dumps(message), timeout=3)
182 186
        self.notification_date = timezone.now()
combo/apps/lingo/views.py
200 200
            item.payment_date = transaction.end_date
201 201
            item.save()
202 202
            try:
203
                item.notify()
203
                item.notify(request)
204 204
            except:
205 205
                # ignore errors, it will be retried later on if it fails
206 206
                pass
207
-